Skip to content

Commit 3a1824e

Browse files
committed
update samples from Release-170 as a part of 1.51 SDK stable release
1 parent 5796433 commit 3a1824e

File tree

46 files changed

+1682
-1395
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

+1682
-1395
lines changed

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# Azure Machine Learning Python SDK notebooks
22

3-
### **With the introduction of AzureML SDK v2, this samples repository for the v1 SDK is now deprecated and will not be monitored or updated. Users are encouraged to visit the [v2 SDK samples repository](https://github.com/Azure/azureml-examples) instead for up-to-date and enhanced examples of how to build, train, and deploy machine learning models with AzureML's newest features.**
4-
5-
-------------------------
6-
Welcome to the Azure Machine Learning Python SDK notebooks repository!
7-
8-
93
> a community-driven repository of examples using mlflow for tracking can be found at https://github.com/Azure/azureml-examples
104
5+
Welcome to the Azure Machine Learning Python SDK notebooks repository!
116

127
## Getting started
138

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.50.0 of the Azure ML SDK\")\n",
106+
"print(\"This notebook was created using version 1.51 of the Azure ML SDK\")\n",
107107
"print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")"
108108
]
109109
},

contrib/fairness/fairlearn-azureml-mitigation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66
- fairlearn>=0.6.2
77
- joblib
88
- liac-arff
9-
- raiwidgets~=0.26.0
9+
- raiwidgets~=0.27.0
1010
- itsdangerous==2.0.1
1111
- markupsafe<2.1.0
1212
- protobuf==3.20.0

contrib/fairness/upload-fairness-dashboard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66
- fairlearn>=0.6.2
77
- joblib
88
- liac-arff
9-
- raiwidgets~=0.26.0
9+
- raiwidgets~=0.27.0
1010
- itsdangerous==2.0.1
1111
- markupsafe<2.1.0
1212
- protobuf==3.20.0

how-to-use-azureml/automated-machine-learning/automl_env.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ dependencies:
1212
- pandas==1.1.5
1313
- scipy==1.5.3
1414
- Cython==0.29.14
15-
- tqdm==4.64.1
15+
- tqdm==4.65.0
1616

1717
- pip:
1818
# Required packages for AzureML execution, history, and data preparation.
19-
- azureml-widgets~=1.50.0
20-
- azureml-defaults~=1.50.0
21-
- -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.50.0/validated_win32_requirements.txt [--no-deps]
19+
- azureml-widgets~=1.51
20+
- azureml-defaults~=1.51
21+
- -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.51/validated_win32_requirements.txt [--no-deps]
2222
- matplotlib==3.6.2
2323
- xgboost==1.3.3
2424
- cmdstanpy==0.9.5

how-to-use-azureml/automated-machine-learning/automl_env_linux.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ dependencies:
2323

2424
- pip:
2525
# Required packages for AzureML execution, history, and data preparation.
26-
- azureml-widgets~=1.50.0
27-
- azureml-defaults~=1.50.0
26+
- azureml-widgets~=1.51
27+
- azureml-defaults~=1.51
2828
- pytorch-transformers==1.0.0
2929
- spacy==2.2.4
3030
- pystan==2.19.1.1
3131
- https://aka.ms/automl-resources/packages/en_core_web_sm-2.1.0.tar.gz
32-
- -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.50.0/validated_linux_requirements.txt [--no-deps]
32+
- -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.51/validated_linux_requirements.txt [--no-deps]

how-to-use-azureml/automated-machine-learning/automl_env_mac.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ dependencies:
1616
- scikit-learn==0.22.1
1717
- py-xgboost<=1.3.3
1818
- holidays==0.10.3
19-
- conda-forge::fbprophet==0.7.1
2019
- pytorch::pytorch=1.11.0
2120
- cudatoolkit=9.0
2221
- notebook
2322

2423
- pip:
2524
# Required packages for AzureML execution, history, and data preparation.
26-
- azureml-widgets~=1.50.0
27-
- azureml-defaults~=1.50.0
25+
- azureml-widgets~=1.51
26+
- azureml-defaults~=1.51
2827
- pytorch-transformers==1.0.0
2928
- spacy==2.2.4
3029
- pystan==2.19.1.1
30+
- fbprophet==0.7.1
3131
- https://aka.ms/automl-resources/packages/en_core_web_sm-2.1.0.tar.gz
32-
- -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.50.0/validated_darwin_requirements.txt [--no-deps]
32+
- -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.51/validated_darwin_requirements.txt [--no-deps]

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,9 @@
712712
"from azureml.core.model import Model\n",
713713
"from azureml.core.environment import Environment\n",
714714
"\n",
715-
"inference_config = InferenceConfig(entry_script=script_file_name)\n",
715+
"inference_config = InferenceConfig(\n",
716+
" environment=best_run.get_environment(), entry_script=script_file_name\n",
717+
")\n",
716718
"\n",
717719
"aciconfig = AciWebservice.deploy_configuration(\n",
718720
" cpu_cores=2,\n",

how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-codegen/codegen-for-autofeaturization.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.50.0 of the Azure ML SDK\")\n",
100+
"print(\"This notebook was created using version 1.51 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/experimental/autofeaturization-custom-model-training/custom-model-training-from-autofeaturization-run.ipynb

Lines changed: 40 additions & 46 deletions
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.50.0 of the Azure ML SDK\")\n",
100+
"print(\"This notebook was created using version 1.51 of the Azure ML SDK\")\n",
101101
"print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")"
102102
]
103103
},
@@ -454,10 +454,13 @@
454454
]
455455
},
456456
{
457+
"attachments": {},
457458
"cell_type": "markdown",
458459
"metadata": {},
459460
"source": [
460-
"**Note:** Not all datasets produce a y_transformer. The dataset used in the current notebook requires a transformer as the y column data is categorical."
461+
"**Note:** Not all datasets produce a y_transformer. The dataset used in the current notebook requires a transformer as the y column data is categorical. \n",
462+
"\n",
463+
"We will go ahead and download the mlflow transformer model and use it to transform test data that can be used for further experimentation below. To run the commented code, make sure the environment requirement is satisfied. You can go ahead and create the environment from the `conda.yaml` file under `/outputs/featurization/pipeline/` and run the given code in it."
461464
]
462465
},
463466
{
@@ -466,22 +469,23 @@
466469
"metadata": {},
467470
"outputs": [],
468471
"source": [
469-
"from azureml.automl.core.shared.constants import Transformers\n",
472+
"''' from azureml.automl.core.shared.constants import Transformers\n",
470473
"\n",
471474
"transformers = mlflow.sklearn.load_model(uri) # Using method 1\n",
472475
"data_transformers = transformers.get_transformers()\n",
473476
"x_transformer = data_transformers[Transformers.X_TRANSFORMER]\n",
474477
"y_transformer = data_transformers[Transformers.Y_TRANSFORMER]\n",
475478
"\n",
476479
"X_test = x_transformer.transform(X_test_data)\n",
477-
"y_test = y_transformer.transform(y_test_data)"
480+
"y_test = y_transformer.transform(y_test_data) '''"
478481
]
479482
},
480483
{
484+
"attachments": {},
481485
"cell_type": "markdown",
482486
"metadata": {},
483487
"source": [
484-
"Run the following cell to see the featurization summary of X and y transformers. "
488+
"Run the following cell to see the featurization summary of X and y transformers. Uncomment to use. "
485489
]
486490
},
487491
{
@@ -490,10 +494,10 @@
490494
"metadata": {},
491495
"outputs": [],
492496
"source": [
493-
"X_data_summary = x_transformer.get_featurization_summary(is_user_friendly=False)\n",
497+
"''' X_data_summary = x_transformer.get_featurization_summary(is_user_friendly=False)\n",
494498
"\n",
495499
"summary_df = pd.DataFrame.from_records(X_data_summary)\n",
496-
"summary_df"
500+
"summary_df '''"
497501
]
498502
},
499503
{
@@ -544,10 +548,11 @@
544548
]
545549
},
546550
{
551+
"attachments": {},
547552
"cell_type": "markdown",
548553
"metadata": {},
549554
"source": [
550-
"Another way to load the data is to go to the above autofeaturization experiment and check for the featurized dataset ids under `Output datasets`. Uncomment and replace them accordingly below to use."
555+
"Another way to load the data is to go to the above autofeaturization experiment and check for the featurized dataset ids under `Output datasets`. Uncomment and replace them accordingly below, to use."
551556
]
552557
},
553558
{
@@ -597,10 +602,20 @@
597602
]
598603
},
599604
{
605+
"attachments": {},
600606
"cell_type": "markdown",
601607
"metadata": {},
602608
"source": [
603-
"Here we are passing our training data to the lightgbm classifier, any custom model can be used with your data."
609+
"Here we are passing our training data to the lightgbm classifier, any custom model can be used with your data. Let us first install lightgbm."
610+
]
611+
},
612+
{
613+
"cell_type": "code",
614+
"execution_count": null,
615+
"metadata": {},
616+
"outputs": [],
617+
"source": [
618+
"! pip install lightgbm"
604619
]
605620
},
606621
{
@@ -612,21 +627,15 @@
612627
"import lightgbm as lgb\n",
613628
"\n",
614629
"model = lgb.LGBMClassifier(learning_rate=0.08,max_depth=-5,random_state=42)\n",
615-
"model.fit(X_train, y_train, sample_weight=sample_weight, eval_set=[(X_test, y_test),(X_train, y_train)],\n",
616-
" verbose=20,eval_metric='logloss')\n",
617-
"\n",
618-
"print('Training accuracy {:.4f}'.format(model.score(X_train, y_train)))\n",
619-
"print('Testing accuracy {:.4f}'.format(model.score(X_test, y_test)))"
630+
"model.fit(X_train, y_train, sample_weight=sample_weight)"
620631
]
621632
},
622633
{
634+
"attachments": {},
623635
"cell_type": "markdown",
624636
"metadata": {},
625637
"source": [
626-
"<a id='Results'></a>\n",
627-
"## Analyze results\n",
628-
"\n",
629-
"### Retrieve the Model"
638+
"Once training is done, the test data obtained after transforming from the above downloaded transformer can be used to calculate the accuracy "
630639
]
631640
},
632641
{
@@ -635,17 +644,20 @@
635644
"metadata": {},
636645
"outputs": [],
637646
"source": [
638-
"model"
647+
"print('Training accuracy {:.4f}'.format(model.score(X_train, y_train)))\n",
648+
"\n",
649+
"# Uncomment below to test the model on test data \n",
650+
"# print('Testing accuracy {:.4f}'.format(model.score(X_test, y_test)))"
639651
]
640652
},
641653
{
642654
"cell_type": "markdown",
643655
"metadata": {},
644656
"source": [
645-
"<a id='Test'></a>\n",
646-
"## Test the fitted model\n",
657+
"<a id='Results'></a>\n",
658+
"## Analyze results\n",
647659
"\n",
648-
"Now that the model is trained, split the data in the same way the data was split for training (The difference here is the data is being split locally) and then run the test data through the trained model to get the predicted values."
660+
"### Retrieve the Model"
649661
]
650662
},
651663
{
@@ -654,17 +666,17 @@
654666
"metadata": {},
655667
"outputs": [],
656668
"source": [
657-
"y_pred = model.predict(X_test)"
669+
"model"
658670
]
659671
},
660672
{
661673
"cell_type": "markdown",
662674
"metadata": {},
663675
"source": [
664-
"### Calculate metrics for the prediction\n",
676+
"<a id='Test'></a>\n",
677+
"## Test the fitted model\n",
665678
"\n",
666-
"Now visualize the data on a scatter plot to show what our truth (actual) values are compared to the predicted values \n",
667-
"from the trained model that was returned."
679+
"Now that the model is trained, split the data in the same way the data was split for training (The difference here is the data is being split locally) and then run the test data through the trained model to get the predicted values."
668680
]
669681
},
670682
{
@@ -673,26 +685,8 @@
673685
"metadata": {},
674686
"outputs": [],
675687
"source": [
676-
"from sklearn.metrics import confusion_matrix\n",
677-
"from matplotlib import pyplot as plt\n",
678-
"import numpy as np\n",
679-
"import itertools\n",
680-
"\n",
681-
"cf =confusion_matrix(y_test,y_pred)\n",
682-
"plt.imshow(cf,cmap=plt.cm.Blues,interpolation='nearest')\n",
683-
"plt.colorbar()\n",
684-
"plt.title('Confusion Matrix')\n",
685-
"plt.xlabel('Predicted')\n",
686-
"plt.ylabel('Actual')\n",
687-
"class_labels = ['False','True']\n",
688-
"tick_marks = np.arange(len(class_labels))\n",
689-
"plt.xticks(tick_marks,class_labels)\n",
690-
"plt.yticks([-0.5,0,1,1.5],['','False','True',''])\n",
691-
"# plotting text value inside cells\n",
692-
"thresh = cf.max() / 2.\n",
693-
"for i,j in itertools.product(range(cf.shape[0]),range(cf.shape[1])):\n",
694-
" plt.text(j,i,format(cf[i,j],'d'),horizontalalignment='center',color='white' if cf[i,j] >thresh else 'black')\n",
695-
"plt.show()"
688+
"# Uncomment below to test the model on test data\n",
689+
"# y_pred = model.predict(X_test)"
696690
]
697691
},
698692
{

0 commit comments

Comments
 (0)