Skip to content

Commit d0dc483

Browse files
committed
update samples from Release-61 as a part of SDK release
1 parent 79739b5 commit d0dc483

File tree

46 files changed

+1737
-1394
lines changed

Some content is hidden

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

46 files changed

+1737
-1394
lines changed

configuration.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"source": [
104104
"import azureml.core\n",
105105
"\n",
106-
"print(\"This notebook was created using version 1.11.0 of the Azure ML SDK\")\n",
106+
"print(\"This notebook was created using version 1.12.0 of the Azure ML SDK\")\n",
107107
"print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")"
108108
]
109109
},

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

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"from azureml.automl.core.featurization import FeaturizationConfig\n",
9090
"from azureml.core.dataset import Dataset\n",
9191
"from azureml.train.automl import AutoMLConfig\n",
92-
"from azureml.explain.model._internal.explanation_client import ExplanationClient"
92+
"from azureml.interpret._internal.explanation_client import ExplanationClient"
9393
]
9494
},
9595
{
@@ -105,7 +105,7 @@
105105
"metadata": {},
106106
"outputs": [],
107107
"source": [
108-
"print(\"This notebook was created using version 1.11.0 of the Azure ML SDK\")\n",
108+
"print(\"This notebook was created using version 1.12.0 of the Azure ML SDK\")\n",
109109
"print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")"
110110
]
111111
},
@@ -733,24 +733,6 @@
733733
"print(aci_service.state)"
734734
]
735735
},
736-
{
737-
"cell_type": "markdown",
738-
"metadata": {},
739-
"source": [
740-
"### Delete a Web Service\n",
741-
"\n",
742-
"Deletes the specified web service."
743-
]
744-
},
745-
{
746-
"cell_type": "code",
747-
"execution_count": null,
748-
"metadata": {},
749-
"outputs": [],
750-
"source": [
751-
"#aci_service.delete()"
752-
]
753-
},
754736
{
755737
"cell_type": "markdown",
756738
"metadata": {},
@@ -775,7 +757,9 @@
775757
"source": [
776758
"## Test\n",
777759
"\n",
778-
"Now that the model is trained, run the test data through the trained model to get the predicted values."
760+
"Now that the model is trained, run the test data through the trained model to get the predicted values. This calls the ACI web service to do the prediction.\n",
761+
"\n",
762+
"Note that the JSON passed to the ACI web service is an array of rows of data. Each row should either be an array of values in the same order that was used for training or a dictionary where the keys are the same as the column names used for training. The example below uses dictionary rows."
779763
]
780764
},
781765
{
@@ -815,10 +799,27 @@
815799
"metadata": {},
816800
"outputs": [],
817801
"source": [
818-
"y_pred = fitted_model.predict(X_test)\n",
802+
"import json\n",
803+
"import requests\n",
804+
"\n",
805+
"X_test_json = X_test.to_json(orient='records')\n",
806+
"data = \"{\\\"data\\\": \" + X_test_json +\"}\"\n",
807+
"headers = {'Content-Type': 'application/json'}\n",
808+
"\n",
809+
"resp = requests.post(aci_service.scoring_uri, data, headers=headers)\n",
810+
"\n",
811+
"y_pred = json.loads(json.loads(resp.text))['result']"
812+
]
813+
},
814+
{
815+
"cell_type": "code",
816+
"execution_count": null,
817+
"metadata": {},
818+
"outputs": [],
819+
"source": [
819820
"actual = array(y_test)\n",
820821
"actual = actual[:,0]\n",
821-
"print(y_pred.shape, \" \", actual.shape)"
822+
"print(len(y_pred), \" \", len(actual))"
822823
]
823824
},
824825
{
@@ -827,8 +828,7 @@
827828
"source": [
828829
"### Calculate metrics for the prediction\n",
829830
"\n",
830-
"Now visualize the data on a scatter plot to show what our truth (actual) values are compared to the predicted values \n",
831-
"from the trained model that was returned."
831+
"Now visualize the data as a confusion matrix that compared the predicted values against the actual values.\n"
832832
]
833833
},
834834
{
@@ -838,12 +838,45 @@
838838
"outputs": [],
839839
"source": [
840840
"%matplotlib notebook\n",
841-
"test_pred = plt.scatter(actual, y_pred, color='b')\n",
842-
"test_test = plt.scatter(actual, actual, color='g')\n",
843-
"plt.legend((test_pred, test_test), ('prediction', 'truth'), loc='upper left', fontsize=8)\n",
841+
"from sklearn.metrics import confusion_matrix\n",
842+
"import numpy as np\n",
843+
"import itertools\n",
844+
"\n",
845+
"cf =confusion_matrix(actual,y_pred)\n",
846+
"plt.imshow(cf,cmap=plt.cm.Blues,interpolation='nearest')\n",
847+
"plt.colorbar()\n",
848+
"plt.title('Confusion Matrix')\n",
849+
"plt.xlabel('Predicted')\n",
850+
"plt.ylabel('Actual')\n",
851+
"class_labels = ['no','yes']\n",
852+
"tick_marks = np.arange(len(class_labels))\n",
853+
"plt.xticks(tick_marks,class_labels)\n",
854+
"plt.yticks([-0.5,0,1,1.5],['','no','yes',''])\n",
855+
"# plotting text value inside cells\n",
856+
"thresh = cf.max() / 2.\n",
857+
"for i,j in itertools.product(range(cf.shape[0]),range(cf.shape[1])):\n",
858+
" plt.text(j,i,format(cf[i,j],'d'),horizontalalignment='center',color='white' if cf[i,j] >thresh else 'black')\n",
844859
"plt.show()"
845860
]
846861
},
862+
{
863+
"cell_type": "markdown",
864+
"metadata": {},
865+
"source": [
866+
"### Delete a Web Service\n",
867+
"\n",
868+
"Deletes the specified web service."
869+
]
870+
},
871+
{
872+
"cell_type": "code",
873+
"execution_count": null,
874+
"metadata": {},
875+
"outputs": [],
876+
"source": [
877+
"aci_service.delete()"
878+
]
879+
},
847880
{
848881
"cell_type": "markdown",
849882
"metadata": {},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"metadata": {},
9494
"outputs": [],
9595
"source": [
96-
"print(\"This notebook was created using version 1.11.0 of the Azure ML SDK\")\n",
96+
"print(\"This notebook was created using version 1.12.0 of the Azure ML SDK\")\n",
9797
"print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")"
9898
]
9999
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"metadata": {},
9898
"outputs": [],
9999
"source": [
100-
"print(\"This notebook was created using version 1.11.0 of the Azure ML SDK\")\n",
100+
"print(\"This notebook was created using version 1.12.0 of the Azure ML SDK\")\n",
101101
"print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")"
102102
]
103103
},

how-to-use-azureml/automated-machine-learning/continuous-retraining/auto-ml-continuous-retraining.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"metadata": {},
8989
"outputs": [],
9090
"source": [
91-
"print(\"This notebook was created using version 1.11.0 of the Azure ML SDK\")\n",
91+
"print(\"This notebook was created using version 1.12.0 of the Azure ML SDK\")\n",
9292
"print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")"
9393
]
9494
},
@@ -204,7 +204,6 @@
204204
"cd = CondaDependencies.create(pip_packages=['azureml-sdk[automl]', 'applicationinsights', 'azureml-opendatasets', 'azureml-defaults'], \n",
205205
" conda_packages=['numpy==1.16.2'], \n",
206206
" pin_sdk_version=False)\n",
207-
"#cd.add_pip_package('azureml-explain-model')\n",
208207
"conda_run_config.environment.python.conda_dependencies = cd\n",
209208
"\n",
210209
"print('run config is ready')"

how-to-use-azureml/automated-machine-learning/forecasting-beer-remote/auto-ml-forecasting-beer-remote.ipynb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"metadata": {},
115115
"outputs": [],
116116
"source": [
117-
"print(\"This notebook was created using version 1.11.0 of the Azure ML SDK\")\n",
117+
"print(\"This notebook was created using version 1.12.0 of the Azure ML SDK\")\n",
118118
"print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")"
119119
]
120120
},
@@ -217,7 +217,7 @@
217217
"\n",
218218
"**Time column** is the time axis along which to predict.\n",
219219
"\n",
220-
"**Grain** is another word for an individual time series in your dataset. Grains are identified by values of the columns listed `grain_column_names`, for example \"store\" and \"item\" if your data has multiple time series of sales, one series for each combination of store and item sold.\n",
220+
"**Time series identifier columns** are identified by values of the columns listed `time_series_id_column_names`, for example \"store\" and \"item\" if your data has multiple time series of sales, one series for each combination of store and item sold.\n",
221221
"\n",
222222
"This dataset has only one time series. Please see the [orange juice notebook](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/automated-machine-learning/forecasting-orange-juice-sales) for an example of a multi-time series dataset."
223223
]
@@ -269,7 +269,7 @@
269269
"source": [
270270
"target_column_name = 'BeerProduction'\n",
271271
"time_column_name = 'DATE'\n",
272-
"grain_column_names = []\n",
272+
"time_series_id_column_names = []\n",
273273
"freq = 'M' #Monthly data"
274274
]
275275
},
@@ -329,7 +329,7 @@
329329
},
330330
"outputs": [],
331331
"source": [
332-
"max_horizon = 12"
332+
"forecast_horizon = 12"
333333
]
334334
},
335335
{
@@ -364,11 +364,10 @@
364364
},
365365
"outputs": [],
366366
"source": [
367-
"automl_settings = {\n",
368-
" 'time_column_name': time_column_name,\n",
369-
" 'max_horizon': max_horizon,\n",
370-
" 'enable_dnn' : True,\n",
371-
"}\n",
367+
"from azureml.automl.core.forecasting_parameters import ForecastingParameters\n",
368+
"forecasting_parameters = ForecastingParameters(\n",
369+
" time_column_name=time_column_name, forecast_horizon=forecast_horizon\n",
370+
")\n",
372371
"\n",
373372
"automl_config = AutoMLConfig(task='forecasting', \n",
374373
" primary_metric='normalized_root_mean_squared_error',\n",
@@ -380,7 +379,8 @@
380379
" compute_target=compute_target,\n",
381380
" max_concurrent_iterations=4,\n",
382381
" max_cores_per_iteration=-1,\n",
383-
" **automl_settings)"
382+
" enable_dnn=True,\n",
383+
" forecasting_parameters=forecasting_parameters)"
384384
]
385385
},
386386
{
@@ -581,7 +581,7 @@
581581
"source": [
582582
"from helper import run_inference\n",
583583
"\n",
584-
"test_run = run_inference(test_experiment, compute_target, script_folder, best_dnn_run, test_dataset, valid_dataset, max_horizon,\n",
584+
"test_run = run_inference(test_experiment, compute_target, script_folder, best_dnn_run, test_dataset, valid_dataset, forecast_horizon,\n",
585585
" target_column_name, time_column_name, freq)"
586586
]
587587
},
@@ -603,7 +603,7 @@
603603
"from helper import run_multiple_inferences\n",
604604
"\n",
605605
"summary_df = run_multiple_inferences(summary_df, experiment, test_experiment, compute_target, script_folder, test_dataset, \n",
606-
" valid_dataset, max_horizon, target_column_name, time_column_name, freq)"
606+
" valid_dataset, forecast_horizon, target_column_name, time_column_name, freq)"
607607
]
608608
},
609609
{

0 commit comments

Comments
 (0)