Skip to content

Commit a85e783

Browse files
committed
changes from shourya
1 parent 666c4c9 commit a85e783

File tree

1 file changed

+8
-59
lines changed

1 file changed

+8
-59
lines changed

articles/machine-learning/migrate-to-v2-execution-automl.md

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,14 @@ This article gives a comparison of scenario(s) in SDK v1 and SDK v2.
2727

2828
```python
2929
# Imports
30-
import logging
31-
32-
from matplotlib import pyplot as plt
33-
import pandas as pd
34-
import os
35-
30+
3631
import azureml.core
3732
from azureml.core.experiment import Experiment
3833
from azureml.core.workspace import Workspace
3934
from azureml.core.dataset import Dataset
4035
from azureml.train.automl import AutoMLConfig
41-
from azureml.train.automl.run import AutoMLRun
42-
43-
from azureml.widgets import RunDetails
44-
45-
36+
from azureml.train.automl.run import AutoMLRun
37+
4638
# Load tabular dataset
4739
data = "<url_to_data>"
4840
dataset = Dataset.Tabular.from_delimited_files(data)
@@ -71,21 +63,14 @@ This article gives a comparison of scenario(s) in SDK v1 and SDK v2.
7163

7264
# Submit run
7365
remote_run = experiment.submit(automl_config, show_output=False)
74-
75-
# Register the best model
76-
best_run, fitted_model = remote_run.get_output()
77-
fitted_model
78-
description = 'My AutoML Model'
79-
model = run.register_model(description = description,
80-
tags={'area': 'qna'}) # AutoML Run Object
66+
azureml_url = remote_run.get_portal_url()
67+
print(azureml_url)
8168
```
8269

8370
* SDK v2: Below is a sample AutoML classification task. For the entire code, check out our [examples repo](https://github.com/Azure/azureml-examples/blob/main/sdk/jobs/automl-standalone-jobs/automl-classification-task-bankmarketing/automl-classification-task-bankmarketing-mlflow.ipynb).
8471

8572
```python
8673
# Imports
87-
from azure.identity import DefaultAzureCredential
88-
from azure.identity import AzureCliCredential
8974
from azure.ai.ml import automl, Input, MLClient
9075

9176
from azure.ai.ml.constants import AssetTypes
@@ -95,19 +80,7 @@ This article gives a comparison of scenario(s) in SDK v1 and SDK v2.
9580
ClassificationModels,
9681
)
9782

98-
import mlflow
99-
from mlflow.tracking.client import MlflowClient
100-
101-
from azure.ai.ml.entities import (
102-
ManagedOnlineEndpoint,
103-
ManagedOnlineDeployment,
104-
Model,
105-
Environment,
106-
CodeConfiguration,
107-
ProbeSettings,
108-
)
109-
from azure.ai.ml.constants import ModelType
110-
83+
11184
# Create MLTables for training dataset
11285
# Note that AutoML Job can also take in tabular data
11386
my_training_data_input = Input(
@@ -143,32 +116,8 @@ This article gives a comparison of scenario(s) in SDK v1 and SDK v2.
143116
)
144117

145118
# Submit the AutoML job
146-
job_name = ml_client.jobs.create_or_update(
147-
classification_job
148-
)
149-
150-
print(f"Created job: {returned_job}")
151-
152-
# Set up MLFLow
153-
MLFLOW_TRACKING_URI = ml_client.workspaces.get(
154-
name=ml_client.workspace_name
155-
).mlflow_tracking_uri
156-
mlflow.set_tracking_uri(MLFLOW_TRACKING_URI)
157-
mlflow_client = MlflowClient()
158-
159-
# Get the AutoML best run
160-
mlflow_parent_run = mlflow_client.get_run(job_name)
161-
best_child_run_id = mlflow_parent_run.data.tags["automl_best_child_run_id"]
162-
best_run = mlflow_client.get_run(best_child_run_id)
163-
164-
# Register the best model
165-
model_name = "bankmarketing-model"
166-
model = Model(
167-
path=f"azureml://jobs/{best_run.info.run_id}/outputs/artifacts/outputs/model.pkl",
168-
name=model_name,
169-
description="my sample mlflow model",
170-
)
171-
registered_model = ml_client.models.create_or_update(model)
119+
returned_job = ml_client.jobs.create_or_update(classification_job)
120+
returned_job
172121
```
173122

174123
## Mapping of key functionality in SDK v1 and SDK v2

0 commit comments

Comments
 (0)