
Answer-first summary for fast verification
Answer: No
The solution does NOT meet the goal because it fails to properly configure the environment with the required scikit-learn package. The code attempts to set `run_config.environment.python.conda_dependencies = 'scikit-learn'`, which is incorrect syntax - conda_dependencies should be a CondaDependencies object, not a string. Additionally, the environment is not properly initialized or imported from Azure ML's Environment class. The community discussion (with 100% consensus for 'No' and upvoted comments) confirms this, noting that the Environment class was not imported and there are no proper environment definition methods like `from_conda_specification` or proper dependency management. The correct approach would involve creating an Environment object with proper conda or pip dependencies.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You have a Python script named train.py in a local folder named scripts. The script trains a regression model using scikit-learn and includes code to load a training data file from the same scripts folder.
You must run the script as an Azure ML experiment on a compute cluster named aml-compute. You need to configure the run to ensure the environment includes the required packages for model training. You have instantiated a variable named aml_compute that references the target compute cluster.
Solution: Run the following code:
from azureml.core import ScriptRunConfig, Experiment
src = ScriptRunConfig(source_directory='scripts',
script='train.py',
compute_target=aml_compute)
run_config = src.run_config
run_config.environment.python.conda_dependencies = 'scikit-learn'
experiment = Experiment(workspace=ws, name='train-experiment')
run = experiment.submit(src)
from azureml.core import ScriptRunConfig, Experiment
src = ScriptRunConfig(source_directory='scripts',
script='train.py',
compute_target=aml_compute)
run_config = src.run_config
run_config.environment.python.conda_dependencies = 'scikit-learn'
experiment = Experiment(workspace=ws, name='train-experiment')
run = experiment.submit(src)
Does the solution meet the goal?

A
Yes
B
No
No comments yet.