Skip to content

Commit 71e061b

Browse files
committed
update samples from Release-114 as a part of 1.38.0 SDK stable release
1 parent 9094da4 commit 71e061b

File tree

87 files changed

+27934
-12051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+27934
-12051
lines changed

how-to-use-azureml/automated-machine-learning/classification-bank-marketing-all-features/auto-ml-classification-bank-marketing-all-features.ipynb

Lines changed: 933 additions & 918 deletions
Large diffs are not rendered by default.

how-to-use-azureml/automated-machine-learning/classification-credit-card-fraud/auto-ml-classification-credit-card-fraud.ipynb

Lines changed: 481 additions & 495 deletions
Large diffs are not rendered by default.

how-to-use-azureml/automated-machine-learning/classification-text-dnn/auto-ml-classification-text-dnn.ipynb

Lines changed: 589 additions & 588 deletions
Large diffs are not rendered by default.

how-to-use-azureml/automated-machine-learning/classification-text-dnn/helper.py

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,65 @@
44
from azureml.core.run import Run
55

66

7-
def run_inference(test_experiment, compute_target, script_folder, train_run,
8-
test_dataset, target_column_name, model_name):
7+
def run_inference(
8+
test_experiment,
9+
compute_target,
10+
script_folder,
11+
train_run,
12+
test_dataset,
13+
target_column_name,
14+
model_name,
15+
):
916

1017
inference_env = train_run.get_environment()
1118

12-
est = Estimator(source_directory=script_folder,
13-
entry_script='infer.py',
14-
script_params={
15-
'--target_column_name': target_column_name,
16-
'--model_name': model_name
17-
},
18-
inputs=[
19-
test_dataset.as_named_input('test_data')
20-
],
21-
compute_target=compute_target,
22-
environment_definition=inference_env)
19+
est = Estimator(
20+
source_directory=script_folder,
21+
entry_script="infer.py",
22+
script_params={
23+
"--target_column_name": target_column_name,
24+
"--model_name": model_name,
25+
},
26+
inputs=[test_dataset.as_named_input("test_data")],
27+
compute_target=compute_target,
28+
environment_definition=inference_env,
29+
)
2330

2431
run = test_experiment.submit(
25-
est, tags={
26-
'training_run_id': train_run.id,
27-
'run_algorithm': train_run.properties['run_algorithm'],
28-
'valid_score': train_run.properties['score'],
29-
'primary_metric': train_run.properties['primary_metric']
30-
})
31-
32-
run.log("run_algorithm", run.tags['run_algorithm'])
32+
est,
33+
tags={
34+
"training_run_id": train_run.id,
35+
"run_algorithm": train_run.properties["run_algorithm"],
36+
"valid_score": train_run.properties["score"],
37+
"primary_metric": train_run.properties["primary_metric"],
38+
},
39+
)
40+
41+
run.log("run_algorithm", run.tags["run_algorithm"])
3342
return run
3443

3544

3645
def get_result_df(remote_run):
3746

3847
children = list(remote_run.get_children(recursive=True))
39-
summary_df = pd.DataFrame(index=['run_id', 'run_algorithm',
40-
'primary_metric', 'Score'])
48+
summary_df = pd.DataFrame(
49+
index=["run_id", "run_algorithm", "primary_metric", "Score"]
50+
)
4151
goal_minimize = False
4252
for run in children:
43-
if('run_algorithm' in run.properties and 'score' in run.properties):
44-
summary_df[run.id] = [run.id, run.properties['run_algorithm'],
45-
run.properties['primary_metric'],
46-
float(run.properties['score'])]
47-
if('goal' in run.properties):
48-
goal_minimize = run.properties['goal'].split('_')[-1] == 'min'
53+
if "run_algorithm" in run.properties and "score" in run.properties:
54+
summary_df[run.id] = [
55+
run.id,
56+
run.properties["run_algorithm"],
57+
run.properties["primary_metric"],
58+
float(run.properties["score"]),
59+
]
60+
if "goal" in run.properties:
61+
goal_minimize = run.properties["goal"].split("_")[-1] == "min"
4962

5063
summary_df = summary_df.T.sort_values(
51-
'Score',
52-
ascending=goal_minimize).drop_duplicates(['run_algorithm'])
53-
summary_df = summary_df.set_index('run_algorithm')
64+
"Score", ascending=goal_minimize
65+
).drop_duplicates(["run_algorithm"])
66+
summary_df = summary_df.set_index("run_algorithm")
5467

5568
return summary_df

how-to-use-azureml/automated-machine-learning/classification-text-dnn/infer.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,39 @@
1212

1313
parser = argparse.ArgumentParser()
1414
parser.add_argument(
15-
'--target_column_name', type=str, dest='target_column_name',
16-
help='Target Column Name')
15+
"--target_column_name",
16+
type=str,
17+
dest="target_column_name",
18+
help="Target Column Name",
19+
)
1720
parser.add_argument(
18-
'--model_name', type=str, dest='model_name',
19-
help='Name of registered model')
21+
"--model_name", type=str, dest="model_name", help="Name of registered model"
22+
)
2023

2124
args = parser.parse_args()
2225
target_column_name = args.target_column_name
2326
model_name = args.model_name
2427

25-
print('args passed are: ')
26-
print('Target column name: ', target_column_name)
27-
print('Name of registered model: ', model_name)
28+
print("args passed are: ")
29+
print("Target column name: ", target_column_name)
30+
print("Name of registered model: ", model_name)
2831

2932
model_path = Model.get_model_path(model_name)
3033
# deserialize the model file back into a sklearn model
3134
model = joblib.load(model_path)
3235

3336
run = Run.get_context()
3437
# get input dataset by name
35-
test_dataset = run.input_datasets['test_data']
38+
test_dataset = run.input_datasets["test_data"]
3639

37-
X_test_df = test_dataset.drop_columns(columns=[target_column_name]) \
38-
.to_pandas_dataframe()
39-
y_test_df = test_dataset.with_timestamp_columns(None) \
40-
.keep_columns(columns=[target_column_name]) \
41-
.to_pandas_dataframe()
40+
X_test_df = test_dataset.drop_columns(
41+
columns=[target_column_name]
42+
).to_pandas_dataframe()
43+
y_test_df = (
44+
test_dataset.with_timestamp_columns(None)
45+
.keep_columns(columns=[target_column_name])
46+
.to_pandas_dataframe()
47+
)
4248

4349
predicted = model.predict_proba(X_test_df)
4450

@@ -47,11 +53,13 @@
4753

4854
# Use the AutoML scoring module
4955
train_labels = model.classes_
50-
class_labels = np.unique(np.concatenate((y_test_df.values, np.reshape(train_labels, (-1, 1)))))
56+
class_labels = np.unique(
57+
np.concatenate((y_test_df.values, np.reshape(train_labels, (-1, 1))))
58+
)
5159
classification_metrics = list(constants.CLASSIFICATION_SCALAR_SET)
52-
scores = scoring.score_classification(y_test_df.values, predicted,
53-
classification_metrics,
54-
class_labels, train_labels)
60+
scores = scoring.score_classification(
61+
y_test_df.values, predicted, classification_metrics, class_labels, train_labels
62+
)
5563

5664
print("scores:")
5765
print(scores)

0 commit comments

Comments
 (0)