Skip to content

Commit 9aae862

Browse files
committed
Save & register H2
1 parent c3496cc commit 9aae862

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

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

Lines changed: 9 additions & 14 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 expanded sections covering intelligent hyperparameter tuning, model deployment, and notebook widgets.
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.
3838

3939
## Set up the experiment
4040

@@ -163,25 +163,20 @@ As the Run is executed, it goes through the following stages:
163163

164164
- **Post-Processing**: The ./outputs folder of the run is copied over to the run history.
165165

166-
## Register or download a model
166+
## Save and register the model
167167

168-
Once you've trained the model, you can 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).
168+
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.
169171

170-
```Python
171-
model = run.register_model(model_name='sklearn-iris', model_path='outputs/model')
172+
``` Python
173+
save model code
172174
```
173175

174-
You can also download a local copy of the model by using the Run object. In the training script `train_iris.py`, a Scikit-learn saver object persists the model to a local folder (local to the compute target). You can use the Run object to download a copy.
176+
Register the model with the following code.
175177

176178
```Python
177-
# Create a model folder in the current directory
178-
os.makedirs('./model', exist_ok=True)
179-
180-
for f in run.get_file_names():
181-
if f.startswith('outputs/model'):
182-
output_file_path = os.path.join('./model', f.split('/')[-1])
183-
print('Downloading from {} to {} ...'.format(f, output_file_path))
184-
run.download_file(name=f, output_file_path=output_file_path)
179+
model = run.register_model(model_name='sklearn-iris', model_path='outputs/model')
185180
```
186181

187182
## Next steps

0 commit comments

Comments
 (0)