A data scientist has exported an experimentation notebook to a Python script named train.py. The script will be run every week as a command job in Azure Machine Learning. The script still contains print() and df.head() calls that were used to explore the data. Nobody on the team plans to review the script's printed output. The team also wants to be able to test individual parts of the training logic, such as reading and splitting the data, separately.
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
| Statement | Yes | No |
|---|---|---|
| The print() and df.head() calls should be removed from train.py before it is run weekly as a command job. The exploratory calls serve no purpose because nobody will review the output, and nonessential code should be removed from production scripts to keep them clean and easy to maintain. | Correct | |
| To meet the team's testing goal, the training logic should be combined into one large function. Multiple smaller functions, such as one to read data and one to split data, let the team test a small part of the code without running more than necessary; one large function works against that goal. | Correct | |
| If a weekly job fails because train.py is missing an import statement, the error message appears in the std_log.txt file on the job's Outputs + logs tab. std_log.txt contains the output of the job's command, and when a job fails because of an issue in the script, the error message is shown in that file. | Correct |
Preparing a script for production means removing exploratory code that will not be reviewed, because code with no purpose should be removed when nobody reviews the output. Splitting the logic into several small functions makes the code easier to read and lets parts like data reading and splitting be tested on their own. Once the script runs as a command job, its command output is captured in std_log.txt under Outputs + logs, and errors caused by the script, such as a missing import, are reported there.