Skip to content

Commit e0ce6ce

Browse files
committed
code updates
1 parent 9aae862 commit e0ce6ce

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

articles/machine-learning/service/how-to-train-sklearn.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Run this code on either of these environments:
3434
- [Create a workspace configuration file](setup-create-workspace.md#write-a-configuration-file)
3535
- [Download the sample script file](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/training/train-hyperparameter-tune-deploy-with-sklearn) `train_iris.py`
3636

37-
You can also find a completed [Jupyter Notebook version](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training/train-hyperparameter-tune-deploy-with-keras/train-hyperparameter-tune-deploy-with-sklearn.ipynb) of this guide on the GitHub samples page. The notebook includes an expanded section covering intelligent hyperparameter tuning.
37+
You can also find a completed [Jupyter Notebook version](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training/train-hyperparameter-tune-deploy-with-keras/train-hyperparameter-tune-deploy-with-sklearn.ipynb) of this guide on the GitHub samples page. The notebook includes an expanded section covering intelligent hyperparameter tuning and retrieving the best model by primary metrics.
3838

3939
## Set up the experiment
4040

@@ -103,17 +103,17 @@ The [datastore](how-to-access-data.md) is a place where data can be stored and a
103103

104104
## Create a compute target
105105

106-
Create a compute target for your Scikit-learn job to run on. In this example, create a GPU-enabled Azure Machine Learning compute cluster. If you instead want to create CPU compute, provide a different VM size to the vm_size parameter, such as STANDARD_D2_V2.
106+
Create a compute target for your Scikit-learn job to run on. Scikit learn only supports single node, CPU computing.
107107

108108
```Python
109-
cluster_name = "gpucluster"
109+
cluster_name = "cpu-cluster"
110110

111111
try:
112112
compute_target = ComputeTarget(workspace=ws, name=cluster_name)
113113
print('Found existing compute target')
114114
except ComputeTargetException:
115115
print('Creating a new compute target...')
116-
compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_NC6',
116+
compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2',
117117
max_nodes=4)
118118

119119
compute_target = ComputeTarget.create(ws, cluster_name, compute_config)
@@ -141,6 +141,7 @@ estimator = SKLearn(source_directory=project_folder,
141141
script_params=script_params,
142142
compute_target=compute_target,
143143
entry_script='train_iris.py'
144+
pip_packages=['joblib']
144145
)
145146
```
146147

@@ -166,17 +167,19 @@ As the Run is executed, it goes through the following stages:
166167
## Save and register the model
167168

168169
Once you've trained the model, you can save and register it to your workspace. Model registration lets you store and version your models in your workspace to simplify [model management and deployment](concept-model-management-and-deployment.md).
169-
170-
To save the model, include the following code to your training script, train_iris.py.
170+
171+
The following code saves the model as part of the training script, train_iris.py.
171172

172173
``` Python
173-
save model code
174+
import joblib
175+
176+
joblib.dump(svm_model_linear, 'model.joblib')
174177
```
175178

176179
Register the model with the following code.
177180

178181
```Python
179-
model = run.register_model(model_name='sklearn-iris', model_path='outputs/model')
182+
model = run.register_model(model_name='sklearn-iris', model_path='model.joblib')
180183
```
181184

182185
## Next steps

0 commit comments

Comments
 (0)