|
| 1 | +--- |
| 2 | +title: Forecast bike sharing demand with automated ML experiment |
| 3 | +titleSuffix: Azure Machine Learning |
| 4 | +description: Learn how to train and deploy a demand forecasting model with automated machine learning in Azure Machine Learning studio. |
| 5 | +services: machine-learning |
| 6 | +ms.service: machine-learning |
| 7 | +ms.subservice: core |
| 8 | +ms.topic: tutorial |
| 9 | +ms.author: sacartac |
| 10 | +ms.reviewer: nibaccam |
| 11 | +author: cartacioS |
| 12 | +ms.date: 01/27/2020 |
| 13 | + |
| 14 | +# Customer intent: As a non-coding data scientist, I want to use automated machine learning to build a demand forecasting model. |
| 15 | +--- |
| 16 | + |
| 17 | +# Tutorial: Forecast bike sharing demand with automated machine learning |
| 18 | +[!INCLUDE [applies-to-skus](../../includes/aml-applies-to-enterprise-sku.md)] |
| 19 | + |
| 20 | +In this tutorial, you use automated machine learning, or automated ML, in the Azure Machine Learning studio to create a time series forecasting model to predict rental demand for a bike sharing service. |
| 21 | + |
| 22 | +In this tutorial, you learn how to do the following tasks: |
| 23 | + |
| 24 | +> [!div class="checklist"] |
| 25 | +> * Create and load a dataset. |
| 26 | +> * Configure and run an automated ML experiment. |
| 27 | +> * Explore the experiment results. |
| 28 | +> * Deploy the best model. |
| 29 | +
|
| 30 | +## Prerequisites |
| 31 | + |
| 32 | +* An Enterprise edition Azure Machine Learning workspace. If you don't have a workspace, [create an Enterprise edition workspace](how-to-manage-workspace.md). |
| 33 | + * Automated machine learning in the Azure Machine Learning studio is only available for Enterprise edition workspaces. |
| 34 | +* Download the [bike-no.csv](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-bike-share/bike-no.csv) data file |
| 35 | + |
| 36 | +## Get started in Azure Machine Learning studio |
| 37 | + |
| 38 | +For this tutorial, you create your automated ML experiment run in Azure Machine Learning studio, a consolidated interface that includes machine learning tools to perform data science scenarios for data science practitioners of all skill levels. The studio is not supported on Internet Explorer browsers. |
| 39 | + |
| 40 | +1. Sign in to [Azure Machine Learning studio](https://ml.azure.com). |
| 41 | + |
| 42 | +1. Select your subscription and the workspace you created. |
| 43 | + |
| 44 | +1. Select **Get started**. |
| 45 | + |
| 46 | +1. In the left pane, select **Automated ML** under the **Author** section. |
| 47 | + |
| 48 | +1. Select **+New automated ML run**. |
| 49 | + |
| 50 | +## Create and load dataset |
| 51 | + |
| 52 | +Before you configure your experiment, upload your data file to your workspace in the form of an Azure Machine Learning dataset. Doing so, allows you to ensure that your data is formatted appropriately for your experiment. |
| 53 | + |
| 54 | +1. On the **Select dataset** form, select **From local files** from the **+Create dataset** drop-down. |
| 55 | + |
| 56 | + 1. On the **Basic info** form, give your dataset a name and provide an optional description. The dataset type should default to **Tabular**, since automated ML in Azure Machine Learning studio currently only supports tabular datasets. |
| 57 | + |
| 58 | + 1. Select **Next** on the bottom left |
| 59 | + |
| 60 | + 1. On the **Datastore and file selection** form, select the default datastore that was automatically set up during your workspace creation, **workspaceblobstore (Azure Blob Storage)**. This is the storage location where you'll upload your data file. |
| 61 | + |
| 62 | + 1. Select **Browse**. |
| 63 | + |
| 64 | + 1. Choose the **bike-no.csv** file on your local computer. This is the file you downloaded as a [prerequisite](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/forecasting-bike-share/bike-no.csv). |
| 65 | + |
| 66 | + 1. Select **Next** |
| 67 | + |
| 68 | + When the upload is complete, the Settings and preview form is pre-populated based on the file type. |
| 69 | + |
| 70 | + 1. Verify that the **Settings and preview** form is populated as follows and select **Next**. |
| 71 | + |
| 72 | + Field|Description| Value for tutorial |
| 73 | + ---|---|--- |
| 74 | + File format|Defines the layout and type of data stored in a file.| Delimited |
| 75 | + Delimiter|One or more characters for specifying the boundary between separate, independent regions in plain text or other data streams. |Comma |
| 76 | + Encoding|Identifies what bit to character schema table to use to read your dataset.| UTF-8 |
| 77 | + Column headers| Indicates how the headers of the dataset, if any, will be treated.| Use headers from the first file |
| 78 | + Skip rows | Indicates how many, if any, rows are skipped in the dataset.| None |
| 79 | + |
| 80 | + 1. The **Schema** form allows for further configuration of your data for this experiment. |
| 81 | + |
| 82 | + 1. For this example, choose to ignore the **casual** and **registered** columns. These columns are a breakdown of the **cnt** column so, therefore we don't include them. |
| 83 | + |
| 84 | + 1. Also for this example, leave the defaults for the **Properties** and **Type**. |
| 85 | + |
| 86 | + 1. Select **Next**. |
| 87 | + |
| 88 | + 1. On the **Confirm details** form, verify the information matches what was previously populated on the **Basic info** and **Settings and preview** forms. |
| 89 | + |
| 90 | + 1. Select **Create** to complete the creation of your dataset. |
| 91 | + |
| 92 | + 1. Select your dataset once it appears in the list. |
| 93 | + |
| 94 | + 1. Select **Next**. |
| 95 | + |
| 96 | +## Configure experiment run |
| 97 | + |
| 98 | +After you load and configure your data, set up your remote compute target and select which column in your data you want to predict. |
| 99 | + |
| 100 | +1. Populate the **Configure run** form as follows: |
| 101 | + 1. Enter an experiment name: `automl-bikeshare` |
| 102 | + |
| 103 | + 1. Select **cnt** as the target column, what you want to predict. This column indicates the number of total bike share rentals. |
| 104 | + |
| 105 | + 1. Select **Create a new compute** and configure your compute target. Automated ML only supports Azure Machine Learning compute. |
| 106 | + |
| 107 | + Field | Description | Value for tutorial |
| 108 | + ----|---|--- |
| 109 | + Compute name |A unique name that identifies your compute context.|bike-compute |
| 110 | + Virtual machine size| Select the virtual machine size for your compute.|Standard_DS12_V2 |
| 111 | + Min / Max nodes (in Advanced Settings)| To profile data, you must specify 1 or more nodes.|Min nodes: 1<br>Max nodes: 6 |
| 112 | + |
| 113 | + 1. Select **Create** to get the compute target. |
| 114 | + |
| 115 | + **This takes a couple minutes to complete.** |
| 116 | + |
| 117 | + 1. After creation, select your new compute target from the drop-down list. |
| 118 | + |
| 119 | + 1. Select **Next**. |
| 120 | + |
| 121 | +## Select task type and settings |
| 122 | + |
| 123 | +Complete the setup for your automated ML experiment by specifying the machine learning task type and configuration settings. |
| 124 | + |
| 125 | +1. On the **Task type and settings** form, select **Time series forecasting** as the machine learning task type. |
| 126 | + |
| 127 | +1. Select **date** as your **Time column** and leave **Group by column(s)** blank. |
| 128 | + |
| 129 | + 1. Select **View additional configuration settings** and populate the fields as follows. These settings are to better control the training job. Otherwise, defaults are applied based on experiment selection and data. |
| 130 | + |
| 131 | + |
| 132 | + Additional configurations|Description|Value for tutorial |
| 133 | + ------|---------|--- |
| 134 | + Primary metric| Evaluation metric that the machine learning algorithm will be measured by.|Normalized root mean squared error |
| 135 | + Automatic featurization| Enables preprocessing. This includes automatic data cleansing, preparing, and transformation to generate synthetic features.| Enable |
| 136 | + Explain best model (preview)| Automatically shows explainability on the best model created by automated ML.| Enable |
| 137 | + Blocked algorithms | Algorithms you want to exclude from the training job| Extreme Random Trees |
| 138 | + Additional forecasting settings| These settings help improve the accuracy of your model <br><br> _**Forecast horizon**_: length of time into the future you want to predict <br> _**Forecast target lags:**_ how far back you want to construct the lags of a the target variable <br> _**Target rolling window**_: specifies the size of the rolling window over which features, such as the *max, min* and *sum*, will be generated. |Forecast horizon: 14 <br> Forecast target lags: None <br> Target rolling window size: None |
| 139 | + Exit criterion| If a criteria is met, the training job is stopped. |Training job time (hours): 3 <br> Metric score threshold: None |
| 140 | + Validation | Choose a cross-validation type and number of tests.|Validation type:<br> k-fold cross-validation <br> <br> Number of validations: 5 |
| 141 | + Concurrency| The maximum number of parallel iterations executed per iteration| Max concurrent iterations: 6 |
| 142 | + |
| 143 | + Select **Save**. |
| 144 | + |
| 145 | +## Run experiment |
| 146 | + |
| 147 | +To run your experiment, select **Finish**. The **Run details** screen opens with the **Run status** at the top next to the run number. This status updates as the experiment progresses. |
| 148 | + |
| 149 | +>[!IMPORTANT] |
| 150 | +> Preparation takes **10-15 minutes** to prepare the experiment run. |
| 151 | +> Once running, it takes **2-3 minutes more for each iteration**. <br> <br> |
| 152 | +> In production, you'd likely walk away for a bit as this process takes time. While you wait, we suggest you start exploring the tested algorithms on the **Models** tab as they complete. |
| 153 | +
|
| 154 | +## Explore models |
| 155 | + |
| 156 | +Navigate to the **Models** tab to see the algorithms (models) tested. By default, the models are ordered by metric score as they complete. For this tutorial, the model that scores the highest based on the chosen **Normalized root mean squared error** metric is at the top of the list. |
| 157 | + |
| 158 | +While you wait for all of the experiment models to finish, select the **Algorithm name** of a completed model to explore its performance details. |
| 159 | + |
| 160 | +The following example navigates through the **Model details** and the **Visualizations** tabs to view the selected model's properties, metrics and performance charts. |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | +## Deploy the model |
| 165 | + |
| 166 | +Automated machine learning in Azure Machine Learning studio allows you to deploy the best model as a web service in a few steps. Deployment is the integration of the model so it can predict on new data and identify potential areas of opportunity. |
| 167 | + |
| 168 | +For this experiment, deployment to a web service means that the bike share company now has an iterative and scalable web solution for forecasting bike share rental demand. |
| 169 | + |
| 170 | +Once the run is complete, navigate back to the **Run detail** page and select the **Models** tab. |
| 171 | + |
| 172 | +In this experiment context, **StackEnsemble** is considered the best model, based on the **Normalized root mean squared error** metric. We deploy this model, but be advised, deployment takes about 20 minutes to complete. The deployment process entails several steps including registering the model, generating resources, and configuring them for the web service. |
| 173 | + |
| 174 | +1. Select the **Deploy best model** button in the bottom-left corner. |
| 175 | + |
| 176 | +1. Populate the **Deploy a model** pane as follows: |
| 177 | + |
| 178 | + Field| Value |
| 179 | + ----|---- |
| 180 | + Deployment name| bikeshare-deploy |
| 181 | + Deployment description| bike share demand deployment |
| 182 | + Compute type | Select Azure Compute Instance (ACI) |
| 183 | + Enable authentication| Disable. |
| 184 | + Use custom deployment assets| Disable. Disabling allows for the default driver file (scoring script) and environment file to be autogenerated. |
| 185 | + |
| 186 | + For this example, we use the defaults provided in the *Advanced* menu. |
| 187 | + |
| 188 | +1. Select **Deploy**. |
| 189 | + |
| 190 | + A green success message appears at the top of the **Run** screen stated that the deployment was started successfully. The progress of the deployment can be found |
| 191 | + in the **Recommended model** pane under **Deploy status**. |
| 192 | + |
| 193 | +Once deployment succeeds, you have an operational web service to generate predictions. |
| 194 | + |
| 195 | +Proceed to the [**Next steps**](#next-steps) to learn more about how to consume your new web service, and test your predictions using Power BI's built in Azure Machine Learning support. |
| 196 | + |
| 197 | +## Clean up resources |
| 198 | + |
| 199 | +Deployment files are larger than data and experiment files, so they cost more to store. Delete only the deployment files to minimize costs to your account, or if you want to keep your workspace and experiment files. Otherwise, delete the entire resource group, if you don't plan to use any of the files. |
| 200 | + |
| 201 | +### Delete the deployment instance |
| 202 | + |
| 203 | +Delete just the deployment instance from the Azure Machine Learning studio, if you want to keep the resource group and workspace for other tutorials and exploration. |
| 204 | + |
| 205 | +1. Go to the [Azure Machine Learning studio](https://ml.azure.com/). Navigate to your workspace and on the left under the **Assets** pane, select **Endpoints**. |
| 206 | + |
| 207 | +1. Select the deployment you want to delete and select **Delete**. |
| 208 | + |
| 209 | +1. Select **Proceed**. |
| 210 | + |
| 211 | +### Delete the resource group |
| 212 | + |
| 213 | +[!INCLUDE [aml-delete-resource-group](../../includes/aml-delete-resource-group.md)] |
| 214 | + |
| 215 | +## Next steps |
| 216 | + |
| 217 | +In this tutorial, you used automated ML in the Azure Machine Learning studio to create and deploy a time series forecasting model that predicts bike share rental demand. |
| 218 | + |
| 219 | +See this article for steps on how to create a Power BI supported schema to facilitate consumption of your newly deployed web service: |
| 220 | + |
| 221 | +> [!div class="nextstepaction"] |
| 222 | +> [Consume a web service](how-to-consume-web-service.md#consume-the-service-from-power-bi) |
| 223 | +
|
| 224 | + |
| 225 | +>[!NOTE] |
| 226 | +> This bike share dataset has been modified for this tutorial. This dataset was made available as part of a [Kaggle competition](https://www.kaggle.com/c/bike-sharing-demand/data) and was originally available via [Capital Bikeshare](https://www.capitalbikeshare.com/system-data). It can also be found within the [UCI Machine Learning Database](http://archive.ics.uci.edu/ml/datasets/Bike+Sharing+Dataset).<br><br> |
| 227 | +> Source: Fanaee-T, Hadi, and Gama, Joao, Event labeling combining ensemble detectors and background knowledge, Progress in Artificial Intelligence (2013): pp. 1-15, Springer Berlin Heidelberg. |
0 commit comments