Azure Machine Learning Package for Forecasting

The Azure Machine Learning Package for Forecasting (AMLPF) is a Python package for creating and deploying forecasting models using a high-level Python API.

The AMLPF package supports the following scenarios:

  • Financial forecasting
  • Demand forecasting

For more information about each module and class in this package, see the AMLPF reference documenttion.

What's included in the API

Azure Machine Learning Package for Forecasting includes APIs for:

  • Time series data preparation. Load temporal data and convert it to a time series data structure. This time series data structure enables convenient modeling of multiple time series, such as by store or by product. The structure is also compatible with the rich capabilities of pandas.

  • Exploratory reports. Create a comprehensive report of your time series data frame that can be used to choose the best approach for your forecasting problem. The report presents both the general data description and statistics specific to time series data.

  • Featurization. Automatically generate time index, lags, rolling windows, and forecasts as features from your data frame. You can also create your own custom features as well.

  • Modeling and time series cross-validation. Finance series are characterized by relatively small amounts of data and high-accuracy requirements. This package implements univariate forecasting methods and machine learning models. The package also implements time-series cross-validation and hyper-parameter tuning that enable you to squeeze additional accuracy from your data.

  • Model evaluation and selection. Automatically calculate forecast errors including MASE and MAPE, and select the best model based on back-tested performance of many different forecasting models.

  • Model deployment. You can deploy trained models to Azure Machine Learning as web services. These web services can be consumed at the scale required by your business.


Complete these prerequisites before you install and use Azure Machine Learning Package for Forecasting:

  1. If you don't have an Azure subscription, create a free account before you begin.

  2. A Windows PC or a Data Science Virtual Machine (DSVM) on Azure.

    You can provision a DSVM with these steps.

  3. The following accounts and application must be set up and installed:

    • An Azure Machine Learning Experimentation account
    • An Azure Machine Learning Model Management account
    • Azure Machine Learning Workbench installed on the DSVM or Windows PC

    If these accounts don't exist yet or if you haven't installed Workbench, follow the Azure Machine Learning Quickstart and Workbench installation article.

    Starting from a freshly installed Workbench works best. Installing Workbench can take about 30 minutes.

Install and get started on Windows

Install the package

After completing the prerequisite, you can download and install the Azure Machine Learning Package for Forecasting.

  1. If you provisioned a Data Science Virtual Machine (DSVM) on Azure, log into that machine now. If working on a local Windows PC, skip this step.

  2. Download the install script to the directory in which you will store the sample notebooks.

  3. From a command prompt, go to the download directory and run the installation script. The package installation can take around 15 minutes.

Run the sample notebooks

The best way to learn the workflow of this package is through the sample Jupyter notebooks distributed with the package. From the same command window, authenticate with the CLI using your Azure account and start a Jupyter notebook session:

az login
az ml notebook start

CLI commands are run against your default subscription. If you have more than one subscription, you can change your default subscription.

Your default browser is automatically launched with Jupyter server. You can now open the sample notebook, Dominicks_OJ_Sales_Forecasting.ipynb, or create your own.

Optional deployment configuration for Windows PCs

To deploy your models from your local Windows machine using a local docker or remotely via Azure Kubernetes Service, configure those now.

Remote Operationalization: The sample notebook demonstrates remote operationalization with Azure Machine Learning. This works on Windows PC, Windows DSVM, and Ubuntu DSVM.

Local Operationalization: Supported on Windows PCs only. To test local deployment on your PC, you must install Docker for Windows and Azure Kubernetes Service as follows:

  1. Install Docker for Windows.

  2. Virtualize Docker, if needed. You may need to enter the BIOS to enable virtualization.

    Reboot your Windows PC and press the following keys, based on your computer manufacturer:

    Manufacturer Key
    Hewlett Packard
  3. Install Kubernetes for Windows.

  4. Place kubectl.exe on your system path. The default location is C:\Users<USERNAME>\bin.

Open a notebook session and configure the kernel

  1. Launch Azure Machine Learning Workbench.

  2. From the Workbench menu, select File > Open Command Prompt.

  3. In the command prompt window, navigate to the folder that contains the notebook.

  4. Configure the kernel. At the prompt, enter:

    activate azuremlftk_may2018
  5. Authenticate with the CLI using your Azure account and start a Jupyter notebook session. At the prompt, enter:

    az login
    az ml notebook start

    Follow the onscreen prompts to log in.

  6. Open the Jupyter notebook, Dominicks_OJ_Sales_Forecasting.ipynb, from the directory into which you downloaded the install script.

  7. Run through the cells to try out the sample.

Install and get started on Ubuntu

Install the package on an Ubuntu DSVM

After provisioning the DSVM and completing the other prerequisites, you can download and install the package.

  1. SSH into the DSVM. Be sure to replace DSVM_IP with your DSVM IP. At the prompt, enter:

    ssh -L 8000:localhost:8000 username@DSVM_IP

    This SSH tunnel allows you to use JupyterHub on the DSVM without opening ports via Azure portal.

  2. Configure Docker. At the prompt, enter:

    sudo usermod -a -G docker $USER
  3. Disconnect from the DSVM.

  4. Reconnect to the DSVM via an SSH tunnel. Be sure to replace DSVM_IP with the IP for your DSVM. At the prompt, enter:

    ssh -L 8000:localhost:8000 username@DSVM_IP
  5. Download the installation script to a directory on the DSVM in which you plan to store the sample notebooks. At the prompt, enter:

    wget -O
  6. Run the package installation script from this directory. The installation can take up to 20 minutes. At the prompt, enter:


    Now you've installed the package. The best way to familiarize yourself with the workflow of this forecasting package is through its sample Jupyter notebooks.

Run the sample Jupyter notebook

This package is distributed with a sample Jupyter notebook you can use to explore the package.

  1. If you haven't already, log on to the DSVM, open a notebook session, and configure the kernel. These steps assume you have a Jupyter notebook session running with the correct kernel on your DSVM. If not, skip to the next section to start one.

  2. Open the notebook, Dominicks_OJ_Sales_Forecasting.ipynb, which is under ~/notebooks.

  3. Run through the cells to walk through the workflow.


    Enable operationalization in Azure Machine Learning. If your first call to deploy() in the downloaded Jupyter notebook sample fails, it might be due to a missing Kubernetes binary. Azure Machine Learning downloads it for you. Rerun the same notebook cell corrects the issue. More details can be found here.

Open a notebook session and configure the kernel

These steps assume you are connected to the DSVM with an SSH tunnel.

  1. In a command-line window, log in to connect your shell to Azure CLI using your Azure account:

    az login

    Follow the onscreen prompts to authenticate.

  2. From a browser on the DSVM, go to https://localhost:8000.

    Follow the onscreen prompts until the JupyterHub login window appears.


    If you encounter the “Your connection is not private” screen, follow Option 1. When shown the login screen, use the same credentials that you used to connect to the DSVM.

  3. From the JupyterHub menus, select Kernel > Change Kernel. Change the Jupyter Kernel to azuremlftk_may2018.

  4. Run the sample notebook, stored under ~/notebooks, or create your own.

    The default JupyterHub instance on the DSVM only serves notebooks stored under "~/notebooks".

Reconnect to an existing notebook session

If you get disconnected from the DSVM, the JupyterHub continues to run.

  1. Reconnect to the DSVM via an SSH tunnel. In the following command, be sure to replace DSVM_IP with the IP for your DSVM. At the prompt, enter:

    ssh -L 8000:localhost:8000 username@DSVM_IP
  2. If it has been a while, you may need to log in again from the command line with az login.

  3. Return to https://localhost:8000 in your browser.

Reporting issues

For help with any issues, you encounter using this package, contact