diff --git a/README.md b/README.md index da5307d5d..d9ebd8206 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,8 @@ # Azure Machine Learning Python SDK notebooks -### **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.** - -------------------------- -Welcome to the Azure Machine Learning Python SDK notebooks repository! - - > a community-driven repository of examples using mlflow for tracking can be found at https://github.com/Azure/azureml-examples +Welcome to the Azure Machine Learning Python SDK notebooks repository! ## Getting started diff --git a/configuration.ipynb b/configuration.ipynb index 330981b48..69f08f427 100644 --- a/configuration.ipynb +++ b/configuration.ipynb @@ -103,7 +103,7 @@ "source": [ "import azureml.core\n", "\n", - "print(\"This notebook was created using version 1.50.0 of the Azure ML SDK\")\n", + "print(\"This notebook was created using version 1.51 of the Azure ML SDK\")\n", "print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")" ] }, diff --git a/contrib/fairness/fairlearn-azureml-mitigation.yml b/contrib/fairness/fairlearn-azureml-mitigation.yml index 94449e1a2..743049004 100644 --- a/contrib/fairness/fairlearn-azureml-mitigation.yml +++ b/contrib/fairness/fairlearn-azureml-mitigation.yml @@ -6,7 +6,7 @@ dependencies: - fairlearn>=0.6.2 - joblib - liac-arff - - raiwidgets~=0.26.0 + - raiwidgets~=0.27.0 - itsdangerous==2.0.1 - markupsafe<2.1.0 - protobuf==3.20.0 diff --git a/contrib/fairness/upload-fairness-dashboard.yml b/contrib/fairness/upload-fairness-dashboard.yml index 9cae9e8cc..3858f8705 100644 --- a/contrib/fairness/upload-fairness-dashboard.yml +++ b/contrib/fairness/upload-fairness-dashboard.yml @@ -6,7 +6,7 @@ dependencies: - fairlearn>=0.6.2 - joblib - liac-arff - - raiwidgets~=0.26.0 + - raiwidgets~=0.27.0 - itsdangerous==2.0.1 - markupsafe<2.1.0 - protobuf==3.20.0 diff --git a/how-to-use-azureml/automated-machine-learning/automl_env.yml b/how-to-use-azureml/automated-machine-learning/automl_env.yml index 6a45bb9f8..871c1c6b8 100644 --- a/how-to-use-azureml/automated-machine-learning/automl_env.yml +++ b/how-to-use-azureml/automated-machine-learning/automl_env.yml @@ -12,13 +12,13 @@ dependencies: - pandas==1.1.5 - scipy==1.5.3 - Cython==0.29.14 -- tqdm==4.64.1 +- tqdm==4.65.0 - pip: # Required packages for AzureML execution, history, and data preparation. - - azureml-widgets~=1.50.0 - - azureml-defaults~=1.50.0 - - -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.50.0/validated_win32_requirements.txt [--no-deps] + - azureml-widgets~=1.51 + - azureml-defaults~=1.51 + - -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.51/validated_win32_requirements.txt [--no-deps] - matplotlib==3.6.2 - xgboost==1.3.3 - cmdstanpy==0.9.5 diff --git a/how-to-use-azureml/automated-machine-learning/automl_env_linux.yml b/how-to-use-azureml/automated-machine-learning/automl_env_linux.yml index d74d8ae83..ee459befd 100644 --- a/how-to-use-azureml/automated-machine-learning/automl_env_linux.yml +++ b/how-to-use-azureml/automated-machine-learning/automl_env_linux.yml @@ -23,10 +23,10 @@ dependencies: - pip: # Required packages for AzureML execution, history, and data preparation. - - azureml-widgets~=1.50.0 - - azureml-defaults~=1.50.0 + - azureml-widgets~=1.51 + - azureml-defaults~=1.51 - pytorch-transformers==1.0.0 - spacy==2.2.4 - pystan==2.19.1.1 - https://aka.ms/automl-resources/packages/en_core_web_sm-2.1.0.tar.gz - - -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.50.0/validated_linux_requirements.txt [--no-deps] + - -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.51/validated_linux_requirements.txt [--no-deps] diff --git a/how-to-use-azureml/automated-machine-learning/automl_env_mac.yml b/how-to-use-azureml/automated-machine-learning/automl_env_mac.yml index f46123b60..b9a6b5e35 100644 --- a/how-to-use-azureml/automated-machine-learning/automl_env_mac.yml +++ b/how-to-use-azureml/automated-machine-learning/automl_env_mac.yml @@ -16,17 +16,17 @@ dependencies: - scikit-learn==0.22.1 - py-xgboost<=1.3.3 - holidays==0.10.3 -- conda-forge::fbprophet==0.7.1 - pytorch::pytorch=1.11.0 - cudatoolkit=9.0 - notebook - pip: # Required packages for AzureML execution, history, and data preparation. - - azureml-widgets~=1.50.0 - - azureml-defaults~=1.50.0 + - azureml-widgets~=1.51 + - azureml-defaults~=1.51 - pytorch-transformers==1.0.0 - spacy==2.2.4 - pystan==2.19.1.1 + - fbprophet==0.7.1 - https://aka.ms/automl-resources/packages/en_core_web_sm-2.1.0.tar.gz - - -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.50.0/validated_darwin_requirements.txt [--no-deps] + - -r https://automlsdkdataresources.blob.core.windows.net/validated-requirements/1.51/validated_darwin_requirements.txt [--no-deps] diff --git a/how-to-use-azureml/automated-machine-learning/classification-bank-marketing-all-features/auto-ml-classification-bank-marketing-all-features.ipynb b/how-to-use-azureml/automated-machine-learning/classification-bank-marketing-all-features/auto-ml-classification-bank-marketing-all-features.ipynb index aafcdf528..33ea3b14a 100644 --- a/how-to-use-azureml/automated-machine-learning/classification-bank-marketing-all-features/auto-ml-classification-bank-marketing-all-features.ipynb +++ b/how-to-use-azureml/automated-machine-learning/classification-bank-marketing-all-features/auto-ml-classification-bank-marketing-all-features.ipynb @@ -712,7 +712,9 @@ "from azureml.core.model import Model\n", "from azureml.core.environment import Environment\n", "\n", - "inference_config = InferenceConfig(entry_script=script_file_name)\n", + "inference_config = InferenceConfig(\n", + " environment=best_run.get_environment(), entry_script=script_file_name\n", + ")\n", "\n", "aciconfig = AciWebservice.deploy_configuration(\n", " cpu_cores=2,\n", diff --git a/how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-codegen/codegen-for-autofeaturization.ipynb b/how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-codegen/codegen-for-autofeaturization.ipynb index d1de6f24c..391a26616 100644 --- a/how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-codegen/codegen-for-autofeaturization.ipynb +++ b/how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-codegen/codegen-for-autofeaturization.ipynb @@ -97,7 +97,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(\"This notebook was created using version 1.50.0 of the Azure ML SDK\")\n", + "print(\"This notebook was created using version 1.51 of the Azure ML SDK\")\n", "print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")" ] }, diff --git a/how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-custom-model-training/custom-model-training-from-autofeaturization-run.ipynb b/how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-custom-model-training/custom-model-training-from-autofeaturization-run.ipynb index 78a852b86..4ab4dfa4e 100644 --- a/how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-custom-model-training/custom-model-training-from-autofeaturization-run.ipynb +++ b/how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-custom-model-training/custom-model-training-from-autofeaturization-run.ipynb @@ -97,7 +97,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(\"This notebook was created using version 1.50.0 of the Azure ML SDK\")\n", + "print(\"This notebook was created using version 1.51 of the Azure ML SDK\")\n", "print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")" ] }, @@ -454,10 +454,13 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "**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." + "**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", + "\n", + "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." ] }, { @@ -466,7 +469,7 @@ "metadata": {}, "outputs": [], "source": [ - "from azureml.automl.core.shared.constants import Transformers\n", + "''' from azureml.automl.core.shared.constants import Transformers\n", "\n", "transformers = mlflow.sklearn.load_model(uri) # Using method 1\n", "data_transformers = transformers.get_transformers()\n", @@ -474,14 +477,15 @@ "y_transformer = data_transformers[Transformers.Y_TRANSFORMER]\n", "\n", "X_test = x_transformer.transform(X_test_data)\n", - "y_test = y_transformer.transform(y_test_data)" + "y_test = y_transformer.transform(y_test_data) '''" ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "Run the following cell to see the featurization summary of X and y transformers. " + "Run the following cell to see the featurization summary of X and y transformers. Uncomment to use. " ] }, { @@ -490,10 +494,10 @@ "metadata": {}, "outputs": [], "source": [ - "X_data_summary = x_transformer.get_featurization_summary(is_user_friendly=False)\n", + "''' X_data_summary = x_transformer.get_featurization_summary(is_user_friendly=False)\n", "\n", "summary_df = pd.DataFrame.from_records(X_data_summary)\n", - "summary_df" + "summary_df '''" ] }, { @@ -544,10 +548,11 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "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." + "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." ] }, { @@ -597,10 +602,20 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "Here we are passing our training data to the lightgbm classifier, any custom model can be used with your data." + "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." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "! pip install lightgbm" ] }, { @@ -612,21 +627,15 @@ "import lightgbm as lgb\n", "\n", "model = lgb.LGBMClassifier(learning_rate=0.08,max_depth=-5,random_state=42)\n", - "model.fit(X_train, y_train, sample_weight=sample_weight, eval_set=[(X_test, y_test),(X_train, y_train)],\n", - " verbose=20,eval_metric='logloss')\n", - "\n", - "print('Training accuracy {:.4f}'.format(model.score(X_train, y_train)))\n", - "print('Testing accuracy {:.4f}'.format(model.score(X_test, y_test)))" + "model.fit(X_train, y_train, sample_weight=sample_weight)" ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "\n", - "## Analyze results\n", - "\n", - "### Retrieve the Model" + "Once training is done, the test data obtained after transforming from the above downloaded transformer can be used to calculate the accuracy " ] }, { @@ -635,17 +644,20 @@ "metadata": {}, "outputs": [], "source": [ - "model" + "print('Training accuracy {:.4f}'.format(model.score(X_train, y_train)))\n", + "\n", + "# Uncomment below to test the model on test data \n", + "# print('Testing accuracy {:.4f}'.format(model.score(X_test, y_test)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "\n", - "## Test the fitted model\n", + "\n", + "## Analyze results\n", "\n", - "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." + "### Retrieve the Model" ] }, { @@ -654,17 +666,17 @@ "metadata": {}, "outputs": [], "source": [ - "y_pred = model.predict(X_test)" + "model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Calculate metrics for the prediction\n", + "\n", + "## Test the fitted model\n", "\n", - "Now visualize the data on a scatter plot to show what our truth (actual) values are compared to the predicted values \n", - "from the trained model that was returned." + "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." ] }, { @@ -673,26 +685,8 @@ "metadata": {}, "outputs": [], "source": [ - "from sklearn.metrics import confusion_matrix\n", - "from matplotlib import pyplot as plt\n", - "import numpy as np\n", - "import itertools\n", - "\n", - "cf =confusion_matrix(y_test,y_pred)\n", - "plt.imshow(cf,cmap=plt.cm.Blues,interpolation='nearest')\n", - "plt.colorbar()\n", - "plt.title('Confusion Matrix')\n", - "plt.xlabel('Predicted')\n", - "plt.ylabel('Actual')\n", - "class_labels = ['False','True']\n", - "tick_marks = np.arange(len(class_labels))\n", - "plt.xticks(tick_marks,class_labels)\n", - "plt.yticks([-0.5,0,1,1.5],['','False','True',''])\n", - "# plotting text value inside cells\n", - "thresh = cf.max() / 2.\n", - "for i,j in itertools.product(range(cf.shape[0]),range(cf.shape[1])):\n", - " plt.text(j,i,format(cf[i,j],'d'),horizontalalignment='center',color='white' if cf[i,j] >thresh else 'black')\n", - "plt.show()" + "# Uncomment below to test the model on test data\n", + "# y_pred = model.predict(X_test)" ] }, { diff --git a/how-to-use-azureml/automated-machine-learning/experimental/automl_thin_client_env.yml b/how-to-use-azureml/automated-machine-learning/experimental/automl_thin_client_env.yml index 76acd2b57..1cc5549a4 100644 --- a/how-to-use-azureml/automated-machine-learning/experimental/automl_thin_client_env.yml +++ b/how-to-use-azureml/automated-machine-learning/experimental/automl_thin_client_env.yml @@ -1,9 +1,21 @@ name: azure_automl_experimental dependencies: # The python interpreter version. +<<<<<<< HEAD + # Currently Azure ML only supports 3.6.0 and later. +- pip<=20.2.4 +- python>=3.6.0,<3.10 +- cython==0.29.14 +- urllib3==1.26.7 +- PyJWT < 2.0.0 +- numpy==1.22.3 +- pywin32==227 +- cryptography<37.0.0 +======= # Currently Azure ML only supports 3.7.0 and later. - pip<=22.3.1 - python>=3.7.0,<3.11 +>>>>>>> 4671acd451ce979c3cebcd3917804861a333b710 - pip: # Required packages for AzureML execution, history, and data preparation. @@ -13,3 +25,4 @@ dependencies: - azureml-mlflow - pandas - mlflow + - docker<6.0.0 diff --git a/how-to-use-azureml/automated-machine-learning/experimental/classification-credit-card-fraud-local-managed/auto-ml-classification-credit-card-fraud-local-managed.ipynb b/how-to-use-azureml/automated-machine-learning/experimental/classification-credit-card-fraud-local-managed/auto-ml-classification-credit-card-fraud-local-managed.ipynb index 9a8666c0b..1d69c9e73 100644 --- a/how-to-use-azureml/automated-machine-learning/experimental/classification-credit-card-fraud-local-managed/auto-ml-classification-credit-card-fraud-local-managed.ipynb +++ b/how-to-use-azureml/automated-machine-learning/experimental/classification-credit-card-fraud-local-managed/auto-ml-classification-credit-card-fraud-local-managed.ipynb @@ -92,7 +92,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(\"This notebook was created using version 1.50.0 of the Azure ML SDK\")\n", + "print(\"This notebook was created using version 1.51 of the Azure ML SDK\")\n", "print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")" ] }, diff --git a/how-to-use-azureml/automated-machine-learning/experimental/regression-model-proxy/auto-ml-regression-model-proxy.ipynb b/how-to-use-azureml/automated-machine-learning/experimental/regression-model-proxy/auto-ml-regression-model-proxy.ipynb index 580cf3751..0be61d52c 100644 --- a/how-to-use-azureml/automated-machine-learning/experimental/regression-model-proxy/auto-ml-regression-model-proxy.ipynb +++ b/how-to-use-azureml/automated-machine-learning/experimental/regression-model-proxy/auto-ml-regression-model-proxy.ipynb @@ -91,7 +91,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(\"This notebook was created using version 1.50.0 of the Azure ML SDK\")\n", + "print(\"This notebook was created using version 1.51 of the Azure ML SDK\")\n", "print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")" ] }, diff --git a/how-to-use-azureml/automated-machine-learning/forecasting-bike-share/auto-ml-forecasting-bike-share.ipynb b/how-to-use-azureml/automated-machine-learning/forecasting-bike-share/auto-ml-forecasting-bike-share.ipynb index dd8a29777..02476bd83 100644 --- a/how-to-use-azureml/automated-machine-learning/forecasting-bike-share/auto-ml-forecasting-bike-share.ipynb +++ b/how-to-use-azureml/automated-machine-learning/forecasting-bike-share/auto-ml-forecasting-bike-share.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -10,6 +11,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -17,6 +19,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -34,6 +37,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -52,6 +56,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -61,7 +66,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1680248038565 + } + }, "outputs": [], "source": [ "import json\n", @@ -77,6 +86,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -93,6 +103,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -126,6 +137,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -165,30 +177,12 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Data\n", "\n", - "The [Machine Learning service workspace](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-workspace) is paired with the storage account, which contains the default data store. We will use it to upload the bike share data and create [tabular dataset](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.data.tabulardataset?view=azure-ml-py) for training. A tabular dataset defines a series of lazily-evaluated, immutable operations to load data from the data source into tabular representation." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "datastore = ws.get_default_datastore()\n", - "datastore.upload_files(\n", - " files=[\"./bike-no.csv\"], target_path=\"dataset/\", overwrite=True, show_progress=True\n", - ")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ "Let's set up what we know about the dataset. \n", "\n", "**Target column** is what we want to forecast.\n", @@ -206,25 +200,52 @@ "time_column_name = \"date\"" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": { + "nteract": { + "transient": { + "deleting": false + } + } + }, + "source": [ + "You are now ready to load the historical bike share data. We will load the CSV file into a plain pandas DataFrame." + ] + }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "outputs_hidden": false, + "source_hidden": false + }, + "nteract": { + "transient": { + "deleting": false + } + } + }, "outputs": [], "source": [ - "dataset = Dataset.Tabular.from_delimited_files(\n", - " path=[(datastore, \"dataset/bike-no.csv\")]\n", - ").with_timestamp_columns(fine_grain_timestamp=time_column_name)\n", + "all_data = pd.read_csv(\"bike-no.csv\", parse_dates=[time_column_name])\n", "\n", "# Drop the columns 'casual' and 'registered' as these columns are a breakdown of the total and therefore a leak.\n", - "dataset = dataset.drop_columns(columns=[\"casual\", \"registered\"])\n", - "\n", - "dataset.take(5).to_pandas_dataframe().reset_index(drop=True)" + "all_data.drop([\"casual\", \"registered\"], axis=1, inplace=True)" ] }, { + "attachments": {}, "cell_type": "markdown", - "metadata": {}, + "metadata": { + "nteract": { + "transient": { + "deleting": false + } + } + }, "source": [ "### Split the data\n", "\n", @@ -234,25 +255,68 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1680247376789 + }, + "jupyter": { + "outputs_hidden": false, + "source_hidden": false + }, + "nteract": { + "transient": { + "deleting": false + } + } + }, "outputs": [], "source": [ "# select data that occurs before a specified date\n", - "train = dataset.time_before(datetime(2012, 8, 31), include_boundary=True)\n", - "train.to_pandas_dataframe().tail(5).reset_index(drop=True)" + "train = all_data[all_data[time_column_name] <= pd.Timestamp(\"2012-08-31\")].copy()\n", + "test = all_data[all_data[time_column_name] >= pd.Timestamp(\"2012-09-01\")].copy()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Upload data to datastore\n", + "\n", + "The [Machine Learning service workspace](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-workspace) is paired with the storage account, which contains the default data store. We will use it to upload the bike share data and create [tabular dataset](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.data.tabulardataset?view=azure-ml-py) for training. A tabular dataset defines a series of lazily-evaluated, immutable operations to load data from the data source into tabular representation." ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "outputs_hidden": false, + "source_hidden": false + }, + "nteract": { + "transient": { + "deleting": false + } + } + }, "outputs": [], "source": [ - "test = dataset.time_after(datetime(2012, 9, 1), include_boundary=True)\n", - "test.to_pandas_dataframe().head(5).reset_index(drop=True)" + "from azureml.data.dataset_factory import TabularDatasetFactory\n", + "\n", + "datastore = ws.get_default_datastore()\n", + "\n", + "train_dataset = TabularDatasetFactory.register_pandas_dataframe(\n", + " train, target=(datastore, \"dataset/\"), name=\"bike_no_train\"\n", + ")\n", + "\n", + "test_dataset = TabularDatasetFactory.register_pandas_dataframe(\n", + " test, target=(datastore, \"dataset/\"), name=\"bike_no_test\"\n", + ")" ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -270,6 +334,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -294,6 +359,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -312,6 +378,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -331,6 +398,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -360,7 +428,7 @@ " featurization=featurization_config,\n", " blocked_models=[\"ExtremeRandomTrees\"],\n", " experiment_timeout_hours=0.3,\n", - " training_data=train,\n", + " training_data=train_dataset,\n", " label_column_name=target_column_name,\n", " compute_target=compute_target,\n", " enable_early_stopping=True,\n", @@ -373,6 +441,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -398,6 +467,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -416,6 +486,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -441,6 +512,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -484,6 +556,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -491,6 +564,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -509,6 +583,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -531,6 +606,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -546,7 +622,7 @@ "from run_forecast import run_rolling_forecast\n", "\n", "remote_run = run_rolling_forecast(\n", - " test_experiment, compute_target, best_run, test, target_column_name\n", + " test_experiment, compute_target, best_run, test_dataset, target_column_name\n", ")\n", "remote_run" ] @@ -561,6 +637,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -579,6 +656,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -595,6 +673,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -626,6 +705,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -635,6 +715,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -666,6 +747,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -722,6 +804,9 @@ ], "friendly_name": "Forecasting BikeShare Demand", "index_order": 1, + "kernel_info": { + "name": "python38-azureml" + }, "kernelspec": { "display_name": "Python 3.8 - AzureML", "language": "python", @@ -737,11 +822,19 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.13" + "version": "3.10.9" + }, + "microsoft": { + "ms_spell_check": { + "ms_spell_check_language": "en" + } }, "mimetype": "text/x-python", "name": "python", "npconvert_exporter": "python", + "nteract": { + "version": "nteract-front-end@1.0.0" + }, "pygments_lexer": "ipython3", "tags": [ "Forecasting" diff --git a/how-to-use-azureml/automated-machine-learning/forecasting-energy-demand/auto-ml-forecasting-energy-demand.ipynb b/how-to-use-azureml/automated-machine-learning/forecasting-energy-demand/auto-ml-forecasting-energy-demand.ipynb index bedef546e..f2666bb95 100644 --- a/how-to-use-azureml/automated-machine-learning/forecasting-energy-demand/auto-ml-forecasting-energy-demand.ipynb +++ b/how-to-use-azureml/automated-machine-learning/forecasting-energy-demand/auto-ml-forecasting-energy-demand.ipynb @@ -2,23 +2,22 @@ "cells": [ { "cell_type": "markdown", - "metadata": {}, "source": [ "Copyright (c) Microsoft Corporation. All rights reserved.\n", "\n", "Licensed under the MIT License." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/forecasting-energy-demand/auto-ml-forecasting-energy-demand.png)" - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# Automated Machine Learning\n", "_**Forecasting using the Energy Demand Dataset**_\n", @@ -33,11 +32,11 @@ "Advanced Forecasting\n", "1. [Advanced Training](#advanced_training)\n", "1. [Advanced Results](#advanced_results)" - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# Introduction\n", "\n", @@ -53,20 +52,18 @@ "1. Generate the forecast and compute the out-of-sample accuracy metrics\n", "1. Configuration and remote run of AutoML for a time-series model with lag and rolling window features\n", "1. Run and explore the forecast with lagging features" - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# Setup" - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "import json\n", "import logging\n", @@ -85,36 +82,36 @@ "from azureml.core import Experiment, Workspace, Dataset\n", "from azureml.train.automl import AutoMLConfig\n", "from datetime import datetime" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This notebook is compatible with Azure ML SDK version 1.35.0 or later." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "As part of the setup you have already created an Azure ML `Workspace` object. For Automated ML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "ws = Workspace.from_config()\n", "\n", @@ -136,11 +133,13 @@ "pd.set_option(\"display.max_colwidth\", None)\n", "outputDf = pd.DataFrame(data=output, index=[\"\"])\n", "outputDf.T" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "## Create or Attach existing AmlCompute\n", "A compute target is required to execute a remote Automated ML run. \n", @@ -150,13 +149,11 @@ "#### Creation of AmlCompute takes approximately 5 minutes. \n", "If the AmlCompute with that name is already in your workspace this code will skip the creation process.\n", "As with other Azure services, there are limits on certain resources (e.g. AmlCompute) associated with the Azure Machine Learning service. Please read [this article](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-manage-quotas) on the default limits and how to request more quota." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from azureml.core.compute import ComputeTarget, AmlCompute\n", "from azureml.core.compute_target import ComputeTargetException\n", @@ -175,22 +172,24 @@ " compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, compute_config)\n", "\n", "compute_target.wait_for_completion(show_output=True)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# Data\n", "\n", "We will use energy consumption [data from New York City](http://mis.nyiso.com/public/P-58Blist.htm) for model training. The data is stored in a tabular format and includes energy demand and basic weather data at an hourly frequency. \n", "\n", "With Azure Machine Learning datasets you can keep a single copy of data in your storage, easily access data during model training, share data and collaborate with other users. Below, we will upload the datatset and create a [tabular dataset](https://docs.microsoft.com/bs-latn-ba/azure/machine-learning/service/how-to-create-register-datasets#dataset-types) to be used training and prediction." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "Let's set up what we know about the dataset.\n", "\n", @@ -198,86 +197,122 @@ "Time column is the time axis along which to predict.\n", "\n", "The other columns, \"temp\" and \"precip\", are implicitly designated as features." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "target_column_name = \"demand\"\n", "time_column_name = \"timeStamp\"" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "dataset = Dataset.Tabular.from_delimited_files(\n", " path=\"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/nyc_energy.csv\"\n", ").with_timestamp_columns(fine_grain_timestamp=time_column_name)\n", "dataset.take(5).to_pandas_dataframe().reset_index(drop=True)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "The NYC Energy dataset is missing energy demand values for all datetimes later than August 10th, 2017 5AM. Below, we trim the rows containing these missing values from the end of the dataset." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# Cut off the end of the dataset due to large number of nan values\n", "dataset = dataset.time_before(datetime(2017, 10, 10, 5))" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "## Split the data into train and test sets" - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "The first split we make is into train and test sets. Note that we are splitting on time. Data before and including August 8th, 2017 5AM will be used for training, and data after will be used for testing." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# split into train based on time\n", - "train = dataset.time_before(datetime(2017, 8, 8, 5), include_boundary=True)\n", - "train.to_pandas_dataframe().reset_index(drop=True).sort_values(time_column_name).tail(5)" - ] + "train = (\n", + " dataset.time_before(datetime(2017, 8, 8, 5), include_boundary=True)\n", + " .to_pandas_dataframe()\n", + " .reset_index(drop=True)\n", + ")\n", + "train.sort_values(time_column_name).tail(5)" + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# split into test based on time\n", - "test = dataset.time_between(datetime(2017, 8, 8, 6), datetime(2017, 8, 10, 5))\n", - "test.to_pandas_dataframe().reset_index(drop=True).head(5)" - ] + "test = (\n", + " dataset.time_between(datetime(2017, 8, 8, 6), datetime(2017, 8, 10, 5))\n", + " .to_pandas_dataframe()\n", + " .reset_index(drop=True)\n", + ")\n", + "test.head(5)" + ], + "outputs": [], + "execution_count": null, + "metadata": {} + }, + { + "cell_type": "code", + "source": [ + "# register the splitted train and test data in workspace storage\n", + "from azureml.data.dataset_factory import TabularDatasetFactory\n", + "\n", + "datastore = ws.get_default_datastore()\n", + "train_dataset = TabularDatasetFactory.register_pandas_dataframe(\n", + " train, target=(datastore, \"dataset/\"), name=\"nyc_energy_train\"\n", + ")\n", + "test_dataset = TabularDatasetFactory.register_pandas_dataframe(\n", + " test, target=(datastore, \"dataset/\"), name=\"nyc_energy_test\"\n", + ")" + ], + "outputs": [], + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": false, + "outputs_hidden": false + }, + "nteract": { + "transient": { + "deleting": false + } + } + } }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Setting the maximum forecast horizon\n", "\n", @@ -286,20 +321,20 @@ "Learn more about forecast horizons in our [Auto-train a time-series forecast model](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-auto-train-forecast#configure-and-run-experiment) guide.\n", "\n", "In this example, we set the horizon to 48 hours." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "forecast_horizon = 48" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "## Forecasting Parameters\n", "To define forecasting parameters for your experiment training, you can leverage the ForecastingParameters class. The table below details the forecasting parameter we will be passing into our experiment.\n", @@ -310,11 +345,11 @@ "|**forecast_horizon**|The forecast horizon is how many periods forward you would like to forecast. This integer horizon is in units of the timeseries frequency (e.g. daily, weekly).|\n", "|**freq**|Forecast frequency. This optional parameter represents the period with which the forecast is desired, for example, daily, weekly, yearly, etc. Use this parameter for the correction of time series containing irregular data points or for padding of short time series. The frequency needs to be a pandas offset alias. Please refer to [pandas documentation](https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#dateoffset-objects) for more information.\n", "|**cv_step_size**|Number of periods between two consecutive cross-validation folds. The default value is \"auto\", in which case AutoMl determines the cross-validation step size automatically, if a validation set is not provided. Or users could specify an integer value." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# Train\n", "\n", @@ -332,20 +367,18 @@ "|**n_cross_validations**|Number of cross-validation folds to use for model/pipeline selection. The default value is \"auto\", in which case AutoMl determines the number of cross-validations automatically, if a validation set is not provided. Or users could specify an integer value.\n", "|**enable_early_stopping**|Flag to enble early termination if the score is not improving in the short term.|\n", "|**forecasting_parameters**|A class holds all the forecasting related parameters.|\n" - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This notebook uses the blocked_models parameter to exclude some models that take a longer time to train on this dataset. You can choose to remove models from the blocked_models list but you may need to increase the experiment_timeout_hours parameter value to get results." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from azureml.automl.core.forecasting_parameters import ForecastingParameters\n", "\n", @@ -361,7 +394,7 @@ " primary_metric=\"normalized_root_mean_squared_error\",\n", " blocked_models=[\"ExtremeRandomTrees\", \"AutoArima\", \"Prophet\"],\n", " experiment_timeout_hours=0.3,\n", - " training_data=train,\n", + " training_data=train_dataset,\n", " label_column_name=target_column_name,\n", " compute_target=compute_target,\n", " enable_early_stopping=True,\n", @@ -369,65 +402,65 @@ " verbosity=logging.INFO,\n", " forecasting_parameters=forecasting_parameters,\n", ")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "Call the `submit` method on the experiment object and pass the run configuration. Depending on the data and the number of iterations this can run for a while.\n", "One may specify `show_output = True` to print currently running iterations to the console." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "remote_run = experiment.submit(automl_config, show_output=False)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "remote_run.wait_for_completion()" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "## Retrieve the Best Run details\n", "Below we retrieve the best Run object from among all the runs in the experiment." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "best_run = remote_run.get_best_child()\n", "best_run" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "## Featurization\n", "We can look at the engineered feature names generated in time-series featurization via. the JSON file named 'engineered_feature_names.json' under the run outputs." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# Download the JSON file locally\n", "best_run.download_file(\n", @@ -437,11 +470,13 @@ " records = json.load(f)\n", "\n", "records" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### View featurization summary\n", "You can also see what featurization steps were performed on different raw features in the user data. For each raw feature in the user data, the following information is displayed:\n", @@ -451,13 +486,11 @@ "+ Type detected\n", "+ If feature was dropped\n", "+ List of feature transformations for the raw feature" - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# Download the featurization summary JSON file locally\n", "best_run.download_file(\n", @@ -479,41 +512,41 @@ " \"Transformations\",\n", " ]\n", "]" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# Forecasting\n", "\n", "Now that we have retrieved the best pipeline/model, it can be used to make predictions on test data. We will do batch scoring on the test dataset which should have the same schema as training dataset.\n", "\n", "The inference will run on a remote compute. In this example, it will re-use the training compute." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "test_experiment = Experiment(ws, experiment_name + \"_inference\")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Retrieving forecasts from the model\n", "We have created a function called `run_forecast` that submits the test data to the best model determined during the training run and retrieves forecasts. This function uses a helper script `forecasting_script` which is uploaded and expecuted on the remote compute." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from run_forecast import run_remote_inference\n", "\n", @@ -521,39 +554,39 @@ " test_experiment=test_experiment,\n", " compute_target=compute_target,\n", " train_run=best_run,\n", - " test_dataset=test,\n", + " test_dataset=test_dataset,\n", " target_column_name=target_column_name,\n", ")\n", "remote_run_infer.wait_for_completion(show_output=False)\n", "\n", "# download the inference output file to the local machine\n", "remote_run_infer.download_file(\"outputs/predictions.csv\", \"predictions.csv\")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Evaluate\n", "To evaluate the accuracy of the forecast, we'll compare against the actual sales quantities for some select metrics, included the mean absolute percentage error (MAPE). For more metrics that can be used for evaluation after training, please see [supported metrics](https://docs.microsoft.com/en-us/azure/machine-learning/how-to-understand-automated-ml#regressionforecasting-metrics), and [how to calculate residuals](https://docs.microsoft.com/en-us/azure/machine-learning/how-to-understand-automated-ml#residuals)." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# load forecast data frame\n", "fcst_df = pd.read_csv(\"predictions.csv\", parse_dates=[time_column_name])\n", "fcst_df.head()" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from azureml.automl.core.shared import constants\n", "from azureml.automl.runtime.shared.score import scoring\n", @@ -580,31 +613,31 @@ " (test_pred, test_test), (\"prediction\", \"truth\"), loc=\"upper left\", fontsize=8\n", ")\n", "plt.show()" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# Advanced Training \n", "We did not use lags in the previous model specification. In effect, the prediction was the result of a simple regression on date, time series identifier columns and any additional features. This is often a very good prediction as common time series patterns like seasonality and trends can be captured in this manner. Such simple regression is horizon-less: it doesn't matter how far into the future we are predicting, because we are not using past data. In the previous example, the horizon was only used to split the data for cross-validation." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Using lags and rolling window features\n", "Now we will configure the target lags, that is the previous values of the target variables, meaning the prediction is no longer horizon-less. We therefore must still specify the `forecast_horizon` that the model will learn to forecast. The `target_lags` keyword specifies how far back we will construct the lags of the target variable, and the `target_rolling_window_size` specifies the size of the rolling window over which we will generate the `max`, `min` and `sum` features.\n", "\n", "This notebook uses the blocked_models parameter to exclude some models that take a longer time to train on this dataset. You can choose to remove models from the blocked_models list but you may need to increase the iteration_timeout_minutes parameter value to get results." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "advanced_forecasting_parameters = ForecastingParameters(\n", " time_column_name=time_column_name,\n", @@ -627,7 +660,7 @@ " \"Prophet\",\n", " ], # These models are blocked for tutorial purposes, remove this for real use cases.\n", " experiment_timeout_hours=0.3,\n", - " training_data=train,\n", + " training_data=train_dataset,\n", " label_column_name=target_column_name,\n", " compute_target=compute_target,\n", " enable_early_stopping=True,\n", @@ -635,70 +668,70 @@ " verbosity=logging.INFO,\n", " forecasting_parameters=advanced_forecasting_parameters,\n", ")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "We now start a new remote run, this time with lag and rolling window featurization. AutoML applies featurizations in the setup stage, prior to iterating over ML models. The full training set is featurized first, followed by featurization of each of the CV splits. Lag and rolling window features introduce additional complexity, so the run will take longer than in the previous example that lacked these featurizations." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "advanced_remote_run = experiment.submit(automl_config, show_output=False)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "advanced_remote_run.wait_for_completion()" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Retrieve the Best Run details" - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "best_run_lags = remote_run.get_best_child()\n", "best_run_lags" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# Advanced Results\n", "We did not use lags in the previous model specification. In effect, the prediction was the result of a simple regression on date, time series identifier columns and any additional features. This is often a very good prediction as common time series patterns like seasonality and trends can be captured in this manner. Such simple regression is horizon-less: it doesn't matter how far into the future we are predicting, because we are not using past data. In the previous example, the horizon was only used to split the data for cross-validation." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "test_experiment_advanced = Experiment(ws, experiment_name + \"_inference_advanced\")\n", "advanced_remote_run_infer = run_remote_inference(\n", " test_experiment=test_experiment_advanced,\n", " compute_target=compute_target,\n", " train_run=best_run_lags,\n", - " test_dataset=test,\n", + " test_dataset=test_dataset,\n", " target_column_name=target_column_name,\n", " inference_folder=\"./forecast_advanced\",\n", ")\n", @@ -708,23 +741,23 @@ "advanced_remote_run_infer.download_file(\n", " \"outputs/predictions.csv\", \"predictions_advanced.csv\"\n", ")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "fcst_adv_df = pd.read_csv(\"predictions_advanced.csv\", parse_dates=[time_column_name])\n", "fcst_adv_df.head()" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from azureml.automl.core.shared import constants\n", "from azureml.automl.runtime.shared.score import scoring\n", @@ -753,7 +786,10 @@ " (test_pred, test_test), (\"prediction\", \"truth\"), loc=\"upper left\", fontsize=8\n", ")\n", "plt.show()" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} } ], "metadata": { @@ -767,26 +803,37 @@ "automated-machine-learning" ], "kernelspec": { - "display_name": "Python 3.8 - AzureML", + "name": "python38-azureml", "language": "python", - "name": "python38-azureml" + "display_name": "Python 3.8 - AzureML" }, "language_info": { + "name": "python", + "version": "3.8.5", + "mimetype": "text/x-python", "codemirror_mode": { "name": "ipython", "version": 3 }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "nbconvert_exporter": "python", + "file_extension": ".py" }, "vscode": { "interpreter": { "hash": "6bd77c88278e012ef31757c15997a7bea8c943977c43d6909403c00ae11d43ca" } + }, + "microsoft": { + "ms_spell_check": { + "ms_spell_check_language": "en" + } + }, + "kernel_info": { + "name": "python3" + }, + "nteract": { + "version": "nteract-front-end@1.0.0" } }, "nbformat": 4, diff --git a/how-to-use-azureml/automated-machine-learning/forecasting-orange-juice-sales/auto-ml-forecasting-orange-juice-sales.ipynb b/how-to-use-azureml/automated-machine-learning/forecasting-orange-juice-sales/auto-ml-forecasting-orange-juice-sales.ipynb index 26eae3218..c50cee1bd 100644 --- a/how-to-use-azureml/automated-machine-learning/forecasting-orange-juice-sales/auto-ml-forecasting-orange-juice-sales.ipynb +++ b/how-to-use-azureml/automated-machine-learning/forecasting-orange-juice-sales/auto-ml-forecasting-orange-juice-sales.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -10,6 +11,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -17,6 +19,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -34,6 +37,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -46,6 +50,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -70,6 +75,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -86,6 +92,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -119,6 +126,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -158,6 +166,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -181,6 +190,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -201,6 +211,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -220,6 +231,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -250,6 +262,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -275,6 +288,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -291,6 +305,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -318,6 +333,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -356,6 +372,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -373,6 +390,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -446,6 +464,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -472,6 +491,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -491,6 +511,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -528,6 +549,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -548,6 +570,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -556,6 +579,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -584,6 +608,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -639,6 +664,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -646,6 +672,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -668,6 +695,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -687,6 +715,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -715,7 +744,7 @@ " description=\"Automl forecasting sample service\",\n", ")\n", "\n", - "aci_service_name = \"automl-oj-forecast-01\"\n", + "aci_service_name = \"automl-oj-forecast-03\"\n", "print(aci_service_name)\n", "aci_service = Model.deploy(ws, aci_service_name, [model], inference_config, aciconfig)\n", "aci_service.wait_for_deployment(True)\n", @@ -732,6 +761,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -780,6 +810,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -792,7 +823,7 @@ "metadata": {}, "outputs": [], "source": [ - "serv = Webservice(ws, \"automl-oj-forecast-01\")\n", + "serv = Webservice(ws, \"automl-oj-forecast-03\")\n", "serv.delete() # don't do it accidentally" ] } diff --git a/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-experiment-settings.ipynb b/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-experiment-settings.ipynb index d73121a2d..c83731a08 100644 --- a/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-experiment-settings.ipynb +++ b/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-experiment-settings.ipynb @@ -2,25 +2,24 @@ "cells": [ { "cell_type": "markdown", - "metadata": {}, "source": [ "Copyright (c) Microsoft Corporation. All rights reserved.\n", "\n", "Licensed under the MIT License." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/1_determine_experiment_settings.png)" - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ - "In this notebook we will explore the univaraite time-series data to determine the settings for an automated ML experiment. We will follow the thought process depicted in the following diagram:
\n", + "In this notebook we will explore the univariate time-series data to determine the settings for an automated ML experiment. We will follow the thought process depicted in the following diagram:
\n", "![Forecasting after training](figures/univariate_settings_map_20210408.jpg)\n", "\n", "The objective is to answer the following questions:\n", @@ -32,22 +31,20 @@ " \n", "
  • Is the data stationary?
  • \n", " \n", "
  • Is there a detectable auto-regressive pattern in the stationary data?
  • \n", " \n", "\n", "\n", "The answers to these questions will help determine the appropriate settings for the automated ML experiment.\n" - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "import os\n", "import warnings\n", @@ -68,13 +65,13 @@ "# set printing options\n", "pd.set_option(\"display.max_columns\", 500)\n", "pd.set_option(\"display.width\", 1000)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# load data\n", "main_data_loc = \"data\"\n", @@ -89,13 +86,13 @@ "df.sort_values(by=TIME_COLNAME, inplace=True)\n", "df.set_index(TIME_COLNAME, inplace=True)\n", "df.head(2)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# plot the entire dataset\n", "fig, ax = plt.subplots(figsize=(6, 2), dpi=180)\n", @@ -103,20 +100,20 @@ "ax.title.set_text(\"Original Data Series\")\n", "locs, labels = plt.xticks()\n", "plt.xticks(rotation=45)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ - "The graph plots the alcohol sales in the United States. Because the data is trending, it can be difficult to see cycles, seasonality or other interestng behaviors due to the scaling issues. For example, if there is a seasonal pattern, which we will discuss later, we cannot see them on the trending data. In such case, it is worth plotting the same data in first differences." - ] + "The graph plots the alcohol sales in the United States. Because the data is trending, it can be difficult to see cycles, seasonality or other interesting behaviors due to the scaling issues. For example, if there is a seasonal pattern, which we will discuss later, we cannot see them on the trending data. In such case, it is worth plotting the same data in first differences." + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# plot the entire dataset in first differences\n", "fig, ax = plt.subplots(figsize=(6, 2), dpi=180)\n", @@ -124,18 +121,20 @@ "ax.title.set_text(\"Data in first differences\")\n", "locs, labels = plt.xticks()\n", "plt.xticks(rotation=45)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "In the previous plot we observe that the data is more volatile towards the end of the series. This period coincides with the Covid-19 period, so we will exclude it from our experiment. Since in this example there are no user-provided features it is hard to make an argument that a model trained on the less volatile pre-covid data will be able to accurately predict the covid period." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# 1. Seasonality\n", "\n", @@ -144,13 +143,11 @@ "2. If it's seasonal, does the data exhibit a trend (up or down)?\n", "\n", "It is hard to visually detect seasonality when the data is trending. The reason being is scale of seasonal fluctuations is dwarfed by the range of the trend in the data. One way to deal with this is to de-trend the data by taking the first differences. We will discuss this in more detail in the next section." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# plot the entire dataset in first differences\n", "fig, ax = plt.subplots(figsize=(6, 2), dpi=180)\n", @@ -158,20 +155,20 @@ "ax.title.set_text(\"Data in first differences\")\n", "locs, labels = plt.xticks()\n", "plt.xticks(rotation=45)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "For the next plot, we will exclude the Covid period again. We will also shorten the length of data because plotting a very long time series may prevent us from seeing seasonal patterns, if there are any, because the plot may look like a random walk." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# remove COVID period\n", "df = df[:COVID_PERIOD_START]\n", @@ -182,11 +179,13 @@ "ax.title.set_text(\"Data in first differences\")\n", "locs, labels = plt.xticks()\n", "plt.xticks(rotation=45)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "

    Conclusion

    \n", "\n", @@ -205,11 +204,11 @@ "
  • In the first case, by taking first differences we are removing stochastic trend, but we do not remove seasonal patterns. In the second case, we do not remove the stochastic trend and it can be captured by the trend component of the STL decomposition. It is hard to say which option will work best in your case, hence you will need to run both options to see which one results in more accurate forecasts.
  • \n", " \n", "" - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# 2. Stationarity\n", "If the data does not exhibit seasonal patterns, we would like to see if the data is non-stationary. Particularly, we want to see if there is a clear trending behavior. If such behavior is observed, we would like to first difference the data and examine the plot of an auto-correlation function (ACF) known as correlogram. If the data is seasonal, differencing it will not get rid off the seasonality and this will be shown on the correlogram as well.\n", @@ -237,13 +236,11 @@ "\n", "\n", "To answer the first question, we run a series of tests (we call them unit root tests)." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# unit root tests\n", "test = unit_root_test_wrapper(df[TARGET_COLNAME])\n", @@ -251,11 +248,13 @@ "print(\"Summary table\", \"\\n\", test[\"summary\"], \"\\n\")\n", "print(\"Is the {} series stationary?: {}\".format(TARGET_COLNAME, test[\"stationary\"]))\n", "print(\"---------------\", \"\\n\")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "In the previous cell, we ran a series of unit root tests. The summary table contains the following columns:\n", "\n", "" - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "" - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ " " - ] + ], + "metadata": {} } ], "metadata": { @@ -472,21 +472,32 @@ } ], "kernelspec": { - "display_name": "Python 3.8 - AzureML", + "name": "python38-azureml", "language": "python", - "name": "python38-azureml" + "display_name": "Python 3.8 - AzureML" }, "language_info": { + "name": "python", + "version": "3.8.10", + "mimetype": "text/x-python", "codemirror_mode": { "name": "ipython", "version": 3 }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.9" + "nbconvert_exporter": "python", + "file_extension": ".py" + }, + "microsoft": { + "ms_spell_check": { + "ms_spell_check_language": "en" + } + }, + "kernel_info": { + "name": "python38-azureml" + }, + "nteract": { + "version": "nteract-front-end@1.0.0" } }, "nbformat": 4, diff --git a/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-run-experiment.ipynb b/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-run-experiment.ipynb index 1fcca49fc..6d70f388d 100644 --- a/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-run-experiment.ipynb +++ b/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-run-experiment.ipynb @@ -2,23 +2,22 @@ "cells": [ { "cell_type": "markdown", - "metadata": {}, "source": [ "Copyright (c) Microsoft Corporation. All rights reserved.\n", "\n", "Licensed under the MIT License." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/2_run_experiment.png)" - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# Running AutoML experiments\n", "\n", @@ -27,20 +26,18 @@ "
    \n", "\n", "The output generated by this notebook is saved in the `experiment_output`folder." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Setup" - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "import os\n", "import logging\n", @@ -63,21 +60,21 @@ "np.set_printoptions(precision=4, suppress=True, linewidth=100)\n", "pd.set_option(\"display.max_columns\", 500)\n", "pd.set_option(\"display.width\", 1000)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "As part of the setup you have already created a **Workspace**. You will also need to create a [compute target](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-set-up-training-targets#amlcompute) for your AutoML run. In this tutorial, you create AmlCompute as your training compute resource.\n", "> Note that if you have an AzureML Data Scientist role, you will not have permission to create compute resources. Talk to your workspace or IT admin to create the compute targets described in this section, if they do not already exist." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "ws = Workspace.from_config()\n", "amlcompute_cluster_name = \"recipe-cluster\"\n", @@ -107,22 +104,22 @@ "compute_target.wait_for_completion(\n", " show_output=True, min_node_count=None, timeout_in_minutes=20\n", ")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Data\n", "\n", "Here, we will load the data from the csv file and drop the Covid period." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "main_data_loc = \"data\"\n", "train_file_name = \"S4248SM144SCEN.csv\"\n", @@ -140,32 +137,34 @@ "\n", "# remove the Covid period\n", "df = df.query('{} <= \"{}\"'.format(TIME_COLNAME, COVID_PERIOD_START))" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Set parameters\n", "\n", "The first set of parameters is based on the analysis performed in the `auto-ml-forecasting-univariate-recipe-experiment-settings` notebook. " - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# set parameters based on the settings notebook analysis\n", "DIFFERENCE_SERIES = True\n", "TARGET_LAGS = None\n", "STL_TYPE = None" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "Next, define additional parameters to be used in the AutoML config class.\n", "\n", @@ -180,32 +179,30 @@ " \n", " \n", "\n" - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# set other parameters\n", "FORECAST_HORIZON = 12\n", "TIME_SERIES_ID_COLNAMES = []\n", "BLOCKED_MODELS = []" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "To run AutoML, you also need to create an **Experiment**. An Experiment corresponds to a prediction problem you are trying to solve, while a Run corresponds to a specific approach to the problem." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# choose a name for the run history container in the workspace\n", "if isinstance(TARGET_LAGS, list):\n", @@ -232,38 +229,38 @@ "pd.set_option(\"display.max_colwidth\", None)\n", "outputDf = pd.DataFrame(data=output, index=[\"\"])\n", "print(outputDf.T)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# create output directory\n", "output_dir = \"experiment_output/{}\".format(experiment_desc)\n", "if not os.path.exists(output_dir):\n", " os.makedirs(output_dir)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# difference data and test for unit root\n", "if DIFFERENCE_SERIES:\n", " df_delta = df.copy()\n", " df_delta[TARGET_COLNAME] = df[TARGET_COLNAME].diff()\n", " df_delta.dropna(axis=0, inplace=True)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# split the data into train and test set\n", "if DIFFERENCE_SERIES:\n", @@ -281,64 +278,51 @@ " time_colname=TIME_COLNAME,\n", " ts_id_colnames=TIME_SERIES_ID_COLNAMES,\n", " )" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Upload files to the Datastore\n", "The [Machine Learning service workspace](https://docs.microsoft.com/en-us/azure/machine-learning/service/concept-workspace) is paired with the storage account, which contains the default data store. We will use it to upload the bike share data and create [tabular dataset](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.data.tabulardataset?view=azure-ml-py) for training. A tabular dataset defines a series of lazily-evaluated, immutable operations to load data from the data source into tabular representation." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "df_train.to_csv(\"train.csv\", index=False)\n", "df_test.to_csv(\"test.csv\", index=False)\n", "\n", - "datastore = ws.get_default_datastore()\n", - "datastore.upload_files(\n", - " files=[\"./train.csv\"],\n", - " target_path=\"uni-recipe-dataset/tabular/\",\n", - " overwrite=True,\n", - " show_progress=True,\n", - ")\n", - "datastore.upload_files(\n", - " files=[\"./test.csv\"],\n", - " target_path=\"uni-recipe-dataset/tabular/\",\n", - " overwrite=True,\n", - " show_progress=True,\n", - ")\n", - "\n", - "from azureml.core import Dataset\n", + "from azureml.data.dataset_factory import TabularDatasetFactory\n", "\n", - "train_dataset = Dataset.Tabular.from_delimited_files(\n", - " path=[(datastore, \"uni-recipe-dataset/tabular/train.csv\")]\n", + "datastore = ws.get_default_datastore()\n", + "train_dataset = TabularDatasetFactory.register_pandas_dataframe(\n", + " df_train, target=(datastore, \"dataset/\"), name=\"train\"\n", ")\n", - "test_dataset = Dataset.Tabular.from_delimited_files(\n", - " path=[(datastore, \"uni-recipe-dataset/tabular/test.csv\")]\n", + "test_dataset = TabularDatasetFactory.register_pandas_dataframe(\n", + " df_test, target=(datastore, \"dataset/\"), name=\"test\"\n", ")\n", "\n", "# print the first 5 rows of the Dataset\n", "train_dataset.to_pandas_dataframe().reset_index(drop=True).head(5)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Config AutoML" - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "time_series_settings = {\n", " \"time_column_name\": TIME_COLNAME,\n", @@ -365,76 +349,76 @@ " compute_target=compute_target,\n", " **time_series_settings,\n", ")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "We will now run the experiment, you can go to Azure ML portal to view the run details." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "remote_run = experiment.submit(automl_config, show_output=False)\n", "remote_run.wait_for_completion()" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Retrieve the Best Run details\n", "Below we retrieve the best Run object from among all the runs in the experiment." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "best_run = remote_run.get_best_child()\n", "best_run" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Inference\n", "\n", "We now use the best fitted model from the AutoML Run to make forecasts for the test set. We will do batch scoring on the test dataset which should have the same schema as training dataset.\n", "\n", "The inference will run on a remote compute. In this example, it will re-use the training compute." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "test_experiment = Experiment(ws, experiment_name + \"_inference\")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "## Retreiving forecasts from the model\n", "We have created a function called `run_forecast` that submits the test data to the best model determined during the training run and retrieves forecasts. This function uses a helper script `forecasting_script` which is uploaded and expecuted on the remote compute." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from run_forecast import run_remote_inference\n", "\n", @@ -448,31 +432,31 @@ "remote_run.wait_for_completion(show_output=False)\n", "\n", "remote_run.download_file(\"outputs/predictions.csv\", f\"{output_dir}/predictions.csv\")" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Download the prediction result for metrics calcuation\n", "The test data with predictions are saved in artifact `outputs/predictions.csv`. We will use it to calculate accuracy metrics and vizualize predictions versus actuals." - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "X_trans = pd.read_csv(f\"{output_dir}/predictions.csv\", parse_dates=[TIME_COLNAME])\n", "X_trans.head()" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# convert forecast in differences to levels\n", "def convert_fcst_diff_to_levels(fcst, yt, df_orig):\n", @@ -486,13 +470,13 @@ " )\n", " out.rename(columns={TARGET_COLNAME: \"actual_level\"}, inplace=True)\n", " return out" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "if DIFFERENCE_SERIES:\n", " # convert forecast in differences to the levels\n", @@ -506,20 +490,20 @@ " fcst_df[\"predicted_level\"] = y_predictions\n", "\n", "del X_trans" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Calculate metrics and save output" - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "# compute metrics\n", "metrics_df = compute_metrics(fcst_df=fcst_df, metric_name=None, ts_id_colnames=None)\n", @@ -530,20 +514,20 @@ "\n", "metrics_df.to_csv(os.path.join(output_dir, metrics_file_name), index=True)\n", "fcst_df.to_csv(os.path.join(output_dir, fcst_file_name), index=True)" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "### Generate and save visuals" - ] + ], + "metadata": {} }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "plot_df = df.query('{} > \"2010-01-01\"'.format(TIME_COLNAME))\n", "plot_df.set_index(TIME_COLNAME, inplace=True)\n", @@ -562,7 +546,10 @@ "\n", "plt.setp(labels, rotation=45)\n", "plt.savefig(os.path.join(output_dir, plot_file_name))" - ] + ], + "outputs": [], + "execution_count": null, + "metadata": {} } ], "metadata": { @@ -572,26 +559,37 @@ } ], "kernelspec": { - "display_name": "Python 3.8 - AzureML", + "name": "python38-azureml", "language": "python", - "name": "python38-azureml" + "display_name": "Python 3.8 - AzureML" }, "language_info": { + "name": "python", + "version": "3.8.5", + "mimetype": "text/x-python", "codemirror_mode": { "name": "ipython", "version": 3 }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "nbconvert_exporter": "python", + "file_extension": ".py" }, "vscode": { "interpreter": { "hash": "6bd77c88278e012ef31757c15997a7bea8c943977c43d6909403c00ae11d43ca" } + }, + "microsoft": { + "ms_spell_check": { + "ms_spell_check_language": "en" + } + }, + "kernel_info": { + "name": "python3" + }, + "nteract": { + "version": "nteract-front-end@1.0.0" } }, "nbformat": 4, diff --git a/how-to-use-azureml/deployment/deploy-to-cloud/model-register-and-deploy.ipynb b/how-to-use-azureml/deployment/deploy-to-cloud/model-register-and-deploy.ipynb index a593061c7..673a0a4a7 100644 --- a/how-to-use-azureml/deployment/deploy-to-cloud/model-register-and-deploy.ipynb +++ b/how-to-use-azureml/deployment/deploy-to-cloud/model-register-and-deploy.ipynb @@ -91,7 +91,7 @@ "metadata": {}, "outputs": [], "source": [ - "import joblib\n", + "import dill\n", "\n", "from sklearn.datasets import load_diabetes\n", "from sklearn.linear_model import Ridge\n", @@ -101,7 +101,7 @@ "\n", "model = Ridge().fit(dataset_x, dataset_y)\n", "\n", - "joblib.dump(model, 'sklearn_regression_model.pkl')" + "dill.dump(model, open('sklearn_regression_model.pkl', 'wb'))" ] }, { @@ -285,6 +285,7 @@ " 'azureml-defaults',\n", " 'inference-schema[numpy-support]',\n", " 'joblib',\n", + " 'dill==0.3.6',\n", " 'numpy==1.23',\n", " 'scikit-learn=={}'.format(sklearn.__version__)\n", "])" @@ -486,6 +487,7 @@ " 'azureml-defaults',\n", " 'inference-schema[numpy-support]',\n", " 'joblib',\n", + " 'dill==0.3.6',\n", " 'numpy==1.23',\n", " 'scikit-learn=={}'.format(sklearn.__version__)\n", "])\n", diff --git a/how-to-use-azureml/explain-model/azure-integration/gpu-explanation/train-explain-model-gpu-tree-explainer.ipynb b/how-to-use-azureml/explain-model/azure-integration/gpu-explanation/train-explain-model-gpu-tree-explainer.ipynb index caa0ea911..1b6fbcbed 100644 --- a/how-to-use-azureml/explain-model/azure-integration/gpu-explanation/train-explain-model-gpu-tree-explainer.ipynb +++ b/how-to-use-azureml/explain-model/azure-integration/gpu-explanation/train-explain-model-gpu-tree-explainer.ipynb @@ -106,7 +106,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(\"This notebook was created using version 1.50.0 of the Azure ML SDK\")\n", + "print(\"This notebook was created using version 1.51 of the Azure ML SDK\")\n", "print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")" ] }, diff --git a/how-to-use-azureml/explain-model/azure-integration/gpu-explanation/train-explain-model-gpu-tree-explainer.yml b/how-to-use-azureml/explain-model/azure-integration/gpu-explanation/train-explain-model-gpu-tree-explainer.yml index 3946b1a13..8a4f04fb7 100644 --- a/how-to-use-azureml/explain-model/azure-integration/gpu-explanation/train-explain-model-gpu-tree-explainer.yml +++ b/how-to-use-azureml/explain-model/azure-integration/gpu-explanation/train-explain-model-gpu-tree-explainer.yml @@ -10,7 +10,7 @@ dependencies: - ipython - matplotlib - ipywidgets - - raiwidgets~=0.26.0 + - raiwidgets~=0.27.0 - itsdangerous==2.0.1 - markupsafe<2.1.0 - scipy>=1.5.3 diff --git a/how-to-use-azureml/explain-model/azure-integration/remote-explanation/explain-model-on-amlcompute.yml b/how-to-use-azureml/explain-model/azure-integration/remote-explanation/explain-model-on-amlcompute.yml index b79e5a216..d7e25fdc7 100644 --- a/how-to-use-azureml/explain-model/azure-integration/remote-explanation/explain-model-on-amlcompute.yml +++ b/how-to-use-azureml/explain-model/azure-integration/remote-explanation/explain-model-on-amlcompute.yml @@ -8,9 +8,8 @@ dependencies: - gevent>=1.3.6 - ipython - matplotlib - - azureml-dataset-runtime - ipywidgets - - raiwidgets~=0.26.0 + - raiwidgets~=0.27.0 - itsdangerous==2.0.1 - markupsafe<2.1.0 - scipy>=1.5.3 diff --git a/how-to-use-azureml/explain-model/azure-integration/run-history/save-retrieve-explanations-run-history.yml b/how-to-use-azureml/explain-model/azure-integration/run-history/save-retrieve-explanations-run-history.yml index 801f4962a..530dd05f1 100644 --- a/how-to-use-azureml/explain-model/azure-integration/run-history/save-retrieve-explanations-run-history.yml +++ b/how-to-use-azureml/explain-model/azure-integration/run-history/save-retrieve-explanations-run-history.yml @@ -9,7 +9,7 @@ dependencies: - ipython - matplotlib - ipywidgets - - raiwidgets~=0.26.0 + - raiwidgets~=0.27.0 - packaging>=20.9 - itsdangerous==2.0.1 - markupsafe<2.1.0 diff --git a/how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-locally-and-deploy.yml b/how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-locally-and-deploy.yml index e63912b78..de4afb21e 100644 --- a/how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-locally-and-deploy.yml +++ b/how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-locally-and-deploy.yml @@ -9,7 +9,7 @@ dependencies: - ipython - matplotlib - ipywidgets - - raiwidgets~=0.26.0 + - raiwidgets~=0.27.0 - packaging>=20.9 - itsdangerous==2.0.1 - markupsafe<2.1.0 diff --git a/how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-on-amlcompute-and-deploy.yml b/how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-on-amlcompute-and-deploy.yml index 6812a6dda..32f38b978 100644 --- a/how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-on-amlcompute-and-deploy.yml +++ b/how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-on-amlcompute-and-deploy.yml @@ -8,10 +8,9 @@ dependencies: - gevent>=1.3.6 - ipython - matplotlib - - azureml-dataset-runtime - azureml-core - ipywidgets - - raiwidgets~=0.26.0 + - raiwidgets~=0.27.0 - itsdangerous==2.0.1 - markupsafe<2.1.0 - scipy>=1.5.3 diff --git a/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/docker/Dockerfile-gpu b/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/docker/Dockerfile-gpu index 01dcdc934..83aa1f4f0 100644 --- a/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/docker/Dockerfile-gpu +++ b/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/docker/Dockerfile-gpu @@ -1,14 +1,16 @@ -FROM mcr.microsoft.com/azureml/openmpi4.1.0-cuda11.2-cudnn8-ubuntu20.04:20221010.v1 +# NC-series GPUs only support the pytorch-1.11/cuda11.3 combo +# See https://learn.microsoft.com/en-us/azure/machine-learning/resource-curated-environments +FROM mcr.microsoft.com/azureml/curated/acpt-pytorch-1.11-cuda11.3 USER root -ENV AZUREML_CONDA_ENVIRONMENT_PATH /azureml-envs/tensorflow-2.7 +# ENV AZUREML_CONDA_ENVIRONMENT_PATH /azureml-envs/ray-rllib # Create conda environment -RUN conda create -p $AZUREML_CONDA_ENVIRONMENT_PATH \ - python=3.8 pip=20.2.4 +# RUN conda create -p $AZUREML_CONDA_ENVIRONMENT_PATH \ +# python=3.8.5 # Prepend path to AzureML conda environment -ENV PATH $AZUREML_CONDA_ENVIRONMENT_PATH/bin:$PATH +# ENV PATH $AZUREML_CONDA_ENVIRONMENT_PATH/bin:$PATH # Install necessary packages to support videos in rllib/gym RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -22,51 +24,32 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ RUN pip --version RUN python --version -# Install ray-on-aml -RUN pip install 'ray-on-aml==0.1.6' - -RUN pip install ray==0.8.7 -RUN pip install gym[atari]==0.19.0 -RUN pip install gym[accept-rom-license]==0.19.0 - -# Install pip dependencies for Tensorflow -RUN pip install 'matplotlib~=3.5.0' \ - 'psutil~=5.8.0' \ - 'tqdm~=4.62.0' \ - 'pandas~=1.3.0' \ - 'scipy~=1.7.0' \ - 'numpy~=1.21.0' \ - 'ipykernel~=6.0' \ - 'azureml-core==1.47.0' \ - 'azureml-defaults==1.47.0' \ - 'azureml-mlflow==1.47.0' \ - 'azureml-telemetry==1.47.0' \ - 'tensorboard~=2.7.0' \ - 'tensorflow-gpu~=2.7.0' \ - 'tensorflow-datasets~=4.5.0' \ - 'onnxruntime-gpu~=1.9.0' \ - 'protobuf~=3.20' \ - 'horovod[tensorflow-gpu]~=0.23.0' \ - 'debugpy~=1.6.3' - -RUN pip install --no-cache-dir \ - azureml-defaults \ - azureml-dataset-runtime[fuse,pandas] \ - azureml-contrib-reinforcementlearning \ - gputil \ - cloudpickle==1.3.0 \ - tabulate \ - dm_tree \ - lz4 \ - psutil \ - setproctitle - -# This is required for ray 0.8.7 -RUN pip install -U aiohttp==3.7.4 - -RUN pip install 'msrest<0.7.0' -RUN pip install protobuf==3.20.0 - -# This is needed for mpi to locate libpython -ENV LD_LIBRARY_PATH $AZUREML_CONDA_ENVIRONMENT_PATH/lib:$LD_LIBRARY_PATH +RUN pip install ray-on-aml==0.2.4 \ + ray==2.4.0 \ + ray[rllib]==2.4.0 \ + mlflow==2.3.1 \ + azureml-defaults==1.50.0 \ + azureml-dataset-runtime[fuse,pandas]==1.50.0 \ + azureml-contrib-reinforcementlearning==1.50.0 \ + gputil==1.4.0 \ + scipy==1.9.1 \ + pyglet==2.0.6 \ + cloudpickle==2.2.1 \ + tensorflow==2.11.0 \ + tensorflow-probability==0.19.0 \ + tabulate==0.9.0 \ + dm_tree==0.1.8 \ + lz4==4.3.2 \ + psutil==5.9.4 \ + setproctitle==1.3.2 \ + pygame==2.1.0 \ + gymnasium[classic_control]==0.26.3 \ + gymnasium[atari]==0.26.3 \ + gymnasium[accept-rom-license]==0.26.3 \ + gym==0.26.2 \ + gym[atari]==0.26.2 \ + gym[accept-rom-license]==0.26.2 + +# Display all versions +RUN pip freeze diff --git a/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/pong-impala-vectorized.yaml b/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/pong-impala-vectorized.yaml new file mode 100644 index 000000000..a27442e6b --- /dev/null +++ b/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/pong-impala-vectorized.yaml @@ -0,0 +1,18 @@ +pong-impala-vectorized: + env: ALE/Pong-v5 + run: IMPALA + config: + # Make analogous to old v4 + NoFrameskip. + env_config: + frameskip: 1 + full_action_space: false + repeat_action_probability: 0.0 + rollout_fragment_length: 50 + train_batch_size: 500 + num_workers: 11 + num_envs_per_worker: 10 + framework: torch + log_level: INFO + stop: + episode_reward_mean: 10 + time_total_s: 3600 diff --git a/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/pong_rllib.py b/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/pong_rllib.py index e2953f004..82c50eb1a 100644 --- a/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/pong_rllib.py +++ b/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/pong_rllib.py @@ -1,35 +1,35 @@ from ray_on_aml.core import Ray_On_AML - -import ray.tune as tune -from ray.rllib import train - +import yaml +from ray.tune.tune import run_experiments from utils import callbacks +import argparse + if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--config', help='Path to yaml configuration file') + args = parser.parse_args() ray_on_aml = Ray_On_AML() ray = ray_on_aml.getRay() if ray: # in the headnode - # Parse arguments - train_parser = train.create_parser() + ray.init(address="auto") + print("Configuring run from file: ", args.config) + experiment_config = None + with open(args.config, "r") as file: + experiment_config = yaml.safe_load(file) + print(f'Config: {experiment_config}') + + # Set local_dir in each experiment configuration to ensure generated logs get picked up + # by Azure ML + for experiment in experiment_config.values(): + experiment["local_dir"] = "./logs" - args = train_parser.parse_args() - print("Algorithm config:", args.config) + trials = run_experiments( + experiment_config, + callbacks=[callbacks.TrialCallback()], + verbose=2 + ) - tune.run( - run_or_experiment=args.run, - config={ - "env": args.env, - "num_gpus": args.config["num_gpus"], - "num_workers": args.config["num_workers"], - "callbacks": {"on_train_result": callbacks.on_train_result}, - "sample_batch_size": 50, - "train_batch_size": 1000, - "num_sgd_iter": 2, - "num_data_loader_buffers": 2, - "model": {"dim": 42}, - }, - stop=args.stop, - local_dir='./logs') else: print("in worker node") diff --git a/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/utils/callbacks.py b/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/utils/callbacks.py index f34a4e8c8..f296f5770 100644 --- a/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/utils/callbacks.py +++ b/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/files/utils/callbacks.py @@ -3,15 +3,20 @@ ''' from azureml.core import Run +from ray import tune +from ray.tune import Callback +from ray.air import session -def on_train_result(info): - '''Callback on train result to record metrics returned by trainer. - ''' - run = Run.get_context() - run.log( - name='episode_reward_mean', - value=info["result"]["episode_reward_mean"]) - run.log( - name='episodes_total', - value=info["result"]["episodes_total"]) +class TrialCallback(Callback): + + def on_trial_result(self, iteration, trials, trial, result, **info): + '''Callback on train result to record metrics returned by trainer. + ''' + run = Run.get_context() + run.log( + name='episode_reward_mean', + value=result["episode_reward_mean"]) + run.log( + name='episodes_total', + value=result["episodes_total"]) diff --git a/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/pong_rllib.ipynb b/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/pong_rllib.ipynb index 5fea0f502..e7c748b7f 100644 --- a/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/pong_rllib.ipynb +++ b/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/pong_rllib.ipynb @@ -22,7 +22,8 @@ "source": [ "# Reinforcement Learning in Azure Machine Learning - Pong problem\n", "Reinforcement Learning in Azure Machine Learning is a managed service for running distributed reinforcement learning training and simulation using the open source Ray framework.\n", - "This example uses Ray RLlib to train a Pong playing agent on a multi-node cluster.\n", + "This noteboook demonstrates how to use Ray to solve a more complex problem using a more complex setup including Ray RLLib running on multiple compute nodes and using a GPU.\n", + "For this example we will train a Pong playing agent on cluster of two NC6 nodes (6 CPU, 1 GPU).\n", "\n", "## Pong problem\n", "[Pong](https://en.wikipedia.org/wiki/Pong) is a two-dimensional sports game that simulates table tennis. The player controls an in-game paddle by moving it vertically across the left or right side of the screen. They can compete against another player controlling a second paddle on the opposing side. Players use the paddles to hit a ball back and forth." @@ -46,7 +47,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The goal here is to train an agent to win an episode of Pong game against opponent with the score of at least 18 points. An episode in Pong runs until one of the players reaches a score of 21. Episodes are a terminology that is used across all the [OpenAI gym](https://www.gymlibrary.dev/environments/atari/pong/) environments that contains a strictly defined task.\n", + "The goal here is to train an agent to win an episode of Pong game against opponent with the score of at least 10 points. An episode in Pong runs until one of the players reaches a score of 21. Episodes are a terminology that is used across all the [OpenAI gym](https://www.gymlibrary.dev/environments/atari/pong/) environments that contains a strictly defined task.\n", "\n", "Training a Pong agent is a compute-intensive task and this example demonstrates the use of Reinforcement Learning in Azure Machine Learning service to train an agent faster in a distributed, parallel environment. You'll learn more about using the head and the worker compute targets to train an agent in this notebook below." ] @@ -60,19 +61,6 @@ "It is highly recommended that the user should go through the [Reinforcement Learning in Azure Machine Learning - Cartpole Problem on Single Compute](../cartpole-on-single-compute/cartpole_sc.ipynb) to understand the basics of Reinforcement Learning in Azure Machine Learning and Ray RLlib used in this notebook." ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Set up Development Environment\n", - "The following subsections show typical steps to setup your development environment. Setup includes:\n", - "\n", - "* Connecting to a workspace to enable communication between your local machine and remote resources\n", - "* Creating an experiment to track all your runs\n", - "* Setting up a virtual network\n", - "* Creating remote head and worker compute target on a virtual network to use for training" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -86,7 +74,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646081765827 + "logged": 1683263371795 } }, "outputs": [], @@ -113,7 +101,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646081772340 + "logged": 1683263375690 } }, "outputs": [], @@ -137,7 +125,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646081775643 + "logged": 1683263378789 } }, "outputs": [], @@ -165,7 +153,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646086081229 + "logged": 1683263385677 } }, "outputs": [], @@ -177,7 +165,7 @@ "compute_min_nodes = 0\n", "compute_max_nodes = 2\n", "\n", - "# This example uses GPU VM. For using CPU VM, set SKU to STANDARD_D2_V2\n", + "# This example uses GPU VM.\n", "vm_size = 'STANDARD_NC6'\n", "\n", "if compute_name in ws.compute_targets:\n", @@ -207,15 +195,52 @@ " print(compute_target.get_status().serialize())" ] }, + { + "cell_type": "markdown", + "metadata": { + "nteract": { + "transient": { + "deleting": false + } + } + }, + "source": [ + "### Create Azure ML Environment\r\n", + "\r\n", + "This step creates and registers an Azure ML Environment that includes all of the dependencies needed to run this example, including CUDA drivers Pytorch, RLLib, and associated tools. This step can take a significant time (30 min) on the first run." + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { "gather": { - "logged": 1646160884910 + "logged": 1683263388781 }, "jupyter": { - "outputs_hidden": true, + "outputs_hidden": false, + "source_hidden": false + }, + "nteract": { + "transient": { + "deleting": false + } + } + }, + "outputs": [], + "source": [ + "ray_environment_name = 'pong-gpu'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "gather": { + "logged": 1683056774047 + }, + "jupyter": { + "outputs_hidden": false, "source_hidden": false }, "nteract": { @@ -229,7 +254,6 @@ "import os\n", "from azureml.core import Environment\n", "\n", - "ray_environment_name = 'pong-gpu'\n", "ray_environment_dockerfile_path = os.path.join(os.getcwd(), 'docker', 'Dockerfile-gpu')\n", "\n", "# Build GPU image\n", @@ -249,15 +273,7 @@ "\n", "The code below submits the training run using a `ScriptRunConfig`. By providing the\n", "command to run the training, and a `RunConfig` object configured with your\n", - "compute target, number of nodes, and environment image to use.\n", - "\n", - "We specify `episode_reward_mean` to 18 as we want to stop the training as soon as the trained agent reaches an average win margin of at least 18 point over opponent over all episodes in the training epoch.\n", - "Number of Ray worker processes are defined by parameter `num_workers`. We set it to 13 as we have 11 CPUs available in our compute targets. Multiple Ray worker processes parallelizes agent training and helps in achieving our goal faster. \n", - "\n", - "```\n", - "Number of CPUs in the compute cluster = 6 * 2 = 12 CPUs over 2 nodes\n", - "Number of CPUs available = (Number of CPUs in the compute cluster) - (1 CPU for head node) = 12 - 1 = 11\n", - "```" + "compute target, number of nodes, and environment image to use." ] }, { @@ -265,7 +281,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646162435310 + "logged": 1683264835679 } }, "outputs": [], @@ -282,16 +298,12 @@ "aml_run_config_ml.node_count = 2\n", "aml_run_config_ml.environment = ray_environment\n", "\n", - "training_algorithm = \"IMPALA\"\n", - "rl_environment = \"PongNoFrameskip-v4\"\n", "script_name='pong_rllib.py'\n", + "config_name='pong-impala-vectorized.yaml'\n", "\n", "command=[\n", " 'python', script_name,\n", - " '--run', training_algorithm,\n", - " '--env', rl_environment,\n", - " '--config', '\\'{\"num_gpus\": 1, \"num_workers\": 11}\\'',\n", - " '--stop', '\\'{\"episode_reward_mean\": 18, \"time_total_s\": 3600}\\''\n", + " '--config', config_name\n", "]\n", "\n", "config = ScriptRunConfig(source_directory='./files',\n", @@ -305,25 +317,34 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Training script\n", - "As recommended in [RLlib](https://ray.readthedocs.io/en/latest/rllib.html) documentations, we use Ray [Tune](https://ray.readthedocs.io/en/latest/tune.html) API to run the training algorithm. All the RLlib built-in trainers are compatible with the Tune API. Here we use tune.run() to execute a built-in training algorithm. For convenience, down below you can see part of the entry script where we make this call.\n", - "\n", - "```python\n", - " tune.run(\n", - " run_or_experiment=args.run,\n", - " config={\n", - " \"env\": args.env,\n", - " \"num_gpus\": args.config[\"num_gpus\"],\n", - " \"num_workers\": args.config[\"num_workers\"],\n", - " \"callbacks\": {\"on_train_result\": callbacks.on_train_result},\n", - " \"sample_batch_size\": 50,\n", - " \"train_batch_size\": 1000,\n", - " \"num_sgd_iter\": 2,\n", - " \"num_data_loader_buffers\": 2,\n", - " \"model\": {\"dim\": 42},\n", - " },\n", - " stop=args.stop,\n", - " local_dir='./logs')\n", + "### Training configuration\n", + "All training parameters (including the Reinforcement Learning algorithm) are set through a single configuration file. For this example we'll be using the IMPALA algorithm to train an agent to play Atari Pong.\n", + "We set `num_workers` to 11 because we have 11 CPUs available for worker nodes (6 CPUs on each of 2 machines, with 1 CPU consumed as a head node).\n", + "We set `episode_reward_mean` (under `stop`) to 10 so that we terminate the run once we achieve a reward score of 10.\n", + "\n", + "Here is the configuration we are using for this example:\n", + "\n", + "```yaml\n", + "pong:\n", + " env: ALE/Pong-v5\n", + " run: IMPALA\n", + " config:\n", + " num_workers: 11\n", + " num_gpus: 1\n", + " rollout_fragment_length: 50\n", + " train_batch_size: 1000\n", + " num_sgd_iter: 2\n", + " num_multi_gpu_tower_stacks: 2\n", + " env_config:\n", + " frameskip: 1\n", + " full_action_space: false\n", + " repeat_action_probability: 0.0\n", + " stop:\n", + " episode_reward_mean: 10\n", + " total_time_s: 3600\n", + " model:\n", + " dim: 42\n", + "\n", "```" ] }, @@ -339,7 +360,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683056781459 + } + }, "outputs": [], "source": [ "from azureml.widgets import RunDetails\n", @@ -359,7 +384,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683056781759 + } + }, "outputs": [], "source": [ "# Uncomment line below to cancel the run\n", @@ -379,7 +408,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1682525323059 + } + }, "outputs": [], "source": [ "training_run.wait_for_completion()" @@ -399,7 +432,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683064583273 + } + }, "outputs": [], "source": [ "# Get the reward metrics from training_run\n", @@ -416,7 +453,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1682445012908 + } + }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", @@ -431,7 +472,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We observe that during the training over multiple episodes, the agent learns to win the Pong game against opponent with our target of 18 points in each episode of 21 points.\n", + "We observe that during the training over multiple episodes, the agent learns to win the Pong game against opponent with our target of 10 points in each episode of 21 points.\n", "**Congratulations!! You have trained your Pong agent to win a game.**" ] }, @@ -446,7 +487,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1682445012927 + } + }, "outputs": [], "source": [ "# To archive the created experiment:\n", @@ -456,14 +501,6 @@ "#head_compute_target.delete()\n", "#worker_compute_target.delete()" ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Next\n", - "In this example, you learned how to solve distributed reinforcement learning training problems using head and worker compute targets. This was an introductory tutorial on Reinforement Learning in Azure Machine Learning service offering. We would love to hear your feedback to build the features you need!" - ] } ], "metadata": { @@ -494,7 +531,17 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.8.5" + }, + "microsoft": { + "host": { + "AzureML": { + "notebookHasBeenCompleted": true + } + }, + "ms_spell_check": { + "ms_spell_check_language": "en" + } }, "notice": "Copyright (c) Microsoft Corporation. All rights reserved.\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00afLicensed under the MIT License.\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00af ", "nteract": { diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/cartpole_ci.ipynb b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/cartpole_ci.ipynb index d174dc114..9790e0bab 100644 --- a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/cartpole_ci.ipynb +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/cartpole_ci.ipynb @@ -84,7 +84,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646344676671 + "logged": 1683062935076 } }, "outputs": [], @@ -106,7 +106,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646344680982 + "logged": 1683062936280 } }, "outputs": [], @@ -133,7 +133,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646344684217 + "logged": 1683062936485 } }, "outputs": [], @@ -160,7 +160,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646344690768 + "logged": 1683062937126 } }, "outputs": [], @@ -212,14 +212,14 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646344835579 + "logged": 1683062937499 } }, "outputs": [], "source": [ "from azureml.core.experiment import Experiment\n", "\n", - "experiment_name = 'CartPole-v0-CI'\n", + "experiment_name = 'CartPole-v1-CI'\n", "experiment = Experiment(workspace=ws, name=experiment_name)" ] }, @@ -228,7 +228,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646346293902 + "logged": 1683064044718 }, "jupyter": { "outputs_hidden": false, @@ -282,7 +282,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347120585 + "logged": 1683064046594 }, "jupyter": { "outputs_hidden": false, @@ -300,18 +300,10 @@ "from azureml.core import RunConfiguration, ScriptRunConfig, Experiment\n", "from azureml.core.runconfig import DockerConfiguration, RunConfiguration\n", "\n", - "training_algorithm = 'PPO'\n", - "rl_environment = 'CartPole-v0'\n", - "\n", + "config_name = 'cartpole-ppo.yaml'\n", "script_name = 'cartpole_training.py'\n", "script_arguments = [\n", - " '--run', training_algorithm,\n", - " '--env', rl_environment,\n", - " '--config', '{\"num_gpus\": 0, \"num_workers\": 1}',\n", - " '--stop', '{\"episode_reward_mean\": 200, \"time_total_s\": 300}',\n", - " '--checkpoint-freq', '2',\n", - " '--checkpoint-at-end',\n", - " '--local-dir', './logs'\n", + " '--config', config_name\n", "]\n", "\n", "aml_run_config_ml = RunConfiguration(communicator='OpenMpi')\n", @@ -331,43 +323,35 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Training script\n", - "\n", - "As recommended in RLlib documentations, we use Ray Tune API to run the training algorithm. All the RLlib built-in trainers are compatible with the Tune API. Here we use `tune.run()` to execute a built-in training algorithm. For convenience, down below you can see part of the entry script where we make this call.\n", - "\n", - "This is the list of parameters we are passing into `tune.run()` via the `script_params` parameter:\n", - "\n", - "- `run_or_experiment`: name of the [built-in algorithm](https://ray.readthedocs.io/en/latest/rllib-algorithms.html#rllib-algorithms), 'PPO' in our example,\n", - "- `config`: Algorithm-specific configuration. This includes specifying the environment, `env`, which in our example is the gym **[CartPole-v0](https://www.gymlibrary.dev/environments/classic_control/cart_pole/)** environment,\n", - "- `stop`: stopping conditions, which could be any of the metrics returned by the trainer. Here we use \"mean of episode reward\", and \"total training time in seconds\" as stop conditions, and\n", - "- `checkpoint_freq` and `checkpoint_at_end`: Frequency of taking checkpoints (number of training iterations between checkpoints), and if a checkpoint should be taken at the end.\n", - "\n", - "We also specify the `local_dir`, the directory in which the training logs, checkpoints and other training artificats will be recorded. \n", - "\n", - "See [RLlib Training APIs](https://ray.readthedocs.io/en/latest/rllib-training.html#rllib-training-apis) for more details, and also [Training (tune.run, tune.Experiment)](https://ray.readthedocs.io/en/latest/tune/api_docs/execution.html#training-tune-run-tune-experiment) for the complete list of parameters.\n", - "\n", - "```python\n", - "import os\n", - "import ray\n", - "import ray.tune as tune\n", - "\n", - "if __name__ == \"__main__\":\n", - "\n", - " # parse arguments ...\n", - " \n", - " # Start ray head (single node)\n", - " os.system('ray start --head')\n", - " ray.init(address='auto')\n", - "\n", - " # Run training task using tune.run\n", - " tune.run(\n", - " run_or_experiment=args.run,\n", - " config=dict(args.config, env=args.env),\n", - " stop=args.stop,\n", - " checkpoint_freq=args.checkpoint_freq,\n", - " checkpoint_at_end=args.checkpoint_at_end,\n", - " local_dir=args.local_dir\n", - " )\n", + "### Training configuration\n", + "\n", + "This is the training configuration (in yaml) that we use to train an agent to solve the CartPole problem using\n", + "the PPO algorithm.\n", + "\n", + "```yaml\n", + "cartpole-ppo:\n", + " env: CartPole-v1\n", + " run: PPO\n", + " stop:\n", + " episode_reward_mean: 475\n", + " time_total_s: 300\n", + " checkpoint_config:\n", + " checkpoint_frequency: 2\n", + " checkpoint_at_end: true\n", + " config:\n", + " # Works for both torch and tf.\n", + " framework: torch\n", + " gamma: 0.99\n", + " lr: 0.0003\n", + " num_workers: 1\n", + " observation_filter: MeanStdFilter\n", + " num_sgd_iter: 6\n", + " vf_loss_coeff: 0.01\n", + " model:\n", + " fcnet_hiddens: [32]\n", + " fcnet_activation: linear\n", + " vf_share_layers: true\n", + " enable_connectors: true\n", "```" ] }, @@ -386,7 +370,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347127671 + "logged": 1683064049813 } }, "outputs": [], @@ -408,7 +392,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683064050024 + } + }, "outputs": [], "source": [ "# Uncomment line below to cancel the run\n", @@ -430,7 +418,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347318682 + "logged": 1683064304728 } }, "outputs": [], @@ -463,7 +451,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347328505 + "logged": 1683064305251 } }, "outputs": [], @@ -471,7 +459,7 @@ "from os import path\n", "from distutils import dir_util\n", "\n", - "training_artifacts_path = path.join(\"logs\", training_algorithm)\n", + "training_artifacts_path = path.join(\"logs\", \"cartpole-ppo\")\n", "print(\"Training artifacts path:\", training_artifacts_path)\n", "\n", "if path.exists(training_artifacts_path):\n", @@ -493,19 +481,20 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347334571 + "logged": 1683064305283 } }, "outputs": [], "source": [ - "# A helper function to find checkpoint files in a directory\n", + "# A helper function to find all of the checkpoint directories located within a larger directory tree\n", "def find_checkpoints(file_path):\n", " print(\"Looking in path:\", file_path)\n", " checkpoints = []\n", - " for root, _, files in os.walk(file_path):\n", - " for name in files:\n", - " if os.path.basename(root).startswith('checkpoint_'):\n", - " checkpoints.append(path.join(root, name))\n", + " for root, dirs, files in os.walk(file_path):\n", + " trimmed_root = root[len(file_path)+1:]\n", + " for name in dirs:\n", + " if name.startswith('checkpoint_'):\n", + " checkpoints.append(path.join(trimmed_root, name))\n", " return checkpoints" ] }, @@ -514,7 +503,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347337724 + "logged": 1683064305305 } }, "outputs": [], @@ -522,16 +511,16 @@ "# Find checkpoints and last checkpoint number\n", "checkpoint_files = find_checkpoints(training_artifacts_path)\n", "\n", - "checkpoint_numbers = []\n", - "for file in checkpoint_files:\n", - " file = os.path.basename(file)\n", - " if file.startswith('checkpoint-') and not file.endswith('.tune_metadata'):\n", - " checkpoint_numbers.append(int(file.split('-')[1]))\n", + "last_checkpoint_path = None\n", + "last_checkpoint_number = -1\n", + "for checkpoint_file in checkpoint_files:\n", + " checkpoint_number = int(os.path.basename(checkpoint_file).split('_')[1])\n", + " if checkpoint_number > last_checkpoint_number:\n", + " last_checkpoint_path = checkpoint_file\n", + " last_checkpoint_number = checkpoint_number\n", "\n", - "print(\"Checkpoints:\", checkpoint_numbers)\n", - "\n", - "last_checkpoint_number = max(checkpoint_numbers)\n", - "print(\"Last checkpoint number:\", last_checkpoint_number)" + "print(\"Last checkpoint number:\", last_checkpoint_number)\n", + "print(\"Last checkpoint path:\", last_checkpoint_path)" ] }, { @@ -546,17 +535,16 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347346085 + "logged": 1683064305331 } }, "outputs": [], "source": [ "# Upload the checkpoint files and create a DataSet\n", - "from azureml.core import Dataset\n", + "from azureml.data.dataset_factory import FileDatasetFactory\n", "\n", "datastore = ws.get_default_datastore()\n", - "checkpoint_dataref = datastore.upload_files(checkpoint_files, target_path='cartpole_checkpoints_' + training_run.id, overwrite=True)\n", - "checkpoint_ds = Dataset.File.from_files(checkpoint_dataref)" + "checkpoint_ds = FileDatasetFactory.upload_directory(training_artifacts_path, (datastore, 'cartpole_checkpoints_' + training_run.id), overwrite=False, show_progress=True)" ] }, { @@ -571,7 +559,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347354726 + "logged": 1683064305353 } }, "outputs": [], @@ -598,7 +586,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347414835 + "logged": 1683064305371 }, "jupyter": { "outputs_hidden": false, @@ -614,23 +602,18 @@ "source": [ "ray_environment_name = 'cartpole-ray-ci'\n", "\n", - "experiment_name = 'CartPole-v0-CI'\n", - "training_algorithm = 'PPO'\n", - "rl_environment = 'CartPole-v0'\n", + "experiment_name = 'CartPole-v1-CI'\n", "\n", "experiment = Experiment(workspace=ws, name=experiment_name)\n", "ray_environment = Environment.get(workspace=ws, name=ray_environment_name)\n", "\n", "script_name = 'cartpole_rollout.py'\n", "script_arguments = [\n", - " '--run', training_algorithm,\n", - " '--env', rl_environment,\n", - " '--config', '{}',\n", " '--steps', '2000',\n", - " '--checkpoint-number', str(last_checkpoint_number),\n", - " '--no-render',\n", - " '--artifacts-dataset', checkpoint_ds.as_named_input('artifacts_dataset'),\n", - " '--artifacts-path', checkpoint_ds.as_named_input('artifacts_path').as_mount()\n", + " '--checkpoint', last_checkpoint_path,\n", + " '--algo', 'PPO',\n", + " '--render', 'false',\n", + " '--dataset_path', checkpoint_ds.as_named_input('dataset_path').as_mount()\n", "]\n", "\n", "aml_run_config_ml = RunConfiguration(communicator='OpenMpi')\n", @@ -653,7 +636,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "And then, similar to the training section, we can monitor the real-time progress of the rollout run and its chid as follows. If you browse logs of the child run you can see the evaluation results recorded in driver_log.txt file. Note that you may need to wait several minutes before these results become available." + "And then, similar to the training section, we can monitor the real-time progress of the rollout run and its chid as follows. If you browse logs of the child run you can see the evaluation results recorded in std_log_process_0.txt file. Note that you may need to wait several minutes before these results become available." ] }, { @@ -661,7 +644,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347429626 + "logged": 1683064305399 } }, "outputs": [], @@ -679,7 +662,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683064305419 + } + }, "outputs": [], "source": [ "# Uncomment line below to cancel the run\n", @@ -698,7 +685,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683064305437 + } + }, "outputs": [], "source": [ "# To archive the created experiment:\n", @@ -750,13 +741,16 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.8.5" }, "microsoft": { "host": { "AzureML": { "notebookHasBeenCompleted": true } + }, + "ms_spell_check": { + "ms_spell_check_language": "en" } }, "notice": "Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License.", diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole-ppo.yaml b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole-ppo.yaml new file mode 100644 index 000000000..2c2d5cce9 --- /dev/null +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole-ppo.yaml @@ -0,0 +1,23 @@ +cartpole-ppo: + env: CartPole-v1 + run: PPO + stop: + episode_reward_mean: 475 + time_total_s: 300 + checkpoint_config: + checkpoint_frequency: 2 + checkpoint_at_end: true + config: + # Works for both torch and tf. + framework: torch + gamma: 0.99 + lr: 0.0003 + num_workers: 1 + observation_filter: MeanStdFilter + num_sgd_iter: 6 + vf_loss_coeff: 0.01 + model: + fcnet_hiddens: [32] + fcnet_activation: linear + vf_share_layers: true + enable_connectors: true diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole_rollout.py b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole_rollout.py index 0c7f09885..b825d02f8 100644 --- a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole_rollout.py +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole_rollout.py @@ -1,121 +1,108 @@ import os import sys +import argparse -import ray -from ray.rllib import rollout -from ray.tune.registry import get_trainable_cls +from ray.rllib.evaluate import RolloutSaver, rollout +from ray_on_aml.core import Ray_On_AML +import ray.cloudpickle as cloudpickle +from ray.tune.utils import merge_dicts +from ray.tune.registry import get_trainable_cls, _global_registry, ENV_CREATOR from azureml.core import Run - from utils import callbacks - -def run_rollout(args, parser): - - config = args.config - if not args.env: - if not config.get("env"): - parser.error("the following arguments are required: --env") - args.env = config.get("env") - - # Create the Trainer from config. - cls = get_trainable_cls(args.run) - agent = cls(env=args.env, config=config) - - # Load state from checkpoint. - agent.restore(args.checkpoint) - num_steps = int(args.steps) - num_episodes = int(args.episodes) - - # Determine the video output directory. - use_arg_monitor = False - try: - args.video_dir - except AttributeError: - print("There is no such attribute: args.video_dir") - use_arg_monitor = True - - video_dir = None - if not use_arg_monitor: - if args.monitor: - video_dir = os.path.join("./logs", "video") - elif args.video_dir: - video_dir = os.path.expanduser(args.video_dir) +import collections +import copy +import gymnasium as gym +import json +from pathlib import Path + + +def run_rollout(checkpoint, algo, render, steps, episodes): + config_dir = os.path.dirname(checkpoint) + config_path = os.path.join(config_dir, "params.pkl") + config = None + + # Try parent directory. + if not os.path.exists(config_path): + config_path = os.path.join(config_dir, "../params.pkl") + + # Load the config from pickled. + if os.path.exists(config_path): + with open(config_path, "rb") as f: + config = cloudpickle.load(f) + # If no pkl file found, require command line `--config`. + else: + raise ValueError("Could not find params.pkl in either the checkpoint dir or its parent directory") + + # Make sure worker 0 has an Env. + config["create_env_on_driver"] = True + + # Merge with `evaluation_config` (first try from command line, then from + # pkl file). + evaluation_config = copy.deepcopy(config.get("evaluation_config", {})) + config = merge_dicts(config, evaluation_config) + env = config.get("env") + + # Make sure we have evaluation workers. + if not config.get("evaluation_num_workers"): + config["evaluation_num_workers"] = config.get("num_workers", 0) + if not config.get("evaluation_duration"): + config["evaluation_duration"] = 1 + + # Hard-override this as it raises a warning by Algorithm otherwise. + # Makes no sense anyways, to have it set to None as we don't call + # `Algorithm.train()` here. + config["evaluation_interval"] = 1 + + # Rendering settings. + config["render_env"] = render + + # Create the Algorithm from config. + cls = get_trainable_cls(algo) + algorithm = cls(env=env, config=config) + + # Load state from checkpoint, if provided. + if checkpoint: + algorithm.restore(checkpoint) # Do the actual rollout. - with rollout.RolloutSaver( - args.out, - args.use_shelve, - write_update_file=args.track_progress, - target_steps=num_steps, - target_episodes=num_episodes, - save_info=args.save_info) as saver: - if use_arg_monitor: - rollout.rollout( - agent, - args.env, - num_steps, - num_episodes, - saver, - args.no_render, - args.monitor) - else: - rollout.rollout( - agent, args.env, - num_steps, - num_episodes, - saver, - args.no_render, video_dir) + with RolloutSaver( + outfile=None, + use_shelve=False, + write_update_file=False, + target_steps=steps, + target_episodes=episodes, + save_info=False, + ) as saver: + rollout(algorithm, env, steps, episodes, saver, not render) + algorithm.stop() if __name__ == "__main__": - # Start ray head (single node) - os.system('ray start --head') - ray.init(address='auto') - - # Add positional argument - serves as placeholder for checkpoint - argvc = sys.argv[1:] - argvc.insert(0, 'checkpoint-placeholder') - - # Parse arguments - rollout_parser = rollout.create_parser() - - rollout_parser.add_argument( - '--checkpoint-number', required=False, type=int, default=1, - help='Checkpoint number of the checkpoint from which to roll out') - - rollout_parser.add_argument( - '--artifacts-dataset', required=True, - help='The checkpoints artifacts dataset') - - rollout_parser.add_argument( - '--artifacts-path', required=True, - help='The checkpoints artifacts path') - - args = rollout_parser.parse_args(argvc) - - # Get a handle to run - run = Run.get_context() - - # Get handles to the tarining artifacts dataset and mount path - artifacts_dataset = run.input_datasets['artifacts_dataset'] - artifacts_path = run.input_datasets['artifacts_path'] - - # Find checkpoint file to be evaluated - checkpoint_id = '-' + str(args.checkpoint_number) - checkpoint_files = list(filter( - lambda filename: filename.endswith(checkpoint_id), - artifacts_dataset.to_path())) - - checkpoint_file = checkpoint_files[0] - if checkpoint_file[0] == '/': - checkpoint_file = checkpoint_file[1:] - checkpoint = os.path.join(artifacts_path, checkpoint_file) - print('Checkpoint:', checkpoint) - - # Set rollout checkpoint - args.checkpoint = checkpoint - - # Start rollout - run_rollout(args, rollout_parser) + ray_on_aml = Ray_On_AML() + ray = ray_on_aml.getRay() + if ray: + parser = argparse.ArgumentParser() + parser.add_argument('--dataset_path', required=True, help='Path to artifacts dataset') + parser.add_argument('--checkpoint', required=True, help='Name of checkpoint file directory') + parser.add_argument('--algo', required=True, help='Name of RL algorithm') + parser.add_argument('--render', default=False, required=False, help='True to render') + parser.add_argument('--steps', required=False, type=int, help='Number of steps to run') + parser.add_argument('--episodes', required=False, type=int, help='Number of episodes to run') + args = parser.parse_args() + + # Get a handle to run + run = Run.get_context() + + # Get handles to the tarining artifacts dataset and mount path + dataset_path = run.input_datasets['dataset_path'] + + # Find checkpoint file to be evaluated + checkpoint = os.path.join(dataset_path, args.checkpoint) + print('Checkpoint:', checkpoint) + + # Start rollout + ray.init(address='auto') + run_rollout(checkpoint, args.algo, args.render, args.steps, args.episodes) diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole_training.py b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole_training.py index 1a0e3c490..2322e69a6 100644 --- a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole_training.py +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/cartpole_training.py @@ -1,32 +1,34 @@ -import ray -from ray.rllib import train -from ray import tune -import os - +from ray_on_aml.core import Ray_On_AML +import yaml +from ray.tune.tune import run_experiments from utils import callbacks +import argparse if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--config', help='Path to yaml configuration file') + args = parser.parse_args() - # Parse arguments and add callbacks to config - train_parser = train.create_parser() - - args = train_parser.parse_args() - args.config["callbacks"] = {"on_train_result": callbacks.on_train_result} - - # Trace if video capturing is on - if 'monitor' in args.config and args.config['monitor']: - print("Video capturing is ON!") + ray_on_aml = Ray_On_AML() + ray = ray_on_aml.getRay() + if ray: # in the headnode + ray.init(address="auto") + print("Configuring run from file: ", args.config) + experiment_config = None + with open(args.config, "r") as file: + experiment_config = yaml.safe_load(file) - # Start ray head (single node) - os.system('ray start --head') - ray.init(address='auto') + # Set local_dir in each experiment configuration to ensure generated logs get picked up + # Also set monitor to ensure videos are captured + for experiment_name, experiment in experiment_config.items(): + experiment["storage_path"] = "./logs" + experiment['config']['monitor'] = True + print(f'Config: {experiment_config}') - # Run training task using tune.run - tune.run( - run_or_experiment=args.run, - config=dict(args.config, env=args.env), - stop=args.stop, - checkpoint_freq=args.checkpoint_freq, - checkpoint_at_end=args.checkpoint_at_end, - local_dir=args.local_dir - ) + trials = run_experiments( + experiment_config, + callbacks=[callbacks.TrialCallback()], + verbose=2 + ) +else: + print("in worker node") diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/docker/Dockerfile b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/docker/Dockerfile index ab796e884..dd37010b5 100644 --- a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/docker/Dockerfile +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/docker/Dockerfile @@ -1,19 +1,27 @@ FROM mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04 -USER root -RUN conda install -c anaconda python=3.7 +RUN pip install ray-on-aml==0.2.4 \ + ray==2.4.0 \ + ray[rllib]==2.4.0 \ + mlflow==2.3.1 \ + azureml-defaults==1.50.0 \ + azureml-dataset-runtime[fuse,pandas]==1.50.0 \ + azureml-contrib-reinforcementlearning==1.50.0 \ + gputil==1.4.0 \ + scipy==1.9.1 \ + pyglet==2.0.6 \ + cloudpickle==2.2.1 \ + tensorflow==2.11.0 \ + tensorflow-probability==0.19.0 \ + torch \ + tabulate==0.9.0 \ + dm_tree==0.1.8 \ + lz4==4.3.2 \ + psutil==5.9.4 \ + setproctitle==1.3.2 \ + pygame==2.1.0 \ + gymnasium[classic_control]==0.26.3 \ + gym[classic_control]==0.26.2 -RUN pip install ray-on-aml==0.1.6 -RUN pip install gym[atari]==0.19.0 -RUN pip install gym[accept-rom-license]==0.19.0 -RUN pip install ale-py==0.7.0 -RUN pip install azureml-core -RUN pip install azureml-dataset-runtime -RUN pip install ray==0.8.7 -RUN pip install ray[rllib,tune,serve]==0.8.7 -RUN pip install tensorflow==1.14.0 -RUN pip install 'msrest<0.7.0' - -RUN apt-get update -RUN apt-get install -y jq -RUN apt-get install -y rsync +# Display the exact versions we have installed +RUN pip freeze diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/utils/callbacks.py b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/utils/callbacks.py index f34a4e8c8..f296f5770 100644 --- a/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/utils/callbacks.py +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/files/utils/callbacks.py @@ -3,15 +3,20 @@ ''' from azureml.core import Run +from ray import tune +from ray.tune import Callback +from ray.air import session -def on_train_result(info): - '''Callback on train result to record metrics returned by trainer. - ''' - run = Run.get_context() - run.log( - name='episode_reward_mean', - value=info["result"]["episode_reward_mean"]) - run.log( - name='episodes_total', - value=info["result"]["episodes_total"]) +class TrialCallback(Callback): + + def on_trial_result(self, iteration, trials, trial, result, **info): + '''Callback on train result to record metrics returned by trainer. + ''' + run = Run.get_context() + run.log( + name='episode_reward_mean', + value=result["episode_reward_mean"]) + run.log( + name='episodes_total', + value=result["episodes_total"]) diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/cartpole_sc.ipynb b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/cartpole_sc.ipynb index 6b936c6a6..4ebfdcdb0 100644 --- a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/cartpole_sc.ipynb +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/cartpole_sc.ipynb @@ -84,7 +84,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646347616697 + "logged": 1683056824182 } }, "outputs": [], @@ -107,7 +107,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646429058500 + "logged": 1683056825821 } }, "outputs": [], @@ -136,7 +136,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646359152101 + "logged": 1683056826903 } }, "outputs": [], @@ -181,14 +181,14 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646348040613 + "logged": 1683056827252 } }, "outputs": [], "source": [ "from azureml.core.experiment import Experiment\n", "\n", - "experiment_name = 'CartPole-v0-SC'\n", + "experiment_name = 'CartPole-v1-SC'\n", "experiment = Experiment(workspace=ws, name=experiment_name)" ] }, @@ -250,7 +250,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646437786449 + "logged": 1683059658819 }, "jupyter": { "outputs_hidden": false, @@ -264,44 +264,31 @@ }, "outputs": [], "source": [ + "from azureml.core import Environment\n", "from azureml.core import RunConfiguration, ScriptRunConfig, Experiment\n", "from azureml.core.runconfig import DockerConfiguration, RunConfiguration\n", "\n", - "training_algorithm = \"PPO\"\n", - "rl_environment = \"CartPole-v0\"\n", - "video_capture = True\n", - "if video_capture:\n", - " algorithm_config = '\\'{\"num_gpus\": 0, \"num_workers\": 1, \"monitor\": true}\\''\n", - "else:\n", - " algorithm_config = '\\'{\"num_gpus\": 0, \"num_workers\": 1, \"monitor\": false}\\''\n", - "\n", + "config_name = 'cartpole-ppo.yaml'\n", "script_name = 'cartpole_training.py'\n", + "video_capture = True\n", "script_arguments = [\n", - " '--run', training_algorithm,\n", - " '--env', rl_environment,\n", - " '--stop', '\\'{\"episode_reward_mean\": 200, \"time_total_s\": 300}\\'',\n", - " '--config', algorithm_config,\n", - " '--checkpoint-freq', '2',\n", - " '--checkpoint-at-end',\n", - " '--local-dir', './logs'\n", + " '--config', config_name\n", "]\n", - "\n", - "ray_environment = Environment.get(ws, name=ray_environment_name)\n", - "run_config = RunConfiguration(communicator='OpenMpi')\n", - "run_config.target = compute_target\n", - "run_config.node_count = 1\n", - "run_config.environment = ray_environment\n", "command=[\"python\", script_name, *script_arguments]\n", "\n", + "aml_run_config_ml = RunConfiguration(communicator='OpenMpi')\n", + "aml_run_config_ml.target = compute_target\n", + "aml_run_config_ml.node_count = 1\n", + "aml_run_config_ml.environment = ray_environment\n", + "\n", "if video_capture:\n", " command = [\"xvfb-run -s '-screen 0 640x480x16 -ac +extension GLX +render' \"] + command\n", - " run_config.environment_variables[\"SDL_VIDEODRIVER\"] = \"dummy\"\n", + " aml_run_config_ml.environment_variables[\"SDL_VIDEODRIVER\"] = \"dummy\"\n", "\n", "training_config = ScriptRunConfig(source_directory='./files',\n", - " command=command,\n", - " run_config = run_config\n", - " )\n", - "\n", + " command=command,\n", + " run_config = aml_run_config_ml\n", + " )\n", "training_run = experiment.submit(training_config)" ] }, @@ -309,42 +296,35 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Training script\n", - "\n", - "As recommended in RLlib documentations, we use Ray Tune API to run the training algorithm. All the RLlib built-in trainers are compatible with the Tune API. Here we use `tune.run()` to execute a built-in training algorithm. For convenience, down below you can see part of the entry script where we make this call.\n", + "### Training configuration\n", "\n", - "This is the list of parameters we are passing into `tune.run()` via the `script_params` parameter:\n", + "This is the training configuration (in yaml) that we use to train an agent to solve the CartPole problem using\n", + "the PPO algorithm.\n", "\n", - "- `run_or_experiment`: name of the [built-in algorithm](https://ray.readthedocs.io/en/latest/rllib-algorithms.html#rllib-algorithms), 'PPO' in our example,\n", - "- `config`: Algorithm-specific configuration. This includes specifying the environment, `env`, which in our example is the gym **[CartPole-v0](https://www.gymlibrary.dev/environments/classic_control/cart_pole/)** environment,\n", - "- `stop`: stopping conditions, which could be any of the metrics returned by the trainer. Here we use \"mean of episode reward\", and \"total training time in seconds\" as stop conditions, and\n", - "- `checkpoint_freq` and `checkpoint_at_end`: Frequency of taking checkpoints (number of training iterations between checkpoints), and if a checkpoint should be taken at the end.\n", - "\n", - "We also specify the `local_dir`, the directory in which the training logs, checkpoints and other training artificats will be recorded. \n", - "\n", - "See [RLlib Training APIs](https://ray.readthedocs.io/en/latest/rllib-training.html#rllib-training-apis) for more details, and also [Training (tune.run, tune.Experiment)](https://ray.readthedocs.io/en/latest/tune/api_docs/execution.html#training-tune-run-tune-experiment) for the complete list of parameters.\n", - "\n", - "```python\n", - "import ray\n", - "import ray.tune as tune\n", - "\n", - "if __name__ == \"__main__\":\n", - "\n", - " # parse arguments ...\n", - " \n", - " # Start ray head (single node)\n", - " os.system('ray start --head')\n", - " ray.init(address='auto')\n", - "\n", - " # Run training task using tune.run\n", - " tune.run(\n", - " run_or_experiment=args.run,\n", - " config=dict(args.config, env=args.env),\n", - " stop=args.stop,\n", - " checkpoint_freq=args.checkpoint_freq,\n", - " checkpoint_at_end=args.checkpoint_at_end,\n", - " local_dir=args.local_dir\n", - " )\n", + "```yaml\n", + "cartpole-ppo:\n", + " env: CartPole-v1\n", + " run: PPO\n", + " stop:\n", + " episode_reward_mean: 475\n", + " time_total_s: 300\n", + " checkpoint_config:\n", + " checkpoint_frequency: 2\n", + " checkpoint_at_end: true\n", + " config:\n", + " # Works for both torch and tf.\n", + " framework: torch\n", + " gamma: 0.99\n", + " lr: 0.0003\n", + " num_workers: 1\n", + " observation_filter: MeanStdFilter\n", + " num_sgd_iter: 6\n", + " vf_loss_coeff: 0.01\n", + " model:\n", + " fcnet_hiddens: [32]\n", + " fcnet_activation: linear\n", + " vf_share_layers: true\n", + " enable_connectors: true\n", "```" ] }, @@ -362,7 +342,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646437627002 + "logged": 1683060289002 } }, "outputs": [], @@ -403,7 +383,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683060297005 + } + }, "outputs": [], "source": [ "training_run.wait_for_completion()" @@ -420,7 +404,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683060517858 + } + }, "outputs": [], "source": [ "from azureml.core import Run\n", @@ -441,7 +429,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646437652309 + "logged": 1683060521847 } }, "outputs": [], @@ -449,7 +437,7 @@ "from os import path\n", "from distutils import dir_util\n", "\n", - "training_artifacts_path = path.join(\"logs\", training_algorithm)\n", + "training_artifacts_path = path.join(\"logs\", \"cartpole-ppo\")\n", "print(\"Training artifacts path:\", training_artifacts_path)\n", "\n", "if path.exists(training_artifacts_path):\n", @@ -475,7 +463,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646437657045 + "logged": 1683060867182 } }, "outputs": [], @@ -514,7 +502,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646437690241 + "logged": 1683060871682 } }, "outputs": [], @@ -535,7 +523,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646437692954 + "logged": 1683060900828 } }, "outputs": [], @@ -543,7 +531,8 @@ "first_movie = mp4_files[0] if len(mp4_files) > 0 else None\n", "print(\"First movie:\", first_movie)\n", "\n", - "display_movie(first_movie)" + "if first_movie:\n", + " display_movie(first_movie)" ] }, { @@ -558,7 +547,7 @@ "execution_count": null, "metadata": { "gather": { - "logged": 1646437717147 + "logged": 1683060914790 } }, "outputs": [], @@ -566,7 +555,8 @@ "last_movie = mp4_files[-1] if len(mp4_files) > 0 else None\n", "print(\"Last movie:\", last_movie)\n", "\n", - "display_movie(last_movie)" + "if last_movie:\n", + " display_movie(last_movie)" ] }, { @@ -597,53 +587,65 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683061167899 + } + }, "outputs": [], "source": [ - "# A helper function to find checkpoint files in a directory\n", + "# A helper function to find all of the checkpoint directories located within a larger directory tree\n", "def find_checkpoints(file_path):\n", " print(\"Looking in path:\", file_path)\n", " checkpoints = []\n", - " for root, _, files in os.walk(file_path):\n", - " for name in files:\n", - " if os.path.basename(root).startswith('checkpoint_'):\n", - " checkpoints.append(path.join(root, name))\n", - " return checkpoints\n", - "\n", - "checkpoint_files = find_checkpoints(training_artifacts_path)" + " for root, dirs, files in os.walk(file_path):\n", + " trimmed_root = root[len(file_path)+1:]\n", + " for name in dirs:\n", + " if name.startswith('checkpoint_'):\n", + " checkpoints.append(path.join(trimmed_root, name))\n", + " return checkpoints" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683061170184 + } + }, "outputs": [], "source": [ "# Find checkpoints and last checkpoint number\n", - "checkpoint_numbers = []\n", - "for file in checkpoint_files:\n", - " file = os.path.basename(file)\n", - " if file.startswith('checkpoint-') and not file.endswith('.tune_metadata'):\n", - " checkpoint_numbers.append(int(file.split('-')[-1]))\n", + "checkpoint_files = find_checkpoints(training_artifacts_path)\n", "\n", - "print(\"Checkpoints:\", checkpoint_numbers)\n", + "last_checkpoint_path = None\n", + "last_checkpoint_number = -1\n", + "for checkpoint_file in checkpoint_files:\n", + " checkpoint_number = int(os.path.basename(checkpoint_file).split('_')[1])\n", + " if checkpoint_number > last_checkpoint_number:\n", + " last_checkpoint_path = checkpoint_file\n", + " last_checkpoint_number = checkpoint_number\n", "\n", - "last_checkpoint_number = max(checkpoint_numbers)\n", - "print(\"Last checkpoint number:\", last_checkpoint_number)" + "print(\"Last checkpoint number:\", last_checkpoint_number)\n", + "print(\"Last checkpoint path:\", last_checkpoint_path)" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683061176740 + } + }, "outputs": [], "source": [ "# Upload the checkpoint files and create a DataSet\n", - "from azureml.core import Dataset\n", + "from azureml.data.dataset_factory import FileDatasetFactory\n", "\n", "datastore = ws.get_default_datastore()\n", - "checkpoint_dataref = datastore.upload_files(checkpoint_files, target_path='cartpole_checkpoints_' + run_id, overwrite=True)\n", - "checkpoint_ds = Dataset.File.from_files(checkpoint_dataref)" + "checkpoint_ds = FileDatasetFactory.upload_directory(training_artifacts_path, (datastore, 'cartpole_checkpoints_' + training_run.id), overwrite=False, show_progress=True)" ] }, { @@ -657,54 +659,45 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683062377151 + } + }, "outputs": [], "source": [ "ray_environment_name = 'cartpole-ray-sc'\n", "\n", - "experiment_name = 'CartPole-v0-SC'\n", + "experiment_name = 'CartPole-v1-SC'\n", "training_algorithm = 'PPO'\n", - "rl_environment = 'CartPole-v0'\n", + "rl_environment = 'CartPole-v1'\n", "\n", "experiment = Experiment(workspace=ws, name=experiment_name)\n", "ray_environment = Environment.get(workspace=ws, name=ray_environment_name)\n", "\n", "script_name = 'cartpole_rollout.py'\n", - "video_capture = True\n", - "if video_capture:\n", - " script_arguments = ['--video-dir', './logs/video']\n", - "else:\n", - " script_arguments = ['--no-render']\n", - "script_arguments = script_arguments + [\n", - " '--run', training_algorithm,\n", - " '--env', rl_environment,\n", - " '--config', '{}',\n", + "script_arguments = [\n", " '--steps', '2000',\n", - " '--checkpoint-number', str(last_checkpoint_number),\n", - " '--artifacts-dataset', checkpoint_ds.as_named_input('artifacts_dataset'),\n", - " '--artifacts-path', checkpoint_ds.as_named_input('artifacts_path').as_mount()\n", + " '--checkpoint', last_checkpoint_path,\n", + " '--algo', 'PPO',\n", + " '--render', 'true',\n", + " '--dataset_path', checkpoint_ds.as_named_input('dataset_path').as_mount()\n", "]\n", "\n", - "command = [\"python\", script_name, *script_arguments]\n", - "\n", - "if video_capture:\n", - " command = [\"xvfb-run -s '-screen 0 640x480x16 -ac +extension GLX +render' \"] + command\n", - " run_config.environment_variables[\"SDL_VIDEODRIVER\"] = \"dummy\"\n", - "\n", - "run_config = RunConfiguration(communicator='OpenMpi')\n", - "run_config.target = compute_target\n", - "run_config.docker = DockerConfiguration(use_docker=True)\n", - "run_config.node_count = 1\n", - "run_config.environment = ray_environment\n", + "aml_run_config_ml = RunConfiguration(communicator='OpenMpi')\n", + "aml_run_config_ml.target = compute_target\n", + "aml_run_config_ml.node_count = 1\n", + "aml_run_config_ml.environment = ray_environment\n", + "aml_run_config_ml.data\n", "\n", "rollout_config = ScriptRunConfig(\n", " source_directory='./files',\n", - " command=command,\n", - " run_config=run_config\n", + " script=script_name,\n", + " arguments=script_arguments,\n", + " run_config = aml_run_config_ml\n", " )\n", - "\n", - "rollout_run = experiment.submit(rollout_config)\n", - "rollout_run" + " \n", + "rollout_run = experiment.submit(rollout_config)" ] }, { @@ -717,7 +710,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683062379999 + } + }, "outputs": [], "source": [ "RunDetails(rollout_run).show()" @@ -733,7 +730,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683062451723 + } + }, "outputs": [], "source": [ "# Uncomment line below to cancel the run\n", @@ -753,7 +754,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683062747822 + } + }, "outputs": [], "source": [ "# Download rollout artifacts\n", @@ -777,7 +782,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683062752847 + } + }, "outputs": [], "source": [ "# Look for the downloaded movie in local directory\n", @@ -797,13 +806,18 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "gather": { + "logged": 1683062763275 + } + }, "outputs": [], "source": [ "last_movie = mp4_files[-1] if len(mp4_files) > 0 else None\n", "print(\"Last movie:\", last_movie)\n", "\n", - "display_movie(last_movie)" + "if last_movie:\n", + " display_movie(last_movie)" ] }, { @@ -876,7 +890,17 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.8.5" + }, + "microsoft": { + "host": { + "AzureML": { + "notebookHasBeenCompleted": true + } + }, + "ms_spell_check": { + "ms_spell_check_language": "en" + } }, "notice": "Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License.", "nteract": { diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole-ppo.yaml b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole-ppo.yaml new file mode 100644 index 000000000..4d6b041e6 --- /dev/null +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole-ppo.yaml @@ -0,0 +1,24 @@ +cartpole-ppo: + env: CartPole-v1 + run: PPO + stop: + episode_reward_mean: 475 + time_total_s: 300 + checkpoint_config: + checkpoint_frequency: 2 + checkpoint_at_end: true + config: + # Works for both torch and tf. + framework: torch + gamma: 0.99 + lr: 0.0003 + num_workers: 1 + observation_filter: MeanStdFilter + num_sgd_iter: 6 + vf_loss_coeff: 0.01 + model: + fcnet_hiddens: [32] + fcnet_activation: linear + vf_share_layers: true + enable_connectors: true + render_env: true diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole_rollout.py b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole_rollout.py index 0c7f09885..b825d02f8 100644 --- a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole_rollout.py +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole_rollout.py @@ -1,121 +1,108 @@ import os import sys +import argparse -import ray -from ray.rllib import rollout -from ray.tune.registry import get_trainable_cls +from ray.rllib.evaluate import RolloutSaver, rollout +from ray_on_aml.core import Ray_On_AML +import ray.cloudpickle as cloudpickle +from ray.tune.utils import merge_dicts +from ray.tune.registry import get_trainable_cls, _global_registry, ENV_CREATOR from azureml.core import Run - from utils import callbacks - -def run_rollout(args, parser): - - config = args.config - if not args.env: - if not config.get("env"): - parser.error("the following arguments are required: --env") - args.env = config.get("env") - - # Create the Trainer from config. - cls = get_trainable_cls(args.run) - agent = cls(env=args.env, config=config) - - # Load state from checkpoint. - agent.restore(args.checkpoint) - num_steps = int(args.steps) - num_episodes = int(args.episodes) - - # Determine the video output directory. - use_arg_monitor = False - try: - args.video_dir - except AttributeError: - print("There is no such attribute: args.video_dir") - use_arg_monitor = True - - video_dir = None - if not use_arg_monitor: - if args.monitor: - video_dir = os.path.join("./logs", "video") - elif args.video_dir: - video_dir = os.path.expanduser(args.video_dir) +import collections +import copy +import gymnasium as gym +import json +from pathlib import Path + + +def run_rollout(checkpoint, algo, render, steps, episodes): + config_dir = os.path.dirname(checkpoint) + config_path = os.path.join(config_dir, "params.pkl") + config = None + + # Try parent directory. + if not os.path.exists(config_path): + config_path = os.path.join(config_dir, "../params.pkl") + + # Load the config from pickled. + if os.path.exists(config_path): + with open(config_path, "rb") as f: + config = cloudpickle.load(f) + # If no pkl file found, require command line `--config`. + else: + raise ValueError("Could not find params.pkl in either the checkpoint dir or its parent directory") + + # Make sure worker 0 has an Env. + config["create_env_on_driver"] = True + + # Merge with `evaluation_config` (first try from command line, then from + # pkl file). + evaluation_config = copy.deepcopy(config.get("evaluation_config", {})) + config = merge_dicts(config, evaluation_config) + env = config.get("env") + + # Make sure we have evaluation workers. + if not config.get("evaluation_num_workers"): + config["evaluation_num_workers"] = config.get("num_workers", 0) + if not config.get("evaluation_duration"): + config["evaluation_duration"] = 1 + + # Hard-override this as it raises a warning by Algorithm otherwise. + # Makes no sense anyways, to have it set to None as we don't call + # `Algorithm.train()` here. + config["evaluation_interval"] = 1 + + # Rendering settings. + config["render_env"] = render + + # Create the Algorithm from config. + cls = get_trainable_cls(algo) + algorithm = cls(env=env, config=config) + + # Load state from checkpoint, if provided. + if checkpoint: + algorithm.restore(checkpoint) # Do the actual rollout. - with rollout.RolloutSaver( - args.out, - args.use_shelve, - write_update_file=args.track_progress, - target_steps=num_steps, - target_episodes=num_episodes, - save_info=args.save_info) as saver: - if use_arg_monitor: - rollout.rollout( - agent, - args.env, - num_steps, - num_episodes, - saver, - args.no_render, - args.monitor) - else: - rollout.rollout( - agent, args.env, - num_steps, - num_episodes, - saver, - args.no_render, video_dir) + with RolloutSaver( + outfile=None, + use_shelve=False, + write_update_file=False, + target_steps=steps, + target_episodes=episodes, + save_info=False, + ) as saver: + rollout(algorithm, env, steps, episodes, saver, not render) + algorithm.stop() if __name__ == "__main__": - # Start ray head (single node) - os.system('ray start --head') - ray.init(address='auto') - - # Add positional argument - serves as placeholder for checkpoint - argvc = sys.argv[1:] - argvc.insert(0, 'checkpoint-placeholder') - - # Parse arguments - rollout_parser = rollout.create_parser() - - rollout_parser.add_argument( - '--checkpoint-number', required=False, type=int, default=1, - help='Checkpoint number of the checkpoint from which to roll out') - - rollout_parser.add_argument( - '--artifacts-dataset', required=True, - help='The checkpoints artifacts dataset') - - rollout_parser.add_argument( - '--artifacts-path', required=True, - help='The checkpoints artifacts path') - - args = rollout_parser.parse_args(argvc) - - # Get a handle to run - run = Run.get_context() - - # Get handles to the tarining artifacts dataset and mount path - artifacts_dataset = run.input_datasets['artifacts_dataset'] - artifacts_path = run.input_datasets['artifacts_path'] - - # Find checkpoint file to be evaluated - checkpoint_id = '-' + str(args.checkpoint_number) - checkpoint_files = list(filter( - lambda filename: filename.endswith(checkpoint_id), - artifacts_dataset.to_path())) - - checkpoint_file = checkpoint_files[0] - if checkpoint_file[0] == '/': - checkpoint_file = checkpoint_file[1:] - checkpoint = os.path.join(artifacts_path, checkpoint_file) - print('Checkpoint:', checkpoint) - - # Set rollout checkpoint - args.checkpoint = checkpoint - - # Start rollout - run_rollout(args, rollout_parser) + ray_on_aml = Ray_On_AML() + ray = ray_on_aml.getRay() + if ray: + parser = argparse.ArgumentParser() + parser.add_argument('--dataset_path', required=True, help='Path to artifacts dataset') + parser.add_argument('--checkpoint', required=True, help='Name of checkpoint file directory') + parser.add_argument('--algo', required=True, help='Name of RL algorithm') + parser.add_argument('--render', default=False, required=False, help='True to render') + parser.add_argument('--steps', required=False, type=int, help='Number of steps to run') + parser.add_argument('--episodes', required=False, type=int, help='Number of episodes to run') + args = parser.parse_args() + + # Get a handle to run + run = Run.get_context() + + # Get handles to the tarining artifacts dataset and mount path + dataset_path = run.input_datasets['dataset_path'] + + # Find checkpoint file to be evaluated + checkpoint = os.path.join(dataset_path, args.checkpoint) + print('Checkpoint:', checkpoint) + + # Start rollout + ray.init(address='auto') + run_rollout(checkpoint, args.algo, args.render, args.steps, args.episodes) diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole_training.py b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole_training.py index a083b7c33..2322e69a6 100644 --- a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole_training.py +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/cartpole_training.py @@ -1,32 +1,34 @@ -import os -import ray -from ray.rllib import train -from ray import tune - +from ray_on_aml.core import Ray_On_AML +import yaml +from ray.tune.tune import run_experiments from utils import callbacks +import argparse if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--config', help='Path to yaml configuration file') + args = parser.parse_args() - # Parse arguments and add callbacks to config - train_parser = train.create_parser() - - args = train_parser.parse_args() - args.config["callbacks"] = {"on_train_result": callbacks.on_train_result} - - # Trace if video capturing is on - if 'monitor' in args.config and args.config['monitor']: - print("Video capturing is ON!") + ray_on_aml = Ray_On_AML() + ray = ray_on_aml.getRay() + if ray: # in the headnode + ray.init(address="auto") + print("Configuring run from file: ", args.config) + experiment_config = None + with open(args.config, "r") as file: + experiment_config = yaml.safe_load(file) - # Start ray head (single node) - os.system('ray start --head') - ray.init(address='auto') + # Set local_dir in each experiment configuration to ensure generated logs get picked up + # Also set monitor to ensure videos are captured + for experiment_name, experiment in experiment_config.items(): + experiment["storage_path"] = "./logs" + experiment['config']['monitor'] = True + print(f'Config: {experiment_config}') - # Run training task using tune.run - tune.run( - run_or_experiment=args.run, - config=dict(args.config, env=args.env), - stop=args.stop, - checkpoint_freq=args.checkpoint_freq, - checkpoint_at_end=args.checkpoint_at_end, - local_dir=args.local_dir - ) + trials = run_experiments( + experiment_config, + callbacks=[callbacks.TrialCallback()], + verbose=2 + ) +else: + print("in worker node") diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/docker/Dockerfile b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/docker/Dockerfile index bf36aed64..af5d455c2 100644 --- a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/docker/Dockerfile +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/docker/Dockerfile @@ -8,33 +8,28 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ rm -rf /var/lib/apt/lists/* && \ rm -rf /usr/share/man/* -RUN conda install -y conda=23.1.0 python=3.8 && conda clean -ay +RUN pip install ray-on-aml==0.2.4 \ + ray==2.4.0 \ + ray[rllib]==2.4.0 \ + mlflow==2.3.1 \ + azureml-defaults==1.50.0 \ + azureml-dataset-runtime[fuse,pandas]==1.50.0 \ + azureml-contrib-reinforcementlearning==1.50.0 \ + gputil==1.4.0 \ + scipy==1.9.1 \ + pyglet==2.0.6 \ + cloudpickle==2.2.1 \ + tensorflow==2.11.0 \ + tensorflow-probability==0.19.0 \ + torch \ + tabulate==0.9.0 \ + dm_tree==0.1.8 \ + lz4==4.3.2 \ + psutil==5.9.4 \ + setproctitle==1.3.2 \ + pygame==2.1.0 \ + gymnasium[classic_control]==0.26.3 \ + gym[classic_control]==0.26.2 -RUN conda install -y -c conda-forge ffmpeg=4.0.2 -# RUN conda install -c anaconda opencv - -RUN pip install ray-on-aml==0.2.1 & \ - pip install --no-cache-dir \ - azureml-defaults \ - azureml-dataset-runtime[fuse,pandas] \ - azureml-contrib-reinforcementlearning \ - gputil \ - scipy \ - pyglet==1.5.27 \ - cloudpickle==1.3.0 \ - tensorboard==2.7.0 \ - tensorflow==2.7.0 \ - tabulate \ - dm_tree \ - lz4 \ - psutil \ - setproctitle \ - pygame \ - gym[classic_control]==0.19.0 - -RUN pip install protobuf==3.20.0 - -RUN pip install --upgrade ray==0.8.7 \ - ray[rllib,dashboard,tune]==0.8.7 - -RUN pip install 'msrest<0.7.0' +# Display the exact versions we have installed +RUN pip freeze diff --git a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/utils/callbacks.py b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/utils/callbacks.py index 022aadf01..f296f5770 100644 --- a/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/utils/callbacks.py +++ b/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/files/utils/callbacks.py @@ -3,21 +3,20 @@ ''' from azureml.core import Run +from ray import tune +from ray.tune import Callback +from ray.air import session -def on_train_result(info): - '''Callback on train result to record metrics returned by trainer. - ''' - run = Run.get_context() - run.log( - name='episode_reward_mean', - value=info["result"]["episode_reward_mean"]) - run.log( - name='episodes_total', - value=info["result"]["episodes_total"]) - run.log( - name='perf_cpu_percent', - value=info["result"]["perf"]["cpu_util_percent"]) - run.log( - name='perf_memory_percent', - value=info["result"]["perf"]["ram_util_percent"]) +class TrialCallback(Callback): + + def on_trial_result(self, iteration, trials, trial, result, **info): + '''Callback on train result to record metrics returned by trainer. + ''' + run = Run.get_context() + run.log( + name='episode_reward_mean', + value=result["episode_reward_mean"]) + run.log( + name='episodes_total', + value=result["episodes_total"]) diff --git a/how-to-use-azureml/responsible-ai/visualize-upload-loan-decision/rai-loan-decision.yml b/how-to-use-azureml/responsible-ai/visualize-upload-loan-decision/rai-loan-decision.yml index 8f7831378..016d5519f 100644 --- a/how-to-use-azureml/responsible-ai/visualize-upload-loan-decision/rai-loan-decision.yml +++ b/how-to-use-azureml/responsible-ai/visualize-upload-loan-decision/rai-loan-decision.yml @@ -8,7 +8,7 @@ dependencies: - matplotlib - azureml-dataset-runtime - ipywidgets - - raiwidgets~=0.26.0 + - raiwidgets~=0.27.0 - liac-arff - packaging>=20.9 - itsdangerous==2.0.1 diff --git a/how-to-use-azureml/track-and-monitor-experiments/logging-api/logging-api.ipynb b/how-to-use-azureml/track-and-monitor-experiments/logging-api/logging-api.ipynb index 9161675f2..ca354be23 100644 --- a/how-to-use-azureml/track-and-monitor-experiments/logging-api/logging-api.ipynb +++ b/how-to-use-azureml/track-and-monitor-experiments/logging-api/logging-api.ipynb @@ -101,7 +101,7 @@ "\n", "# Check core SDK version number\n", "\n", - "print(\"This notebook was created using SDK version 1.50.0, you are currently running version\", azureml.core.VERSION)" + "print(\"This notebook was created using SDK version 1.51, you are currently running version\", azureml.core.VERSION)" ] }, { diff --git a/index.md b/index.md index 4ed2fd1ec..a32e37276 100644 --- a/index.md +++ b/index.md @@ -9,74 +9,74 @@ Machine Learning notebook samples and encourage efficient retrieval of topics an |Title| Task | Dataset | Training Compute | Deployment Target | ML Framework | Tags | |:----|:-----|:-------:|:----------------:|:-----------------:|:------------:|:------------:| -| [Using Azure ML environments](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/training/using-environments/using-environments.ipynb) | Creating and registering environments | None | Local | None | None | None | +| [Using Azure ML environments](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training/using-environments/using-environments.ipynb) | Creating and registering environments | None | Local | None | None | None | ## Tutorials |Title| Task | Dataset | Training Compute | Deployment Target | ML Framework | Tags | |:----|:-----|:-------:|:----------------:|:-----------------:|:------------:|:------------:| -| [Forecasting BikeShare Demand](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-bike-share/auto-ml-forecasting-bike-share.ipynb) | Forecasting | BikeShare | Remote | None | Azure ML AutoML | Forecasting | -| [Forecasting orange juice sales with deployment](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-orange-juice-sales/auto-ml-forecasting-orange-juice-sales.ipynb) | Forecasting | Orange Juice Sales | Remote | Azure Container Instance | Azure ML AutoML | None | -| [Forecasting orange juice sales with deployment](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-pipelines/auto-ml-forecasting-pipelines.ipynb) | Forecasting | Orange Juice Sales | Remote | Azure Container Instance | Azure ML AutoML | None | -| [Register a model and deploy locally](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/deploy-to-local/register-model-deploy-local.ipynb) | Deployment | None | Local | Local | None | None | -| :star:[Data drift quickdemo](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/work-with-data/datadrift-tutorial/datadrift-tutorial.ipynb) | Filtering | NOAA | Remote | None | Azure ML | Dataset, Timeseries, Drift | -| :star:[Datasets with ML Pipeline](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/work-with-data/datasets-tutorial/pipeline-with-datasets/pipeline-for-image-classification.ipynb) | Train | Fashion MNIST | Remote | None | Azure ML | Dataset, Pipeline, Estimator, ScriptRun | -| :star:[Filtering data using Tabular Timeseiries Dataset related API](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/work-with-data/datasets-tutorial/timeseries-datasets/tabular-timeseries-dataset-filtering.ipynb) | Filtering | NOAA | Local | None | Azure ML | Dataset, Tabular Timeseries | -| :star:[Train with Datasets (Tabular and File)](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/work-with-data/datasets-tutorial/train-with-datasets/train-with-datasets.ipynb) | Train | Iris, Diabetes | Remote | None | Azure ML | Dataset, Estimator, ScriptRun | -| [Forecasting away from training data](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-forecast-function/auto-ml-forecasting-function.ipynb) | Forecasting | None | Remote | None | Azure ML AutoML | Forecasting, Confidence Intervals | -| [Automated ML run with basic edition features.](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/classification-bank-marketing-all-features/auto-ml-classification-bank-marketing-all-features.ipynb) | Classification | Bankmarketing | AML | ACI | None | featurization, explainability, remote_run, AutomatedML | -| [Classification of credit card fraudulent transactions using Automated ML](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/classification-credit-card-fraud/auto-ml-classification-credit-card-fraud.ipynb) | Classification | Creditcard | AML Compute | None | None | remote_run, AutomatedML | -| [Classification of credit card fraudulent transactions using Automated ML](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/experimental/classification-credit-card-fraud-local-managed/auto-ml-classification-credit-card-fraud-local-managed.ipynb) | Classification | Creditcard | AML Compute | None | None | AutomatedML | -| [Automated ML run with featurization and model explainability.](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/regression-explanation-featurization/auto-ml-regression-explanation-featurization.ipynb) | Regression | MachineData | AML | ACI | None | featurization, explainability, remote_run, AutomatedML | -| [auto-ml-forecasting-backtest-single-model](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-backtest-single-model/auto-ml-forecasting-backtest-single-model.ipynb) | | None | Remote | None | Azure ML AutoML | | -| :star:[Azure Machine Learning Pipeline with DataTranferStep](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-data-transfer.ipynb) | Demonstrates the use of DataTranferStep | Custom | ADF | None | Azure ML | None | -| [Getting Started with Azure Machine Learning Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-getting-started.ipynb) | Getting Started notebook for ANML Pipelines | Custom | AML Compute | None | Azure ML | None | -| [Azure Machine Learning Pipeline with AzureBatchStep](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-how-to-use-azurebatch-to-run-a-windows-executable.ipynb) | Demonstrates the use of AzureBatchStep | Custom | Azure Batch | None | Azure ML | None | -| :star:[How to use ModuleStep with AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-how-to-use-modulestep.ipynb) | Demonstrates the use of ModuleStep | Custom | AML Compute | None | Azure ML | None | -| :star:[How to use Pipeline Drafts to create a Published Pipeline](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-how-to-use-pipeline-drafts.ipynb) | Demonstrates the use of Pipeline Drafts | Custom | AML Compute | None | Azure ML | None | -| :star:[Azure Machine Learning Pipeline with HyperDriveStep](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-parameter-tuning-with-hyperdrive.ipynb) | Demonstrates the use of HyperDriveStep | Custom | AML Compute | None | Azure ML | None | -| :star:[How to Publish a Pipeline and Invoke the REST endpoint](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-publish-and-run-using-rest-endpoint.ipynb) | Demonstrates the use of Published Pipelines | Custom | AML Compute | None | Azure ML | None | -| :star:[How to Setup a Schedule for a Published Pipeline or Pipeline Endpoint](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-setup-schedule-for-a-published-pipeline.ipynb) | Demonstrates the use of Schedules for Published Pipelines and Pipeline endpoints | Custom | AML Compute | None | Azure ML | None | -| [How to setup a versioned Pipeline Endpoint](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-setup-versioned-pipeline-endpoints.ipynb) | Demonstrates the use of PipelineEndpoint to run a specific version of the Published Pipeline | Custom | AML Compute | None | Azure ML | None | -| :star:[How to use DataPath as a PipelineParameter](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-showcasing-datapath-and-pipelineparameter.ipynb) | Demonstrates the use of DataPath as a PipelineParameter | Custom | AML Compute | None | Azure ML | None | -| :star:[How to use Dataset as a PipelineParameter](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-showcasing-dataset-and-pipelineparameter.ipynb) | Demonstrates the use of Dataset as a PipelineParameter | Custom | AML Compute | None | Azure ML | None | -| [How to use AdlaStep with AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-use-adla-as-compute-target.ipynb) | Demonstrates the use of AdlaStep | Custom | Azure Data Lake Analytics | None | Azure ML | None | -| :star:[How to use DatabricksStep with AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-use-databricks-as-compute-target.ipynb) | Demonstrates the use of DatabricksStep | Custom | Azure Databricks | None | Azure ML, Azure Databricks | None | -| :star:[How to use KustoStep with AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-use-kusto-as-compute-target.ipynb) | Demonstrates the use of KustoStep | Custom | Kusto | None | Azure ML, Kusto | None | -| :star:[How to use AutoMLStep with AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-with-automated-machine-learning-step.ipynb) | Demonstrates the use of AutoMLStep | Custom | AML Compute | None | Automated Machine Learning | None | -| [Azure Machine Learning Pipeline with CommandStep for R](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-with-commandstep-r.ipynb) | Demonstrates the use of CommandStep for running R scripts | Custom | AML Compute | None | Azure ML | None | -| [Azure Machine Learning Pipeline with CommandStep](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-with-commandstep.ipynb) | Demonstrates the use of CommandStep | Custom | AML Compute | None | Azure ML | None | -| :star:[Azure Machine Learning Pipelines with Data Dependency](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-with-data-dependency-steps.ipynb) | Demonstrates how to construct a Pipeline with data dependency between steps | Custom | AML Compute | None | Azure ML | None | -| [How to use run a notebook as a step in AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-with-notebook-runner-step.ipynb) | Demonstrates the use of NotebookRunnerStep | Custom | AML Compute | None | Azure ML | None | -| [Use MLflow with Azure Machine Learning to Train and Deploy Keras Image Classifier](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/using-mlflow/train-and-deploy-keras-auto-logging/train-and-deploy-keras-auto-logging.ipynb) | Use MLflow with Azure Machine Learning to Train and Deploy Keras Image Classifier, leveraging MLflow auto logging | MNIST | Local, AML Compute | Azure Container Instance | Keras | mlflow, keras | -| [Use MLflow with Azure Machine Learning to Train and Deploy PyTorch Image Classifier](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/using-mlflow/train-and-deploy-pytorch/train-and-deploy-pytorch.ipynb) | Use MLflow with Azure Machine Learning to train and deploy PyTorch image classifier model | MNIST | Local, AML Compute | Azure Container Instance | PyTorch | mlflow, pytorch | -| [Use MLflow projects with Azure Machine Learning to train a model with local compute](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/track-and-monitor-experiments/using-mlflow/train-projects-local/train-projects-local.ipynb) | Use MLflow projects with Azure Machine Learning to train a model using local compute | | Local | | ScikitLearn | mlflow, scikit | -| [Use MLflow projects with Azure Machine Learning to train a model](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/track-and-monitor-experiments/using-mlflow/train-projects-remote/train-projects-remote.ipynb) | Use MLflow projects with Azure Machine Learning to train a model using azureml compute | | AML Compute | | Scikit | mlflow, scikit | -| [How to use ScriptRun with data input and output](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/work-with-data/datasets-tutorial/scriptrun-with-data-input-output/how-to-use-scriptrun.ipynb) | Demonstrates the use of Scriptrun with datasets | Custom | AML Compute | None | Azure ML | Dataset, ScriptRun | +| [Forecasting BikeShare Demand](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-bike-share/auto-ml-forecasting-bike-share.ipynb) | Forecasting | BikeShare | Remote | None | Azure ML AutoML | Forecasting | +| [Forecasting orange juice sales with deployment](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-orange-juice-sales/auto-ml-forecasting-orange-juice-sales.ipynb) | Forecasting | Orange Juice Sales | Remote | Azure Container Instance | Azure ML AutoML | None | +| [Forecasting orange juice sales with deployment](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-pipelines/auto-ml-forecasting-pipelines.ipynb) | Forecasting | Orange Juice Sales | Remote | Azure Container Instance | Azure ML AutoML | None | +| [Register a model and deploy locally](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/deploy-to-local/register-model-deploy-local.ipynb) | Deployment | None | Local | Local | None | None | +| :star:[Data drift quickdemo](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/work-with-data/datadrift-tutorial/datadrift-tutorial.ipynb) | Filtering | NOAA | Remote | None | Azure ML | Dataset, Timeseries, Drift | +| :star:[Datasets with ML Pipeline](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/work-with-data/datasets-tutorial/pipeline-with-datasets/pipeline-for-image-classification.ipynb) | Train | Fashion MNIST | Remote | None | Azure ML | Dataset, Pipeline, Estimator, ScriptRun | +| :star:[Filtering data using Tabular Timeseiries Dataset related API](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/work-with-data/datasets-tutorial/timeseries-datasets/tabular-timeseries-dataset-filtering.ipynb) | Filtering | NOAA | Local | None | Azure ML | Dataset, Tabular Timeseries | +| :star:[Train with Datasets (Tabular and File)](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/work-with-data/datasets-tutorial/train-with-datasets/train-with-datasets.ipynb) | Train | Iris, Diabetes | Remote | None | Azure ML | Dataset, Estimator, ScriptRun | +| [Forecasting away from training data](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-forecast-function/auto-ml-forecasting-function.ipynb) | Forecasting | None | Remote | None | Azure ML AutoML | Forecasting, Confidence Intervals | +| [Automated ML run with basic edition features.](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/classification-bank-marketing-all-features/auto-ml-classification-bank-marketing-all-features.ipynb) | Classification | Bankmarketing | AML | ACI | None | featurization, explainability, remote_run, AutomatedML | +| [Classification of credit card fraudulent transactions using Automated ML](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/classification-credit-card-fraud/auto-ml-classification-credit-card-fraud.ipynb) | Classification | Creditcard | AML Compute | None | None | remote_run, AutomatedML | +| [Classification of credit card fraudulent transactions using Automated ML](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/experimental/classification-credit-card-fraud-local-managed/auto-ml-classification-credit-card-fraud-local-managed.ipynb) | Classification | Creditcard | AML Compute | None | None | AutomatedML | +| [Automated ML run with featurization and model explainability.](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/regression-explanation-featurization/auto-ml-regression-explanation-featurization.ipynb) | Regression | MachineData | AML | ACI | None | featurization, explainability, remote_run, AutomatedML | +| [auto-ml-forecasting-backtest-single-model](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-backtest-single-model/auto-ml-forecasting-backtest-single-model.ipynb) | | None | Remote | None | Azure ML AutoML | | +| :star:[Azure Machine Learning Pipeline with DataTranferStep](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-data-transfer.ipynb) | Demonstrates the use of DataTranferStep | Custom | ADF | None | Azure ML | None | +| [Getting Started with Azure Machine Learning Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-getting-started.ipynb) | Getting Started notebook for ANML Pipelines | Custom | AML Compute | None | Azure ML | None | +| [Azure Machine Learning Pipeline with AzureBatchStep](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-how-to-use-azurebatch-to-run-a-windows-executable.ipynb) | Demonstrates the use of AzureBatchStep | Custom | Azure Batch | None | Azure ML | None | +| :star:[How to use ModuleStep with AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-how-to-use-modulestep.ipynb) | Demonstrates the use of ModuleStep | Custom | AML Compute | None | Azure ML | None | +| :star:[How to use Pipeline Drafts to create a Published Pipeline](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-how-to-use-pipeline-drafts.ipynb) | Demonstrates the use of Pipeline Drafts | Custom | AML Compute | None | Azure ML | None | +| :star:[Azure Machine Learning Pipeline with HyperDriveStep](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-parameter-tuning-with-hyperdrive.ipynb) | Demonstrates the use of HyperDriveStep | Custom | AML Compute | None | Azure ML | None | +| :star:[How to Publish a Pipeline and Invoke the REST endpoint](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-publish-and-run-using-rest-endpoint.ipynb) | Demonstrates the use of Published Pipelines | Custom | AML Compute | None | Azure ML | None | +| :star:[How to Setup a Schedule for a Published Pipeline or Pipeline Endpoint](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-setup-schedule-for-a-published-pipeline.ipynb) | Demonstrates the use of Schedules for Published Pipelines and Pipeline endpoints | Custom | AML Compute | None | Azure ML | None | +| [How to setup a versioned Pipeline Endpoint](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-setup-versioned-pipeline-endpoints.ipynb) | Demonstrates the use of PipelineEndpoint to run a specific version of the Published Pipeline | Custom | AML Compute | None | Azure ML | None | +| :star:[How to use DataPath as a PipelineParameter](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-showcasing-datapath-and-pipelineparameter.ipynb) | Demonstrates the use of DataPath as a PipelineParameter | Custom | AML Compute | None | Azure ML | None | +| :star:[How to use Dataset as a PipelineParameter](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-showcasing-dataset-and-pipelineparameter.ipynb) | Demonstrates the use of Dataset as a PipelineParameter | Custom | AML Compute | None | Azure ML | None | +| [How to use AdlaStep with AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-use-adla-as-compute-target.ipynb) | Demonstrates the use of AdlaStep | Custom | Azure Data Lake Analytics | None | Azure ML | None | +| :star:[How to use DatabricksStep with AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-use-databricks-as-compute-target.ipynb) | Demonstrates the use of DatabricksStep | Custom | Azure Databricks | None | Azure ML, Azure Databricks | None | +| :star:[How to use KustoStep with AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-use-kusto-as-compute-target.ipynb) | Demonstrates the use of KustoStep | Custom | Kusto | None | Azure ML, Kusto | None | +| :star:[How to use AutoMLStep with AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-with-automated-machine-learning-step.ipynb) | Demonstrates the use of AutoMLStep | Custom | AML Compute | None | Automated Machine Learning | None | +| [Azure Machine Learning Pipeline with CommandStep for R](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-with-commandstep-r.ipynb) | Demonstrates the use of CommandStep for running R scripts | Custom | AML Compute | None | Azure ML | None | +| [Azure Machine Learning Pipeline with CommandStep](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-with-commandstep.ipynb) | Demonstrates the use of CommandStep | Custom | AML Compute | None | Azure ML | None | +| :star:[Azure Machine Learning Pipelines with Data Dependency](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-with-data-dependency-steps.ipynb) | Demonstrates how to construct a Pipeline with data dependency between steps | Custom | AML Compute | None | Azure ML | None | +| [How to use run a notebook as a step in AML Pipelines](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-with-notebook-runner-step.ipynb) | Demonstrates the use of NotebookRunnerStep | Custom | AML Compute | None | Azure ML | None | +| [Use MLflow with Azure Machine Learning to Train and Deploy Keras Image Classifier](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/using-mlflow/train-and-deploy-keras-auto-logging/train-and-deploy-keras-auto-logging.ipynb) | Use MLflow with Azure Machine Learning to Train and Deploy Keras Image Classifier, leveraging MLflow auto logging | MNIST | Local, AML Compute | Azure Container Instance | Keras | mlflow, keras | +| [Use MLflow with Azure Machine Learning to Train and Deploy PyTorch Image Classifier](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/using-mlflow/train-and-deploy-pytorch/train-and-deploy-pytorch.ipynb) | Use MLflow with Azure Machine Learning to train and deploy PyTorch image classifier model | MNIST | Local, AML Compute | Azure Container Instance | PyTorch | mlflow, pytorch | +| [Use MLflow projects with Azure Machine Learning to train a model with local compute](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/track-and-monitor-experiments/using-mlflow/train-projects-local/train-projects-local.ipynb) | Use MLflow projects with Azure Machine Learning to train a model using local compute | | Local | | ScikitLearn | mlflow, scikit | +| [Use MLflow projects with Azure Machine Learning to train a model](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/track-and-monitor-experiments/using-mlflow/train-projects-remote/train-projects-remote.ipynb) | Use MLflow projects with Azure Machine Learning to train a model using azureml compute | | AML Compute | | Scikit | mlflow, scikit | +| [How to use ScriptRun with data input and output](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/work-with-data/datasets-tutorial/scriptrun-with-data-input-output/how-to-use-scriptrun.ipynb) | Demonstrates the use of Scriptrun with datasets | Custom | AML Compute | None | Azure ML | Dataset, ScriptRun | ## Training |Title| Task | Dataset | Training Compute | Deployment Target | ML Framework | Tags | |:----|:-----|:-------:|:----------------:|:-----------------:|:------------:|:------------:| -| [Train a model with a custom Docker image](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/fastai/fastai-with-custom-docker/fastai-with-custom-docker.ipynb) | Train with custom Docker image | Oxford IIIT Pet | AML Compute | None | Pytorch | None | -| [Train a DNN using hyperparameter tuning and deploying with Keras](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/keras/train-hyperparameter-tune-deploy-with-keras/train-hyperparameter-tune-deploy-with-keras.ipynb) | Create a multi-class classifier | MNIST | AML Compute | Azure Container Instance | TensorFlow | None | -| [Distributed training with PyTorch](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/pytorch/distributed-pytorch-with-distributeddataparallel/distributed-pytorch-with-distributeddataparallel.ipynb) | Train a model using distributed training via PyTorch DistributedDataParallel | CIFAR-10 | AML Compute | None | PyTorch | None | -| [Distributed PyTorch](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/pytorch/distributed-pytorch-with-horovod/distributed-pytorch-with-horovod.ipynb) | Train a model using the distributed training via Horovod | MNIST | AML Compute | None | PyTorch | None | -| [Training with hyperparameter tuning using PyTorch](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/pytorch/train-hyperparameter-tune-deploy-with-pytorch/train-hyperparameter-tune-deploy-with-pytorch.ipynb) | Train an image classification model using transfer learning with the PyTorch estimator | ImageNet | AML Compute | Azure Container Instance | PyTorch | None | -| [Training and hyperparameter tuning with Scikit-learn](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/scikit-learn/train-hyperparameter-tune-deploy-with-sklearn/train-hyperparameter-tune-deploy-with-sklearn.ipynb) | Train a support vector machine (SVM) to perform classification | Iris | AML Compute | None | Scikit-learn | None | -| [Distributed training using TensorFlow with Horovod](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/tensorflow/distributed-tensorflow-with-horovod/distributed-tensorflow-with-horovod.ipynb) | Use the TensorFlow estimator to train a word2vec model | None | AML Compute | None | TensorFlow | None | -| [Hyperparameter tuning and warm start using the TensorFlow estimator](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/tensorflow/hyperparameter-tune-and-warm-start-with-tensorflow/hyperparameter-tune-and-warm-start-with-tensorflow.ipynb) | Train a deep neural network | MNIST | AML Compute | Azure Container Instance | TensorFlow | None | -| [Training and hyperparameter tuning using the TensorFlow estimator](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/tensorflow/train-hyperparameter-tune-deploy-with-tensorflow/train-hyperparameter-tune-deploy-with-tensorflow.ipynb) | Train a deep neural network | MNIST | AML Compute | Azure Container Instance | TensorFlow | None | -| [Resuming a model](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/ml-frameworks/tensorflow/train-tensorflow-resume-training/train-tensorflow-resume-training.ipynb) | Resume a model in TensorFlow from a previously submitted run | MNIST | AML Compute | None | TensorFlow | None | -| [Using Tensorboard](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/track-and-monitor-experiments/tensorboard/export-run-history-to-tensorboard/export-run-history-to-tensorboard.ipynb) | Export the run history as Tensorboard logs | None | None | None | TensorFlow | None | -| [Training in Spark](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/training/train-in-spark/train-in-spark.ipynb) | Submiting a run on a spark cluster | None | HDI cluster | None | PySpark | None | -| [Train on Azure Machine Learning Compute](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/training/train-on-amlcompute/train-on-amlcompute.ipynb) | Submit a run on Azure Machine Learning Compute. | Diabetes | AML Compute | None | None | None | -| [Train on local compute](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/training/train-on-local/train-on-local.ipynb) | Train a model locally | Diabetes | Local | None | None | None | -| [Train in a remote Linux virtual machine](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/training/train-on-remote-vm/train-on-remote-vm.ipynb) | Configure and execute a run | Diabetes | Data Science Virtual Machine | None | None | None | -| [Managing your training runs](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/track-and-monitor-experiments/manage-runs/manage-runs.ipynb) | Monitor and complete runs | None | Local | None | None | None | -| [Tensorboard integration with run history](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/track-and-monitor-experiments/tensorboard/tensorboard/tensorboard.ipynb) | Run a TensorFlow job and view its Tensorboard output live | None | Local, DSVM, AML Compute | None | TensorFlow | None | -| [Use MLflow with AML for a local training run](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/track-and-monitor-experiments/using-mlflow/train-local/train-local.ipynb) | Use MLflow tracking APIs together with Azure Machine Learning for storing your metrics and artifacts | Diabetes | Local | None | None | None | -| [Use MLflow with AML for a remote training run](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/track-and-monitor-experiments/using-mlflow/train-remote/train-remote.ipynb) | Use MLflow tracking APIs together with AML for storing your metrics and artifacts | Diabetes | AML Compute | None | None | None | +| [Train a model with a custom Docker image](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/fastai/fastai-with-custom-docker/fastai-with-custom-docker.ipynb) | Train with custom Docker image | Oxford IIIT Pet | AML Compute | None | Pytorch | None | +| [Train a DNN using hyperparameter tuning and deploying with Keras](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/keras/train-hyperparameter-tune-deploy-with-keras/train-hyperparameter-tune-deploy-with-keras.ipynb) | Create a multi-class classifier | MNIST | AML Compute | Azure Container Instance | TensorFlow | None | +| [Distributed training with PyTorch](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/pytorch/distributed-pytorch-with-distributeddataparallel/distributed-pytorch-with-distributeddataparallel.ipynb) | Train a model using distributed training via PyTorch DistributedDataParallel | CIFAR-10 | AML Compute | None | PyTorch | None | +| [Distributed PyTorch](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/pytorch/distributed-pytorch-with-horovod/distributed-pytorch-with-horovod.ipynb) | Train a model using the distributed training via Horovod | MNIST | AML Compute | None | PyTorch | None | +| [Training with hyperparameter tuning using PyTorch](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/pytorch/train-hyperparameter-tune-deploy-with-pytorch/train-hyperparameter-tune-deploy-with-pytorch.ipynb) | Train an image classification model using transfer learning with the PyTorch estimator | ImageNet | AML Compute | Azure Container Instance | PyTorch | None | +| [Training and hyperparameter tuning with Scikit-learn](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/scikit-learn/train-hyperparameter-tune-deploy-with-sklearn/train-hyperparameter-tune-deploy-with-sklearn.ipynb) | Train a support vector machine (SVM) to perform classification | Iris | AML Compute | None | Scikit-learn | None | +| [Distributed training using TensorFlow with Horovod](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/tensorflow/distributed-tensorflow-with-horovod/distributed-tensorflow-with-horovod.ipynb) | Use the TensorFlow estimator to train a word2vec model | None | AML Compute | None | TensorFlow | None | +| [Hyperparameter tuning and warm start using the TensorFlow estimator](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/tensorflow/hyperparameter-tune-and-warm-start-with-tensorflow/hyperparameter-tune-and-warm-start-with-tensorflow.ipynb) | Train a deep neural network | MNIST | AML Compute | Azure Container Instance | TensorFlow | None | +| [Training and hyperparameter tuning using the TensorFlow estimator](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/tensorflow/train-hyperparameter-tune-deploy-with-tensorflow/train-hyperparameter-tune-deploy-with-tensorflow.ipynb) | Train a deep neural network | MNIST | AML Compute | Azure Container Instance | TensorFlow | None | +| [Resuming a model](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/tensorflow/train-tensorflow-resume-training/train-tensorflow-resume-training.ipynb) | Resume a model in TensorFlow from a previously submitted run | MNIST | AML Compute | None | TensorFlow | None | +| [Using Tensorboard](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/track-and-monitor-experiments/tensorboard/export-run-history-to-tensorboard/export-run-history-to-tensorboard.ipynb) | Export the run history as Tensorboard logs | None | None | None | TensorFlow | None | +| [Training in Spark](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training/train-in-spark/train-in-spark.ipynb) | Submiting a run on a spark cluster | None | HDI cluster | None | PySpark | None | +| [Train on Azure Machine Learning Compute](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training/train-on-amlcompute/train-on-amlcompute.ipynb) | Submit a run on Azure Machine Learning Compute. | Diabetes | AML Compute | None | None | None | +| [Train on local compute](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training/train-on-local/train-on-local.ipynb) | Train a model locally | Diabetes | Local | None | None | None | +| [Train in a remote Linux virtual machine](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training/train-on-remote-vm/train-on-remote-vm.ipynb) | Configure and execute a run | Diabetes | Data Science Virtual Machine | None | None | None | +| [Managing your training runs](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/track-and-monitor-experiments/manage-runs/manage-runs.ipynb) | Monitor and complete runs | None | Local | None | None | None | +| [Tensorboard integration with run history](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/track-and-monitor-experiments/tensorboard/tensorboard/tensorboard.ipynb) | Run a TensorFlow job and view its Tensorboard output live | None | Local, DSVM, AML Compute | None | TensorFlow | None | +| [Use MLflow with AML for a local training run](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/track-and-monitor-experiments/using-mlflow/train-local/train-local.ipynb) | Use MLflow tracking APIs together with Azure Machine Learning for storing your metrics and artifacts | Diabetes | Local | None | None | None | +| [Use MLflow with AML for a remote training run](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/track-and-monitor-experiments/using-mlflow/train-remote/train-remote.ipynb) | Use MLflow tracking APIs together with AML for storing your metrics and artifacts | Diabetes | AML Compute | None | None | None | ## Deployment @@ -84,68 +84,68 @@ Machine Learning notebook samples and encourage efficient retrieval of topics an |Title| Task | Dataset | Training Compute | Deployment Target | ML Framework | Tags | |:----|:-----|:-------:|:----------------:|:-----------------:|:------------:|:------------:| -| [Deploy MNIST digit recognition with ONNX Runtime](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/onnx/onnx-inference-mnist-deploy.ipynb) | Image Classification | MNIST | Local | Azure Container Instance | ONNX | ONNX Model Zoo | -| [Deploy Facial Expression Recognition (FER+) with ONNX Runtime](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/onnx/onnx-inference-facial-expression-recognition-deploy.ipynb) | Facial Expression Recognition | Emotion FER | Local | Azure Container Instance | ONNX | ONNX Model Zoo | -| :star:[Register model and deploy as webservice](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/deploy-to-cloud/model-register-and-deploy.ipynb) | Deploy a model with Azure Machine Learning | Diabetes | None | Azure Container Instance | Scikit-learn | None | -| [Train MNIST in PyTorch, convert, and deploy with ONNX Runtime](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/onnx/onnx-train-pytorch-aml-deploy-mnist.ipynb) | Image Classification | MNIST | AML Compute | Azure Container Instance | ONNX | ONNX Converter | -| [Deploy ResNet50 with ONNX Runtime](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/onnx/onnx-modelzoo-aml-deploy-resnet50.ipynb) | Image Classification | ImageNet | Local | Azure Container Instance | ONNX | ONNX Model Zoo | -| :star:[Convert and deploy TinyYolo with ONNX Runtime](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/onnx/onnx-convert-aml-deploy-tinyyolo.ipynb) | Object Detection | PASCAL VOC | local | Azure Container Instance | ONNX | ONNX Converter | -| [Register Spark model and deploy as webservice](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/spark/model-register-and-deploy-spark.ipynb) | | Iris | None | Azure Container Instance | PySpark | | +| [Deploy MNIST digit recognition with ONNX Runtime](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/onnx/onnx-inference-mnist-deploy.ipynb) | Image Classification | MNIST | Local | Azure Container Instance | ONNX | ONNX Model Zoo | +| [Deploy Facial Expression Recognition (FER+) with ONNX Runtime](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/onnx/onnx-inference-facial-expression-recognition-deploy.ipynb) | Facial Expression Recognition | Emotion FER | Local | Azure Container Instance | ONNX | ONNX Model Zoo | +| :star:[Register model and deploy as webservice](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/deploy-to-cloud/model-register-and-deploy.ipynb) | Deploy a model with Azure Machine Learning | Diabetes | None | Azure Container Instance | Scikit-learn | None | +| [Train MNIST in PyTorch, convert, and deploy with ONNX Runtime](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/onnx/onnx-train-pytorch-aml-deploy-mnist.ipynb) | Image Classification | MNIST | AML Compute | Azure Container Instance | ONNX | ONNX Converter | +| [Deploy ResNet50 with ONNX Runtime](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/onnx/onnx-modelzoo-aml-deploy-resnet50.ipynb) | Image Classification | ImageNet | Local | Azure Container Instance | ONNX | ONNX Model Zoo | +| :star:[Convert and deploy TinyYolo with ONNX Runtime](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/onnx/onnx-convert-aml-deploy-tinyyolo.ipynb) | Object Detection | PASCAL VOC | local | Azure Container Instance | ONNX | ONNX Converter | +| [Register Spark model and deploy as webservice](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/spark/model-register-and-deploy-spark.ipynb) | | Iris | None | Azure Container Instance | PySpark | | ## Other Notebooks |Title| Task | Dataset | Training Compute | Deployment Target | ML Framework | Tags | |:----|:-----|:-------:|:----------------:|:-----------------:|:------------:|:------------:| -| [DNN Text Featurization](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/classification-text-dnn/auto-ml-classification-text-dnn.ipynb) | Text featurization using DNNs for classification | None | AML Compute | None | None | None | +| [DNN Text Featurization](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/classification-text-dnn/auto-ml-classification-text-dnn.ipynb) | Text featurization using DNNs for classification | None | AML Compute | None | None | None | | [configuration](https://github.com/Azure/MachineLearningNotebooks/blob/master/configuration.ipynb) | | | | | | | -| [fairlearn-azureml-mitigation](https://github.com/Azure/MachineLearningNotebooks/blob/master//contrib/fairness/fairlearn-azureml-mitigation.ipynb) | | | | | | | -| [upload-fairness-dashboard](https://github.com/Azure/MachineLearningNotebooks/blob/master//contrib/fairness/upload-fairness-dashboard.ipynb) | | | | | | | -| [azure-ml-with-nvidia-rapids](https://github.com/Azure/MachineLearningNotebooks/blob/master//contrib/RAPIDS/azure-ml-with-nvidia-rapids.ipynb) | | | | | | | -| [auto-ml-continuous-retraining](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/continuous-retraining/auto-ml-continuous-retraining.ipynb) | | | | | | | -| [codegen-for-autofeaturization](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-codegen/codegen-for-autofeaturization.ipynb) | | | | | | | -| [custom-model-training-from-autofeaturization-run](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-custom-model-training/custom-model-training-from-autofeaturization-run.ipynb) | | | | | | | -| [auto-ml-regression-model-proxy](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/experimental/regression-model-proxy/auto-ml-regression-model-proxy.ipynb) | | | | | | | -| [auto-ml-forecasting-backtest-many-models](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-backtest-many-models/auto-ml-forecasting-backtest-many-models.ipynb) | | | | | | | -| [auto-ml-forecasting-energy-demand](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-energy-demand/auto-ml-forecasting-energy-demand.ipynb) | | | | | | | -| [auto-ml-forecasting-github-dau](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-github-dau/auto-ml-forecasting-github-dau.ipynb) | | | | | | | -| [auto-ml-forecasting-hierarchical-timeseries](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-hierarchical-timeseries/auto-ml-forecasting-hierarchical-timeseries.ipynb) | | | | | | | -| [auto-ml-forecasting-many-models](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-many-models/auto-ml-forecasting-many-models.ipynb) | | | | | | | -| [auto-ml-forecasting-univariate-recipe-experiment-settings](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-experiment-settings.ipynb) | | | | | | | -| [auto-ml-forecasting-univariate-recipe-run-experiment](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-run-experiment.ipynb) | | | | | | | -| [auto-ml-regression](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/automated-machine-learning/regression/auto-ml-regression.ipynb) | | | | | | | -| [automl-databricks-local-01](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/azure-databricks/automl/automl-databricks-local-01.ipynb) | | | | | | | -| [automl-databricks-local-with-deployment](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/azure-databricks/automl/automl-databricks-local-with-deployment.ipynb) | | | | | | | -| [spark_job_on_synapse_spark_pool](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/azure-synapse/spark_job_on_synapse_spark_pool.ipynb) | | | | | | | -| [spark_session_on_synapse_spark_pool](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/azure-synapse/spark_session_on_synapse_spark_pool.ipynb) | | | | | | | -| [Synapse_Job_Scala_Support](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/azure-synapse/Synapse_Job_Scala_Support.ipynb) | | | | | | | -| [Synapse_Session_Scala_Support](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/azure-synapse/Synapse_Session_Scala_Support.ipynb) | | | | | | | -| [multi-model-register-and-deploy](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/deploy-multi-model/multi-model-register-and-deploy.ipynb) | | | | | | | -| [register-model-deploy-local-advanced](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/deploy-to-local/register-model-deploy-local-advanced.ipynb) | | | | | | | -| [enable-app-insights-in-production-service](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/enable-app-insights-in-production-service/enable-app-insights-in-production-service.ipynb) | | | | | | | -| [onnx-model-register-and-deploy](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/onnx/onnx-model-register-and-deploy.ipynb) | | | | | | | -| [production-deploy-to-aks-ssl](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/production-deploy-to-aks/production-deploy-to-aks-ssl.ipynb) | | | | | | | -| [production-deploy-to-aks](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/production-deploy-to-aks/production-deploy-to-aks.ipynb) | | | | | | | -| [production-deploy-to-aks-gpu](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/deployment/production-deploy-to-aks-gpu/production-deploy-to-aks-gpu.ipynb) | | | | | | | -| [train-explain-model-gpu-tree-explainer](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/explain-model/azure-integration/gpu-explanation/train-explain-model-gpu-tree-explainer.ipynb) | | | | | | | -| [explain-model-on-amlcompute](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/explain-model/azure-integration/remote-explanation/explain-model-on-amlcompute.ipynb) | | | | | | | -| [save-retrieve-explanations-run-history](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/explain-model/azure-integration/run-history/save-retrieve-explanations-run-history.ipynb) | | | | | | | -| [train-explain-model-locally-and-deploy](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-locally-and-deploy.ipynb) | | | | | | | -| [train-explain-model-on-amlcompute-and-deploy](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-on-amlcompute-and-deploy.ipynb) | | | | | | | -| [training_notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/notebook_runner/training_notebook.ipynb) | | | | | | | -| [nyc-taxi-data-regression-model-building](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/machine-learning-pipelines/nyc-taxi-data-regression-model-building/nyc-taxi-data-regression-model-building.ipynb) | | | | | | | -| [authentication-in-azureml](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/manage-azureml-service/authentication-in-azureml/authentication-in-azureml.ipynb) | | | | | | | -| [pong_rllib](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/pong_rllib.ipynb) | | | | | | | -| [cartpole_ci](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/cartpole_ci.ipynb) | | | | | | | -| [cartpole_sc](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/cartpole_sc.ipynb) | | | | | | | -| [rai-loan-decision](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/responsible-ai/visualize-upload-loan-decision/rai-loan-decision.ipynb) | | | | | | | -| [Logging APIs](https://github.com/Azure/MachineLearningNotebooks/blob/master//how-to-use-azureml/track-and-monitor-experiments/logging-api/logging-api.ipynb) | Logging APIs and analyzing results | None | None | None | None | None | -| [configuration](https://github.com/Azure/MachineLearningNotebooks/blob/master//setup-environment/configuration.ipynb) | | | | | | | -| [quickstart-azureml-automl](https://github.com/Azure/MachineLearningNotebooks/blob/master//tutorials/compute-instance-quickstarts/quickstart-azureml-automl/quickstart-azureml-automl.ipynb) | | | | | | | -| [quickstart-azureml-in-10mins](https://github.com/Azure/MachineLearningNotebooks/blob/master//tutorials/compute-instance-quickstarts/quickstart-azureml-in-10mins/quickstart-azureml-in-10mins.ipynb) | | | | | | | -| [quickstart-azureml-python-sdk](https://github.com/Azure/MachineLearningNotebooks/blob/master//tutorials/compute-instance-quickstarts/quickstart-azureml-python-sdk/quickstart-azureml-python-sdk.ipynb) | | | | | | | -| [tutorial-1st-experiment-sdk-train](https://github.com/Azure/MachineLearningNotebooks/blob/master//tutorials/create-first-ml-experiment/tutorial-1st-experiment-sdk-train.ipynb) | | | | | | | -| [img-classification-part1-training](https://github.com/Azure/MachineLearningNotebooks/blob/master//tutorials/image-classification-mnist-data/img-classification-part1-training.ipynb) | | | | | | | -| [img-classification-part2-deploy](https://github.com/Azure/MachineLearningNotebooks/blob/master//tutorials/image-classification-mnist-data/img-classification-part2-deploy.ipynb) | | | | | | | -| [img-classification-part3-deploy-encrypted](https://github.com/Azure/MachineLearningNotebooks/blob/master//tutorials/image-classification-mnist-data/img-classification-part3-deploy-encrypted.ipynb) | | | | | | | -| [tutorial-pipeline-batch-scoring-classification](https://github.com/Azure/MachineLearningNotebooks/blob/master//tutorials/machine-learning-pipelines-advanced/tutorial-pipeline-batch-scoring-classification.ipynb) | | | | | | | -| [regression-automated-ml](https://github.com/Azure/MachineLearningNotebooks/blob/master//tutorials/regression-automl-nyc-taxi-data/regression-automated-ml.ipynb) | | | | | | | +| [fairlearn-azureml-mitigation](https://github.com/Azure/MachineLearningNotebooks/blob/master/contrib/fairness/fairlearn-azureml-mitigation.ipynb) | | | | | | | +| [upload-fairness-dashboard](https://github.com/Azure/MachineLearningNotebooks/blob/master/contrib/fairness/upload-fairness-dashboard.ipynb) | | | | | | | +| [azure-ml-with-nvidia-rapids](https://github.com/Azure/MachineLearningNotebooks/blob/master/contrib/RAPIDS/azure-ml-with-nvidia-rapids.ipynb) | | | | | | | +| [auto-ml-continuous-retraining](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/continuous-retraining/auto-ml-continuous-retraining.ipynb) | | | | | | | +| [codegen-for-autofeaturization](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-codegen/codegen-for-autofeaturization.ipynb) | | | | | | | +| [custom-model-training-from-autofeaturization-run](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/experimental/autofeaturization-custom-model-training/custom-model-training-from-autofeaturization-run.ipynb) | | | | | | | +| [auto-ml-regression-model-proxy](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/experimental/regression-model-proxy/auto-ml-regression-model-proxy.ipynb) | | | | | | | +| [auto-ml-forecasting-backtest-many-models](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-backtest-many-models/auto-ml-forecasting-backtest-many-models.ipynb) | | | | | | | +| [auto-ml-forecasting-energy-demand](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-energy-demand/auto-ml-forecasting-energy-demand.ipynb) | | | | | | | +| [auto-ml-forecasting-github-dau](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-github-dau/auto-ml-forecasting-github-dau.ipynb) | | | | | | | +| [auto-ml-forecasting-hierarchical-timeseries](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-hierarchical-timeseries/auto-ml-forecasting-hierarchical-timeseries.ipynb) | | | | | | | +| [auto-ml-forecasting-many-models](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-many-models/auto-ml-forecasting-many-models.ipynb) | | | | | | | +| [auto-ml-forecasting-univariate-recipe-experiment-settings](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-experiment-settings.ipynb) | | | | | | | +| [auto-ml-forecasting-univariate-recipe-run-experiment](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-recipes-univariate/auto-ml-forecasting-univariate-recipe-run-experiment.ipynb) | | | | | | | +| [auto-ml-regression](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/regression/auto-ml-regression.ipynb) | | | | | | | +| [automl-databricks-local-01](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/azure-databricks/automl/automl-databricks-local-01.ipynb) | | | | | | | +| [automl-databricks-local-with-deployment](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/azure-databricks/automl/automl-databricks-local-with-deployment.ipynb) | | | | | | | +| [spark_job_on_synapse_spark_pool](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/azure-synapse/spark_job_on_synapse_spark_pool.ipynb) | | | | | | | +| [spark_session_on_synapse_spark_pool](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/azure-synapse/spark_session_on_synapse_spark_pool.ipynb) | | | | | | | +| [Synapse_Job_Scala_Support](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/azure-synapse/Synapse_Job_Scala_Support.ipynb) | | | | | | | +| [Synapse_Session_Scala_Support](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/azure-synapse/Synapse_Session_Scala_Support.ipynb) | | | | | | | +| [multi-model-register-and-deploy](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/deploy-multi-model/multi-model-register-and-deploy.ipynb) | | | | | | | +| [register-model-deploy-local-advanced](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/deploy-to-local/register-model-deploy-local-advanced.ipynb) | | | | | | | +| [enable-app-insights-in-production-service](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/enable-app-insights-in-production-service/enable-app-insights-in-production-service.ipynb) | | | | | | | +| [onnx-model-register-and-deploy](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/onnx/onnx-model-register-and-deploy.ipynb) | | | | | | | +| [production-deploy-to-aks-ssl](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/production-deploy-to-aks/production-deploy-to-aks-ssl.ipynb) | | | | | | | +| [production-deploy-to-aks](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/production-deploy-to-aks/production-deploy-to-aks.ipynb) | | | | | | | +| [production-deploy-to-aks-gpu](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/production-deploy-to-aks-gpu/production-deploy-to-aks-gpu.ipynb) | | | | | | | +| [train-explain-model-gpu-tree-explainer](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/explain-model/azure-integration/gpu-explanation/train-explain-model-gpu-tree-explainer.ipynb) | | | | | | | +| [explain-model-on-amlcompute](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/explain-model/azure-integration/remote-explanation/explain-model-on-amlcompute.ipynb) | | | | | | | +| [save-retrieve-explanations-run-history](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/explain-model/azure-integration/run-history/save-retrieve-explanations-run-history.ipynb) | | | | | | | +| [train-explain-model-locally-and-deploy](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-locally-and-deploy.ipynb) | | | | | | | +| [train-explain-model-on-amlcompute-and-deploy](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/explain-model/azure-integration/scoring-time/train-explain-model-on-amlcompute-and-deploy.ipynb) | | | | | | | +| [training_notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/notebook_runner/training_notebook.ipynb) | | | | | | | +| [nyc-taxi-data-regression-model-building](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/nyc-taxi-data-regression-model-building/nyc-taxi-data-regression-model-building.ipynb) | | | | | | | +| [authentication-in-azureml](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/manage-azureml-service/authentication-in-azureml/authentication-in-azureml.ipynb) | | | | | | | +| [pong_rllib](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/reinforcement-learning/atari-on-distributed-compute/pong_rllib.ipynb) | | | | | | | +| [cartpole_ci](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/reinforcement-learning/cartpole-on-compute-instance/cartpole_ci.ipynb) | | | | | | | +| [cartpole_sc](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/reinforcement-learning/cartpole-on-single-compute/cartpole_sc.ipynb) | | | | | | | +| [rai-loan-decision](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/responsible-ai/visualize-upload-loan-decision/rai-loan-decision.ipynb) | | | | | | | +| [Logging APIs](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/track-and-monitor-experiments/logging-api/logging-api.ipynb) | Logging APIs and analyzing results | None | None | None | None | None | +| [configuration](https://github.com/Azure/MachineLearningNotebooks/blob/master/setup-environment/configuration.ipynb) | | | | | | | +| [quickstart-azureml-automl](https://github.com/Azure/MachineLearningNotebooks/blob/master/tutorials/compute-instance-quickstarts/quickstart-azureml-automl/quickstart-azureml-automl.ipynb) | | | | | | | +| [quickstart-azureml-in-10mins](https://github.com/Azure/MachineLearningNotebooks/blob/master/tutorials/compute-instance-quickstarts/quickstart-azureml-in-10mins/quickstart-azureml-in-10mins.ipynb) | | | | | | | +| [quickstart-azureml-python-sdk](https://github.com/Azure/MachineLearningNotebooks/blob/master/tutorials/compute-instance-quickstarts/quickstart-azureml-python-sdk/quickstart-azureml-python-sdk.ipynb) | | | | | | | +| [tutorial-1st-experiment-sdk-train](https://github.com/Azure/MachineLearningNotebooks/blob/master/tutorials/create-first-ml-experiment/tutorial-1st-experiment-sdk-train.ipynb) | | | | | | | +| [img-classification-part1-training](https://github.com/Azure/MachineLearningNotebooks/blob/master/tutorials/image-classification-mnist-data/img-classification-part1-training.ipynb) | | | | | | | +| [img-classification-part2-deploy](https://github.com/Azure/MachineLearningNotebooks/blob/master/tutorials/image-classification-mnist-data/img-classification-part2-deploy.ipynb) | | | | | | | +| [img-classification-part3-deploy-encrypted](https://github.com/Azure/MachineLearningNotebooks/blob/master/tutorials/image-classification-mnist-data/img-classification-part3-deploy-encrypted.ipynb) | | | | | | | +| [tutorial-pipeline-batch-scoring-classification](https://github.com/Azure/MachineLearningNotebooks/blob/master/tutorials/machine-learning-pipelines-advanced/tutorial-pipeline-batch-scoring-classification.ipynb) | | | | | | | +| [regression-automated-ml](https://github.com/Azure/MachineLearningNotebooks/blob/master/tutorials/regression-automl-nyc-taxi-data/regression-automated-ml.ipynb) | | | | | | | diff --git a/setup-environment/configuration.ipynb b/setup-environment/configuration.ipynb index a44c8ce73..d895aba8c 100644 --- a/setup-environment/configuration.ipynb +++ b/setup-environment/configuration.ipynb @@ -102,7 +102,7 @@ "source": [ "import azureml.core\n", "\n", - "print(\"This notebook was created using version 1.50.0 of the Azure ML SDK\")\n", + "print(\"This notebook was created using version 1.51 of the Azure ML SDK\")\n", "print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")" ] },