update samples - test

This commit is contained in:
vizhur
2019-11-01 14:48:01 +00:00
parent 46ec74f8df
commit 4ed3f0767a
308 changed files with 13971 additions and 59495 deletions

View File

@@ -13,16 +13,16 @@ Read more detailed instructions on [how to set up your environment](./NBSETUP.md
## How to navigate and use the example notebooks?
If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, you should always run the [Configuration](./configuration.ipynb) notebook first when setting up a notebook library on a new machine or in a new environment. It configures your notebook library to connect to an Azure Machine Learning workspace, and sets up your workspace and compute to be used by many of the other examples.
This [index](.index.md) should assist in navigating the Azure Machine Learning notebook samples and encourage efficient retrieval of topics and content.
If you want to...
* ...try out and explore Azure ML, start with image classification tutorials: [Part 1 (Training)](./tutorials/img-classification-part1-training.ipynb) and [Part 2 (Deployment)](./tutorials/img-classification-part2-deploy.ipynb).
* ...prepare your data and do automated machine learning, start with regression tutorials: [Part 1 (Data Prep)](./tutorials/regression-part1-data-prep.ipynb) and [Part 2 (Automated ML)](./tutorials/regression-part2-automated-ml.ipynb).
* ...learn about experimentation and tracking run history, first [train within Notebook](./how-to-use-azureml/training/train-within-notebook/train-within-notebook.ipynb), then try [training on remote VM](./how-to-use-azureml/training/train-on-remote-vm/train-on-remote-vm.ipynb) and [using logging APIs](./how-to-use-azureml/training/logging-api/logging-api.ipynb).
* ...train deep learning models at scale, first learn about [Machine Learning Compute](./how-to-use-azureml/training/train-on-amlcompute/train-on-amlcompute.ipynb), and then try [distributed hyperparameter tuning](./how-to-use-azureml/training-with-deep-learning/train-hyperparameter-tune-deploy-with-pytorch/train-hyperparameter-tune-deploy-with-pytorch.ipynb) and [distributed training](./how-to-use-azureml/training-with-deep-learning/distributed-pytorch-with-horovod/distributed-pytorch-with-horovod.ipynb).
* ...deploy models as a realtime scoring service, first learn the basics by [training within Notebook and deploying to Azure Container Instance](./how-to-use-azureml/training/train-within-notebook/train-within-notebook.ipynb), then learn how to [register and manage models, and create Docker images](./how-to-use-azureml/deployment/register-model-create-image-deploy-service/register-model-create-image-deploy-service.ipynb), and [production deploy models on Azure Kubernetes Cluster](./how-to-use-azureml/deployment/production-deploy-to-aks/production-deploy-to-aks.ipynb).
* ...deploy models as a batch scoring service, first [train a model within Notebook](./how-to-use-azureml/training/train-within-notebook/train-within-notebook.ipynb), learn how to [register and manage models](./how-to-use-azureml/deployment/register-model-create-image-deploy-service/register-model-create-image-deploy-service.ipynb), then [create Machine Learning Compute for scoring compute](./how-to-use-azureml/training/train-on-amlcompute/train-on-amlcompute.ipynb), and [use Machine Learning Pipelines to deploy your model](https://aka.ms/pl-batch-scoring).
* ...monitor your deployed models, learn about using [App Insights](./how-to-use-azureml/deployment/enable-app-insights-in-production-service/enable-app-insights-in-production-service.ipynb) and [model data collection](./how-to-use-azureml/deployment/enable-data-collection-for-models-in-aks/enable-data-collection-for-models-in-aks.ipynb).
* ...monitor your deployed models, learn about using [App Insights](./how-to-use-azureml/deployment/enable-app-insights-in-production-service/enable-app-insights-in-production-service.ipynb).
## Tutorials

View File

@@ -103,7 +103,7 @@
"source": [
"import azureml.core\n",
"\n",
"print(\"This notebook was created using version 1.0.69 of the Azure ML SDK\")\n",
"print(\"This notebook was created using version 1.0.72 of the Azure ML SDK\")\n",
"print(\"You are currently using version\", azureml.core.VERSION, \"of the Azure ML SDK\")"
]
},
@@ -214,7 +214,10 @@
"* You do not have permission to create a resource group if it's non-existing.\n",
"* You are not a subscription owner or contributor and no Azure ML workspaces have ever been created in this subscription\n",
"\n",
"If workspace creation fails, please work with your IT admin to provide you with the appropriate permissions or to provision the required resources."
"If workspace creation fails, please work with your IT admin to provide you with the appropriate permissions or to provision the required resources.\n",
"\n",
"**Note**: A Basic workspace is created by default. If you would like to create an Enterprise workspace, please specify sku = 'enterprise'.\n",
"Please visit our [pricing page](https://azure.microsoft.com/en-us/pricing/details/machine-learning/) for more details on our Enterprise edition.\n"
]
},
{
@@ -235,6 +238,7 @@
" resource_group = resource_group, \n",
" location = workspace_region,\n",
" create_resource_group = True,\n",
" sku = 'basic',\n",
" exist_ok = True)\n",
"ws.get_details()\n",
"\n",
@@ -357,7 +361,7 @@
"metadata": {
"authors": [
{
"name": "roastala"
"name": "ninhu"
}
],
"kernelspec": {

View File

@@ -1,48 +0,0 @@
name: rapids0.9
channels:
- nvidia
- rapidsai/label/xgboost
- rapidsai
- conda-forge
- numba
- pytorch
dependencies:
- python=3.7
- pytorch
- cudatoolkit=10.0
- dask-cuda=0.9.1
- cudf=0.9.*
- cuml=0.9.*
- cugraph=0.9.*
- rapidsai/label/xgboost::xgboost=0.90.rapidsdev1
- rapidsai/label/xgboost::dask-xgboost=0.2.*
- conda-forge::numpy=1.16.4
- cython
- dask
- distributed=2.3.2
- pynvml=8.0.2
- gcsfs
- requests
- jupyterhub
- jupyterlab
- matplotlib
- ipywidgets
- ipyvolume
- seaborn
- scipy
- pandas
- boost
- nodejs
- pytest
- pip
- pip:
- git+https://github.com/cupy/cupy.git
- setuptools
- torch
- torchvision
- pytorch-ignite
- graphviz
- networkx
- dask-kubernetes
- dask_labextension
- jupyterlab-nvdashboard

View File

@@ -0,0 +1,41 @@
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license.
import os
import numpy as np
import tensorflow as tf
from PIL import Image
from azureml.core import Model
def init():
global g_tf_sess
# pull down model from workspace
model_path = Model.get_model_path("mnist")
# contruct graph to execute
tf.reset_default_graph()
saver = tf.train.import_meta_graph(os.path.join(model_path, 'mnist-tf.model.meta'))
g_tf_sess = tf.Session(config=tf.ConfigProto(device_count={'GPU': 0}))
saver.restore(g_tf_sess, os.path.join(model_path, 'mnist-tf.model'))
def run(mini_batch):
print(f'run method start: {__file__}, run({mini_batch})')
resultList = []
in_tensor = g_tf_sess.graph.get_tensor_by_name("network/X:0")
output = g_tf_sess.graph.get_tensor_by_name("network/output/MatMul:0")
for image in mini_batch:
# prepare each image
data = Image.open(image)
np_im = np.array(data).reshape((1, 784))
# perform inference
inference_result = output.eval(feed_dict={in_tensor: np_im}, session=g_tf_sess)
# find best probability, and add to result list
best_result = np.argmax(inference_result)
resultList.append("{}: {}".format(os.path.basename(image), best_result))
return resultList

View File

@@ -0,0 +1,31 @@
import io
import pickle
import argparse
import numpy as np
from azureml.core.model import Model
from sklearn.linear_model import LogisticRegression
def init():
global iris_model
parser = argparse.ArgumentParser(description="Iris model serving")
parser.add_argument('--model_name', dest="model_name", required=True)
args, unknown_args = parser.parse_known_args()
model_path = Model.get_model_path(args.model_name)
with open(model_path, 'rb') as model_file:
iris_model = pickle.load(model_file)
def run(input_data):
# make inference
num_rows, num_cols = input_data.shape
pred = iris_model.predict(input_data).reshape((num_rows, 1))
# cleanup output
result = input_data.drop(input_data.columns[4:], axis=1)
result['variety'] = pred
return result

View File

@@ -0,0 +1,537 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved. \n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Using Azure Machine Learning Pipelines for Batch Inference\n",
"\n",
"In this notebook, we will demonstrate how to make predictions on large quantities of data asynchronously using the ML pipelines with Azure Machine Learning. Batch inference (or batch scoring) provides cost-effective inference, with unparalleled throughput for asynchronous applications. Batch prediction pipelines can scale to perform inference on terabytes of production data. Batch prediction is optimized for high throughput, fire-and-forget predictions for a large collection of data.\n",
"\n",
"> **Tip**\n",
"If your system requires low-latency processing (to process a single document or small set of documents quickly), use [real-time scoring](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-consume-web-service) instead of batch prediction.\n",
"\n",
"In this example will be take a digit identification model already-trained on MNIST dataset using the [AzureML training with deep learning example notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/training-with-deep-learning/train-hyperparameter-tune-deploy-with-keras/train-hyperparameter-tune-deploy-with-keras.ipynb), and run that trained model on some of the MNIST test images in batch. \n",
"\n",
"The input dataset used for this notebook differs from a standard MNIST dataset in that it has been converted to PNG images to demonstrate use of files as inputs to Batch Inference. A sample of PNG-converted images of the MNIST dataset were take from [this repository](https://github.com/myleott/mnist_png). \n",
"\n",
"The outline of this notebook is as follows:\n",
"\n",
"- Create a DataStore referencing MNIST images stored in a blob container.\n",
"- Register the pretrained MNIST model into the model registry. \n",
"- Use the registered model to do batch inference on the images in the data blob container.\n",
"\n",
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/machine-learning-pipelines/contrib/batch_inferencing/file-dataset-image-inference-mnist.png)\n",
"\n",
"## Prerequisites\n",
"If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, make sure you go through the configuration Notebook located at https://github.com/Azure/MachineLearningNotebooks first. This sets you up with a working config file that has information on your workspace, subscription id, etc. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Connect to workspace\n",
"Create a workspace object from the existing workspace. Workspace.from_config() reads the file config.json and loads the details into an object named ws."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Workspace\n",
"\n",
"ws = Workspace.from_config()\n",
"print('Workspace name: ' + ws.name, \n",
" 'Azure region: ' + ws.location, \n",
" 'Subscription id: ' + ws.subscription_id, \n",
" 'Resource group: ' + ws.resource_group, sep = '\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create or Attach existing compute resource\n",
"By using Azure Machine Learning Compute, a managed service, data scientists can train machine learning models on clusters of Azure virtual machines. Examples include VMs with GPU support. In this tutorial, you create Azure Machine Learning Compute as your training environment. The code below creates the compute clusters for you if they don't already exist in your workspace.\n",
"\n",
"**Creation of compute takes approximately 5 minutes. If the AmlCompute with that name is already in your workspace the code will skip the creation process.**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from azureml.core.compute import AmlCompute, ComputeTarget\n",
"from azureml.core.compute_target import ComputeTargetException\n",
"\n",
"# choose a name for your cluster\n",
"compute_name = os.environ.get(\"AML_COMPUTE_CLUSTER_NAME\", \"cpu-cluster\")\n",
"compute_min_nodes = os.environ.get(\"AML_COMPUTE_CLUSTER_MIN_NODES\", 0)\n",
"compute_max_nodes = os.environ.get(\"AML_COMPUTE_CLUSTER_MAX_NODES\", 4)\n",
"\n",
"# This example uses CPU VM. For using GPU VM, set SKU to STANDARD_NC6\n",
"vm_size = os.environ.get(\"AML_COMPUTE_CLUSTER_SKU\", \"STANDARD_D2_V2\")\n",
"\n",
"\n",
"if compute_name in ws.compute_targets:\n",
" compute_target = ws.compute_targets[compute_name]\n",
" if compute_target and type(compute_target) is AmlCompute:\n",
" print('found compute target. just use it. ' + compute_name)\n",
"else:\n",
" print('creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = vm_size,\n",
" min_nodes = compute_min_nodes, \n",
" max_nodes = compute_max_nodes)\n",
"\n",
" # create the cluster\n",
" compute_target = ComputeTarget.create(ws, compute_name, provisioning_config)\n",
" \n",
" # can poll for a minimum number of nodes and for a specific timeout. \n",
" # if no min node count is provided it will use the scale settings for the cluster\n",
" compute_target.wait_for_completion(show_output=True, min_node_count=None, timeout_in_minutes=20)\n",
" \n",
" # For a more detailed view of current AmlCompute status, use get_status()\n",
" print(compute_target.get_status().serialize())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create a datastore containing sample images\n",
"The input dataset used for this notebook differs from a standard MNIST dataset in that it has been converted to PNG images to demonstrate use of files as inputs to Batch Inference. A sample of PNG-converted images of the MNIST dataset were take from [this repository](https://github.com/myleott/mnist_png).\n",
"\n",
"We have created a public blob container `sampledata` on an account named `pipelinedata`, containing these images from the MNIST dataset. In the next step, we create a datastore with the name `images_datastore`, which points to this blob container. In the call to `register_azure_blob_container` below, setting the `overwrite` flag to `True` overwrites any datastore that was created previously with that name. \n",
"\n",
"This step can be changed to point to your blob container by providing your own `datastore_name`, `container_name`, and `account_name`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.datastore import Datastore\n",
"\n",
"account_name = \"pipelinedata\"\n",
"datastore_name = \"mnist_datastore\"\n",
"container_name = \"sampledata\"\n",
"\n",
"mnist_data = Datastore.register_azure_blob_container(ws, \n",
" datastore_name=datastore_name, \n",
" container_name= container_name, \n",
" account_name=account_name,\n",
" overwrite=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, let's specify the default datastore for the outputs."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def_data_store = ws.get_default_datastore()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create a FileDataset\n",
"A [FileDataset](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.data.filedataset?view=azure-ml-py) references single or multiple files in your datastores or public urls. The files can be of any format. FileDataset provides you with the ability to download or mount the files to your compute. By creating a dataset, you create a reference to the data source location. If you applied any subsetting transformations to the dataset, they will be stored in the dataset as well. The data remains in its existing location, so no extra storage cost is incurred."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.dataset import Dataset\n",
"\n",
"mnist_ds_name = 'mnist_sample_data'\n",
"\n",
"path_on_datastore = mnist_data.path('mnist')\n",
"input_mnist_ds = Dataset.File.from_files(path=path_on_datastore, validate=False)\n",
"registered_mnist_ds = input_mnist_ds.register(ws, mnist_ds_name, create_new_version=True)\n",
"named_mnist_ds = registered_mnist_ds.as_named_input(mnist_ds_name)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Intermediate/Output Data\n",
"Intermediate data (or output of a Step) is represented by [PipelineData](https://docs.microsoft.com/en-us/python/api/azureml-pipeline-core/azureml.pipeline.core.pipelinedata?view=azure-ml-py) object. PipelineData can be produced by one step and consumed in another step by providing the PipelineData object as an output of one step and the input of one or more steps.\n",
"\n",
"**Constructing PipelineData**\n",
"- name: [Required] Name of the data item within the pipeline graph\n",
"- datastore_name: Name of the Datastore to write this output to\n",
"- output_name: Name of the output\n",
"- output_mode: Specifies \"upload\" or \"mount\" modes for producing output (default: mount)\n",
"- output_path_on_compute: For \"upload\" mode, the path to which the module writes this output during execution\n",
"- output_overwrite: Flag to overwrite pre-existing data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.pipeline.core import Pipeline, PipelineData\n",
"\n",
"output_dir = PipelineData(name=\"inferences\", \n",
" datastore=def_data_store, \n",
" output_path_on_compute=\"mnist/results\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Download the Model\n",
"\n",
"Download and extract the model from https://pipelinedata.blob.core.windows.net/mnist-model/mnist-tf.tar.gz to \"models\" directory"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import tarfile\n",
"import urllib.request\n",
"\n",
"# create directory for model\n",
"model_dir = 'models'\n",
"if not os.path.isdir(model_dir):\n",
" os.mkdir(model_dir)\n",
"\n",
"url=\"https://pipelinedata.blob.core.windows.net/mnist-model/mnist-tf.tar.gz\"\n",
"response = urllib.request.urlretrieve(url, \"model.tar.gz\")\n",
"tar = tarfile.open(\"model.tar.gz\", \"r:gz\")\n",
"tar.extractall(model_dir)\n",
"\n",
"os.listdir(model_dir)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Register the model with Workspace\n",
"A registered model is a logical container for one or more files that make up your model. For example, if you have a model that's stored in multiple files, you can register them as a single model in the workspace. After you register the files, you can then download or deploy the registered model and receive all the files that you registered.\n",
"\n",
"Using tags, you can track useful information such as the name and version of the machine learning library used to train the model. Note that tags must be alphanumeric. Learn more about registering models [here](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-deploy-and-where#registermodel) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.model import Model\n",
"\n",
"# register downloaded model \n",
"model = Model.register(model_path = \"models/\",\n",
" model_name = \"mnist\", # this is the name the model is registered as\n",
" tags = {'pretrained': \"mnist\"},\n",
" description = \"Mnist trained tensorflow model\",\n",
" workspace = ws)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Using your model to make batch predictions\n",
"To use the model to make batch predictions, you need an **entry script** and a list of **dependencies**:\n",
"\n",
"#### An entry script\n",
"This script accepts requests, scores the requests by using the model, and returns the results.\n",
"- __init()__ - Typically this function loads the model into a global object. This function is run only once at the start of batch processing per worker node/process. Init method can make use of following environment variables (ParallelRunStep input):\n",
" 1.\tAZUREML_BI_OUTPUT_PATH \u00e2\u20ac\u201c output folder path\n",
"- __run(mini_batch)__ - The method to be parallelized. Each invocation will have one minibatch.<BR>\n",
"__mini_batch__: Batch inference will invoke run method and pass either a list or Pandas DataFrame as an argument to the method. Each entry in min_batch will be - a filepath if input is a FileDataset, a Pandas DataFrame if input is a TabularDataset.<BR>\n",
"__run__ method response: run() method should return a Pandas DataFrame or an array. For append_row output_action, these returned elements are appended into the common output file. For summary_only, the contents of the elements are ignored. For all output actions, each returned output element indicates one successful inference of input element in the input mini-batch.\n",
" User should make sure that enough data is included in inference result to map input to inference. Inference output will be written in output file and not guaranteed to be in order, user should use some key in the output to map it to input.\n",
" \n",
"\n",
"#### Dependencies\n",
"Helper scripts or Python/Conda packages required to run the entry script or model.\n",
"\n",
"The deployment configuration for the compute target that hosts the deployed model. This configuration describes things like memory and CPU requirements needed to run the model.\n",
"\n",
"These items are encapsulated into an inference configuration and a deployment configuration. The inference configuration references the entry script and other dependencies. You define these configurations programmatically when you use the SDK to perform the deployment. You define them in JSON files when you use the CLI."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"scripts_folder = \"Code\"\n",
"script_file = \"digit_identification.py\"\n",
"\n",
"# peek at contents\n",
"with open(os.path.join(scripts_folder, script_file)) as inference_file:\n",
" print(inference_file.read())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Build and run the batch inference pipeline\n",
"The data, models, and compute resource are now available. Let's put all these together in a pipeline."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Specify the environment to run the script\n",
"Specify the conda dependencies for your script. This will allow us to install pip packages as well as configure the inference environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Environment\n",
"from azureml.core.runconfig import CondaDependencies, DEFAULT_CPU_IMAGE\n",
"\n",
"batch_conda_deps = CondaDependencies.create(pip_packages=[\"tensorflow==1.13.1\", \"pillow\"])\n",
"\n",
"batch_env = Environment(name=\"batch_environment\")\n",
"batch_env.python.conda_dependencies = batch_conda_deps\n",
"batch_env.docker.enabled = True\n",
"batch_env.docker.base_image = DEFAULT_CPU_IMAGE"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create the configuration to wrap the inference script"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.contrib.pipeline.steps import ParallelRunStep, ParallelRunConfig\n",
"\n",
"parallel_run_config = ParallelRunConfig(\n",
" source_directory=scripts_folder,\n",
" entry_script=script_file,\n",
" mini_batch_size=\"5\",\n",
" error_threshold=10,\n",
" output_action=\"append_row\",\n",
" environment=batch_env,\n",
" compute_target=compute_target,\n",
" node_count=2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create the pipeline step\n",
"Create the pipeline step using the script, environment configuration, and parameters. Specify the compute target you already attached to your workspace as the target of execution of the script. We will use ParallelRunStep to create the pipeline step."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"parallelrun_step = ParallelRunStep(\n",
" name=\"predict-digits-mnist\",\n",
" parallel_run_config=parallel_run_config,\n",
" inputs=[ named_mnist_ds ],\n",
" output=output_dir,\n",
" models=[ model ],\n",
" arguments=[ ],\n",
" allow_reuse=True\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Run the pipeline\n",
"At this point you can run the pipeline and examine the output it produced. The Experiment object is used to track the run of the pipeline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Experiment\n",
"\n",
"pipeline = Pipeline(workspace=ws, steps=[parallelrun_step])\n",
"experiment = Experiment(ws, 'digit_identification')\n",
"pipeline_run = experiment.submit(pipeline)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Monitor the run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(pipeline_run).show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Optional: View detailed logs (streaming) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pipeline_run.wait_for_completion(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### View the prediction results per input image\n",
"In the score.py file above you can see that the ResultList with the filename and the prediction result gets returned. These are written to the DataStore specified in the PipelineData object as the output data, which in this case is called *inferences*. This containers the outputs from all of the worker nodes used in the compute cluster. You can download this data to view the results ... below just filters to the first 10 rows"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import shutil\n",
"\n",
"# remove previous run results, if present\n",
"shutil.rmtree(\"mnist_results\", ignore_errors=True)\n",
"\n",
"batch_run = next(pipeline_run.get_children())\n",
"batch_output = batch_run.get_output_data(\"inferences\")\n",
"batch_output.download(local_path=\"mnist_results\")\n",
"\n",
"for root, dirs, files in os.walk(\"mnist_results\"):\n",
" for file in files:\n",
" if file.endswith('parallel_run_step.txt'):\n",
" result_file = os.path.join(root,file)\n",
"\n",
"df = pd.read_csv(result_file, delimiter=\":\", header=None)\n",
"df.columns = [\"Filename\", \"Prediction\"]\n",
"print(\"Prediction has \", df.shape[0], \" rows\")\n",
"df.head(10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Cleanup Compute resources\n",
"\n",
"For re-occuring jobs, it may be wise to keep compute the compute resources and allow compute nodes to scale down to 0. However, since this is just a single-run job, we are free to release the allocated compute resources."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# uncomment below and run if compute resources are no longer needed \n",
"# compute_target.delete() "
]
}
],
"metadata": {
"authors": [
{
"name": "joringer"
},
{
"name": "asraniwa"
},
{
"name": "pansav"
},
{
"name": "tracych"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"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"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,7 @@
name: file-dataset-image-inference-mnist
dependencies:
- pip:
- azureml-sdk
- azureml-contrib-pipeline-steps
- pandas
- azureml-widgets

View File

@@ -0,0 +1,513 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved. \n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Using Azure Machine Learning Pipelines for Batch Inference for CSV Files\n",
"\n",
"In this notebook, we will demonstrate how to make predictions on large quantities of data asynchronously using the ML pipelines with Azure Machine Learning. Batch inference (or batch scoring) provides cost-effective inference, with unparalleled throughput for asynchronous applications. Batch prediction pipelines can scale to perform inference on terabytes of production data. Batch prediction is optimized for high throughput, fire-and-forget predictions for a large collection of data.\n",
"\n",
"> **Tip**\n",
"If your system requires low-latency processing (to process a single document or small set of documents quickly), use [real-time scoring](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-consume-web-service) instead of batch prediction.\n",
"\n",
"In this example we will take use a machine learning model already trained to predict different types of iris flowers and run that trained model on some of the data in a CSV file which has characteristics of different iris flowers. However, the same example can be extended to manipulating data to any embarrassingly-parallel processing through a python script.\n",
"\n",
"The outline of this notebook is as follows:\n",
"\n",
"- Create a DataStore referencing the CSV files stored in a blob container.\n",
"- Register the pretrained model into the model registry. \n",
"- Use the registered model to do batch inference on the CSV files in the data blob container.\n",
"\n",
"## Prerequisites\n",
"If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, make sure you go through the configuration Notebook located at https://github.com/Azure/MachineLearningNotebooks first. This sets you up with a working config file that has information on your workspace, subscription id, etc. \n",
"\n",
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/machine-learning-pipelines/contrib/batch_inferencing/tabular-dataset-inference-iris.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Connect to workspace\n",
"Create a workspace object from the existing workspace. Workspace.from_config() reads the file config.json and loads the details into an object named ws."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Workspace\n",
"\n",
"ws = Workspace.from_config()\n",
"print('Workspace name: ' + ws.name, \n",
" 'Azure region: ' + ws.location, \n",
" 'Subscription id: ' + ws.subscription_id, \n",
" 'Resource group: ' + ws.resource_group, sep = '\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create or Attach existing compute resource\n",
"By using Azure Machine Learning Compute, a managed service, data scientists can train machine learning models on clusters of Azure virtual machines. Examples include VMs with GPU support. In this tutorial, you create Azure Machine Learning Compute as your training environment. The code below creates the compute clusters for you if they don't already exist in your workspace.\n",
"\n",
"**Creation of compute takes approximately 5 minutes. If the AmlCompute with that name is already in your workspace the code will skip the creation process.**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from azureml.core.compute import AmlCompute, ComputeTarget\n",
"from azureml.core.compute_target import ComputeTargetException\n",
"\n",
"# choose a name for your cluster\n",
"compute_name = os.environ.get(\"AML_COMPUTE_CLUSTER_NAME\", \"cpu-cluster\")\n",
"compute_min_nodes = os.environ.get(\"AML_COMPUTE_CLUSTER_MIN_NODES\", 0)\n",
"compute_max_nodes = os.environ.get(\"AML_COMPUTE_CLUSTER_MAX_NODES\", 4)\n",
"\n",
"# This example uses CPU VM. For using GPU VM, set SKU to STANDARD_NC6\n",
"vm_size = os.environ.get(\"AML_COMPUTE_CLUSTER_SKU\", \"STANDARD_D2_V2\")\n",
"\n",
"\n",
"if compute_name in ws.compute_targets:\n",
" compute_target = ws.compute_targets[compute_name]\n",
" if compute_target and type(compute_target) is AmlCompute:\n",
" print('found compute target. just use it. ' + compute_name)\n",
"else:\n",
" print('creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = vm_size,\n",
" min_nodes = compute_min_nodes, \n",
" max_nodes = compute_max_nodes)\n",
"\n",
" # create the cluster\n",
" compute_target = ComputeTarget.create(ws, compute_name, provisioning_config)\n",
" \n",
" # can poll for a minimum number of nodes and for a specific timeout. \n",
" # if no min node count is provided it will use the scale settings for the cluster\n",
" compute_target.wait_for_completion(show_output=True, min_node_count=None, timeout_in_minutes=20)\n",
" \n",
" # For a more detailed view of current AmlCompute status, use get_status()\n",
" print(compute_target.get_status().serialize())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create a datastore containing sample images\n",
"The input dataset used for this notebook is CSV data which has attributes of different iris flowers. We have created a public blob container `sampledata` on an account named `pipelinedata`, containing iris data set. In the next step, we create a datastore with the name `iris_datastore`, which points to this container. In the call to `register_azure_blob_container` below, setting the `overwrite` flag to `True` overwrites any datastore that was created previously with that name. \n",
"\n",
"This step can be changed to point to your blob container by providing your own `datastore_name`, `container_name`, and `account_name`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.datastore import Datastore\n",
"\n",
"account_name = \"pipelinedata\"\n",
"datastore_name=\"iris_datastore_data\"\n",
"container_name=\"sampledata\"\n",
"\n",
"iris_data = Datastore.register_azure_blob_container(ws, \n",
" datastore_name=datastore_name, \n",
" container_name= container_name, \n",
" account_name=account_name, \n",
" overwrite=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create a TabularDataset\n",
"A [TabularDataSet](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.data.tabulardataset?view=azure-ml-py) references single or multiple files which contain data in a tabular structure (ie like CSV files) in your datastores or public urls. TabularDatasets provides you with the ability to download or mount the files to your compute. By creating a dataset, you create a reference to the data source location. If you applied any subsetting transformations to the dataset, they will be stored in the dataset as well. The data remains in its existing location, so no extra storage cost is incurred."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.dataset import Dataset\n",
"\n",
"iris_ds_name = 'iris_data'\n",
"\n",
"path_on_datastore = iris_data.path('iris/')\n",
"input_iris_ds = Dataset.Tabular.from_delimited_files(path=path_on_datastore, validate=False)\n",
"registered_iris_ds = input_iris_ds.register(ws, iris_ds_name, create_new_version=True)\n",
"named_iris_ds = registered_iris_ds.as_named_input(iris_ds_name)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Intermediate/Output Data\n",
"Intermediate data (or output of a Step) is represented by [PipelineData](https://docs.microsoft.com/en-us/python/api/azureml-pipeline-core/azureml.pipeline.core.pipelinedata?view=azure-ml-py) object. PipelineData can be produced by one step and consumed in another step by providing the PipelineData object as an output of one step and the input of one or more steps.\n",
"\n",
"**Constructing PipelineData**\n",
"- name: [Required] Name of the data item within the pipeline graph\n",
"- datastore_name: Name of the Datastore to write this output to\n",
"- output_name: Name of the output\n",
"- output_mode: Specifies \"upload\" or \"mount\" modes for producing output (default: mount)\n",
"- output_path_on_compute: For \"upload\" mode, the path to which the module writes this output during execution\n",
"- output_overwrite: Flag to overwrite pre-existing data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.pipeline.core import PipelineData\n",
"\n",
"datastore = ws.get_default_datastore()\n",
"output_folder = PipelineData(name='inferences', datastore=datastore)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Registering the Model with the Workspace\n",
"Get the pretrained model from a publicly available Azure Blob container, then register it to use in your workspace"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"model_container_name=\"iris-model\"\n",
"model_datastore_name=\"iris_model_datastore\"\n",
"\n",
"model_datastore = Datastore.register_azure_blob_container(ws, \n",
" datastore_name=model_datastore_name, \n",
" container_name= model_container_name, \n",
" account_name=account_name, \n",
" overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.model import Model\n",
"\n",
"model_datastore.download('iris_model.pkl')\n",
"\n",
"# register downloaded model\n",
"model = Model.register(model_path = \"iris_model.pkl/iris_model.pkl\",\n",
" model_name = \"iris\", # this is the name the model is registered as\n",
" tags = {'pretrained': \"iris\"},\n",
" workspace = ws)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Using your model to make batch predictions\n",
"To use the model to make batch predictions, you need an **entry script** and a list of **dependencies**:\n",
"\n",
"#### An entry script\n",
"This script accepts requests, scores the requests by using the model, and returns the results.\n",
"- __init()__ - Typically this function loads the model into a global object. This function is run only once at the start of batch processing per worker node/process. init method can make use of following environment variables (ParallelRunStep input):\n",
" 1.\tAZUREML_BI_OUTPUT_PATH \u00e2\u20ac\u201c output folder path\n",
"- __run(mini_batch)__ - The method to be parallelized. Each invocation will have one minibatch.<BR>\n",
"__mini_batch__: Batch inference will invoke run method and pass either a list or Pandas DataFrame as an argument to the method. Each entry in min_batch will be - a filepath if input is a FileDataset, a Pandas DataFrame if input is a TabularDataset.<BR>\n",
"__run__ method response: run() method should return a Pandas DataFrame or an array. For append_row output_action, these returned elements are appended into the common output file. For summary_only, the contents of the elements are ignored. For all output actions, each returned output element indicates one successful inference of input element in the input mini-batch.\n",
" User should make sure that enough data is included in inference result to map input to inference. Inference output will be written in output file and not guaranteed to be in order, user should use some key in the output to map it to input.\n",
" \n",
"\n",
"#### Dependencies\n",
"Helper scripts or Python/Conda packages required to run the entry script or model.\n",
"\n",
"The deployment configuration for the compute target that hosts the deployed model. This configuration describes things like memory and CPU requirements needed to run the model.\n",
"\n",
"These items are encapsulated into an inference configuration and a deployment configuration. The inference configuration references the entry script and other dependencies. You define these configurations programmatically when you use the SDK to perform the deployment. You define them in JSON files when you use the CLI.\n",
"\n",
"## Print inferencing script"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scripts_folder = \"Code\"\n",
"script_file = \"iris_score.py\"\n",
"\n",
"# peek at contents\n",
"with open(os.path.join(scripts_folder, script_file)) as inference_file:\n",
" print(inference_file.read())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Build and run the batch inference pipeline\n",
"The data, models, and compute resource are now available. Let's put all these together in a pipeline."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Specify the environment to run the script\n",
"Specify the conda dependencies for your script. This will allow us to install pip packages as well as configure the inference environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Environment\n",
"from azureml.core.runconfig import CondaDependencies\n",
"\n",
"predict_conda_deps = CondaDependencies.create(pip_packages=[ \"scikit-learn==0.20.3\" ])\n",
"\n",
"predict_env = Environment(name=\"predict_environment\")\n",
"predict_env.python.conda_dependencies = predict_conda_deps\n",
"predict_env.docker.enabled = True\n",
"predict_env.spark.precache_packages = False"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create the configuration to wrap the inference script"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.contrib.pipeline.steps import ParallelRunStep, ParallelRunConfig\n",
"\n",
"# In a real-world scenario, you'll want to shape your process per node and nodes to fit your problem domain.\n",
"parallel_run_config = ParallelRunConfig(\n",
" source_directory=scripts_folder,\n",
" entry_script=script_file, # the user script to run against each input\n",
" mini_batch_size='5MB',\n",
" error_threshold=5,\n",
" output_action='append_row',\n",
" environment=predict_env,\n",
" compute_target=compute_target, \n",
" node_count=3,\n",
" run_invocation_timeout=600)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create the pipeline step\n",
"Create the pipeline step using the script, environment configuration, and parameters. Specify the compute target you already attached to your workspace as the target of execution of the script. We will use ParallelRunStep to create the pipeline step."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"distributed_csv_iris_step = ParallelRunStep(\n",
" name='example-iris',\n",
" inputs=[named_iris_ds],\n",
" output=output_folder,\n",
" parallel_run_config=parallel_run_config,\n",
" models=[model],\n",
" arguments=['--model_name', 'iris'],\n",
" allow_reuse=True\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Run the pipeline\n",
"At this point you can run the pipeline and examine the output it produced. The Experiment object is used to track the run of the pipeline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Experiment\n",
"from azureml.pipeline.core import Pipeline\n",
"\n",
"pipeline = Pipeline(workspace=ws, steps=[distributed_csv_iris_step])\n",
"\n",
"pipeline_run = Experiment(ws, 'iris').submit(pipeline)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# this will output a table with link to the run details in azure portal\n",
"pipeline_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## View progress of Pipeline run\n",
"\n",
"The progress of the pipeline is able to be viewed either through azureml.widgets or a console feed from PipelineRun.wait_for_completion()."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# GUI\n",
"from azureml.widgets import RunDetails\n",
"RunDetails(pipeline_run).show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Console logs\n",
"pipeline_run.wait_for_completion(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## View Results\n",
"In the iris_score.py file above you can see that the Result with the prediction of the iris variety gets returned and then appended to the original input of the row from the csv file. These results are written to the DataStore specified in the PipelineData object as the output data, which in this case is called *inferences*. This contains the outputs from all of the worker nodes used in the compute cluster. You can download this data to view the results ... below just filters to a random 20 rows"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import shutil\n",
"\n",
"shutil.rmtree(\"iris_results\", ignore_errors=True)\n",
"\n",
"prediction_run = next(pipeline_run.get_children())\n",
"prediction_output = prediction_run.get_output_data(\"inferences\")\n",
"prediction_output.download(local_path=\"iris_results\")\n",
"\n",
"\n",
"for root, dirs, files in os.walk(\"iris_results\"):\n",
" for file in files:\n",
" if file.endswith('parallel_run_step.txt'):\n",
" result_file = os.path.join(root,file)\n",
"\n",
"# cleanup output format\n",
"df = pd.read_csv(result_file, delimiter=\" \", header=None)\n",
"df.columns = [\"sepal.length\", \"sepal.width\", \"petal.length\", \"petal.width\", \"variety\"]\n",
"print(\"Prediction has \", df.shape[0], \" rows\")\n",
"\n",
"random_subset = df.sample(n=20)\n",
"random_subset.head(20)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Cleanup compute resources\n",
"For re-occuring jobs, it may be wise to keep compute the compute resources and allow compute nodes to scale down to 0. However, since this is just a single run job, we are free to release the allocated compute resources."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# uncomment below and run if compute resources are no longer needed \n",
"# compute_target.delete()"
]
}
],
"metadata": {
"authors": [
{
"name": "joringer"
},
{
"name": "asraniwa"
},
{
"name": "pansav"
},
{
"name": "tracych"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
},
"notice": "Copyright (c) Microsoft Corporation. All rights reserved.\u00e2\u20ac\u00afLicensed under the MIT License."
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,7 @@
name: tabular-dataset-inference-iris
dependencies:
- pip:
- azureml-sdk
- azureml-contrib-pipeline-steps
- pandas
- azureml-widgets

View File

@@ -1,270 +1,270 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved. \n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/contrib/gbdt/lightgbm/lightgbm-example.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Use LightGBM Estimator in Azure Machine Learning\n",
"In this notebook we will demonstrate how to run a training job using LightGBM Estimator. [LightGBM](https://lightgbm.readthedocs.io/en/latest/) is a gradient boosting framework that uses tree based learning algorithms. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Prerequisites\n",
"This notebook uses azureml-contrib-gbdt package, if you don't already have the package, please install by uncommenting below cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#!pip install azureml-contrib-gbdt --extra-index-url https://azuremlsdktestpypi.azureedge.net/LightGBMPrivateRelease"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Workspace, Run, Experiment\n",
"import shutil, os\n",
"from azureml.widgets import RunDetails\n",
"from azureml.contrib.gbdt import LightGBM\n",
"from azureml.train.dnn import Mpi\n",
"from azureml.core.compute import AmlCompute, ComputeTarget\n",
"from azureml.core.compute_target import ComputeTargetException"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you are using an AzureML Compute Instance, you are all set. Otherwise, go through the [configuration.ipynb](../../../configuration.ipynb) notebook to install the Azure Machine Learning Python SDK and create an Azure ML Workspace"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set up machine learning resources"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"print('Workspace name: ' + ws.name, \n",
" 'Azure region: ' + ws.location, \n",
" 'Subscription id: ' + ws.subscription_id, \n",
" 'Resource group: ' + ws.resource_group, sep = '\\n')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cluster_vm_size = \"STANDARD_DS14_V2\"\n",
"cluster_min_nodes = 0\n",
"cluster_max_nodes = 20\n",
"cpu_cluster_name = 'TrainingCompute' \n",
"\n",
"try:\n",
" cpu_cluster = AmlCompute(ws, cpu_cluster_name)\n",
" if cpu_cluster and type(cpu_cluster) is AmlCompute:\n",
" print('found compute target: ' + cpu_cluster_name)\n",
"except ComputeTargetException:\n",
" print('creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = cluster_vm_size, \n",
" vm_priority = 'lowpriority', \n",
" min_nodes = cluster_min_nodes, \n",
" max_nodes = cluster_max_nodes)\n",
" cpu_cluster = ComputeTarget.create(ws, cpu_cluster_name, provisioning_config)\n",
" \n",
" # can poll for a minimum number of nodes and for a specific timeout. \n",
" # if no min node count is provided it will use the scale settings for the cluster\n",
" cpu_cluster.wait_for_completion(show_output=True, min_node_count=None, timeout_in_minutes=20)\n",
" \n",
" # For a more detailed view of current Azure Machine Learning Compute status, use get_status()\n",
" print(cpu_cluster.get_status().serialize())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"From this point, you can either upload training data file directly or use Datastore for training data storage\n",
"## Upload training file from local"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scripts_folder = \"scripts_folder\"\n",
"if not os.path.isdir(scripts_folder):\n",
" os.mkdir(scripts_folder)\n",
"shutil.copy('./train.conf', os.path.join(scripts_folder, 'train.conf'))\n",
"shutil.copy('./binary0.train', os.path.join(scripts_folder, 'binary0.train'))\n",
"shutil.copy('./binary1.train', os.path.join(scripts_folder, 'binary1.train'))\n",
"shutil.copy('./binary0.test', os.path.join(scripts_folder, 'binary0.test'))\n",
"shutil.copy('./binary1.test', os.path.join(scripts_folder, 'binary1.test'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"training_data_list=[\"binary0.train\", \"binary1.train\"]\n",
"validation_data_list = [\"binary0.test\", \"binary1.test\"]\n",
"lgbm = LightGBM(source_directory=scripts_folder, \n",
" compute_target=cpu_cluster, \n",
" distributed_training=Mpi(),\n",
" node_count=2,\n",
" lightgbm_config='train.conf',\n",
" data=training_data_list,\n",
" valid=validation_data_list\n",
" )\n",
"experiment_name = 'lightgbm-estimator-test'\n",
"experiment = Experiment(ws, name=experiment_name)\n",
"run = experiment.submit(lgbm, tags={\"test public docker image\": None})\n",
"RunDetails(run).show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"run.wait_for_completion(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Use data reference"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.datastore import Datastore\n",
"from azureml.data.data_reference import DataReference\n",
"datastore = ws.get_default_datastore()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"datastore.upload(src_dir='.',\n",
" target_path='.',\n",
" show_progress=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"training_data_list=[\"binary0.train\", \"binary1.train\"]\n",
"validation_data_list = [\"binary0.test\", \"binary1.test\"]\n",
"lgbm = LightGBM(source_directory='.', \n",
" compute_target=cpu_cluster, \n",
" distributed_training=Mpi(),\n",
" node_count=2,\n",
" inputs=[datastore.as_mount()],\n",
" lightgbm_config='train.conf',\n",
" data=training_data_list,\n",
" valid=validation_data_list\n",
" )\n",
"experiment_name = 'lightgbm-estimator-test'\n",
"experiment = Experiment(ws, name=experiment_name)\n",
"run = experiment.submit(lgbm, tags={\"use datastore.as_mount()\": None})\n",
"RunDetails(run).show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"run.wait_for_completion(show_output=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# uncomment below and run if compute resources are no longer needed\n",
"# cpu_cluster.delete() "
]
}
],
"metadata": {
"authors": [
{
"name": "jingywa"
}
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved. \n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/contrib/gbdt/lightgbm/lightgbm-example.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Use LightGBM Estimator in Azure Machine Learning\n",
"In this notebook we will demonstrate how to run a training job using LightGBM Estimator. [LightGBM](https://lightgbm.readthedocs.io/en/latest/) is a gradient boosting framework that uses tree based learning algorithms. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Prerequisites\n",
"This notebook uses azureml-contrib-gbdt package, if you don't already have the package, please install by uncommenting below cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#!pip install azureml-contrib-gbdt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Workspace, Run, Experiment\n",
"import shutil, os\n",
"from azureml.widgets import RunDetails\n",
"from azureml.contrib.gbdt import LightGBM\n",
"from azureml.train.dnn import Mpi\n",
"from azureml.core.compute import AmlCompute, ComputeTarget\n",
"from azureml.core.compute_target import ComputeTargetException"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you are using an AzureML Compute Instance, you are all set. Otherwise, go through the [configuration.ipynb](../../../configuration.ipynb) notebook to install the Azure Machine Learning Python SDK and create an Azure ML Workspace"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set up machine learning resources"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"print('Workspace name: ' + ws.name, \n",
" 'Azure region: ' + ws.location, \n",
" 'Subscription id: ' + ws.subscription_id, \n",
" 'Resource group: ' + ws.resource_group, sep = '\\n')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cluster_vm_size = \"STANDARD_DS14_V2\"\n",
"cluster_min_nodes = 0\n",
"cluster_max_nodes = 20\n",
"cpu_cluster_name = 'TrainingCompute2' \n",
"\n",
"try:\n",
" cpu_cluster = AmlCompute(ws, cpu_cluster_name)\n",
" if cpu_cluster and type(cpu_cluster) is AmlCompute:\n",
" print('found compute target: ' + cpu_cluster_name)\n",
"except ComputeTargetException:\n",
" print('creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = cluster_vm_size, \n",
" vm_priority = 'lowpriority', \n",
" min_nodes = cluster_min_nodes, \n",
" max_nodes = cluster_max_nodes)\n",
" cpu_cluster = ComputeTarget.create(ws, cpu_cluster_name, provisioning_config)\n",
" \n",
" # can poll for a minimum number of nodes and for a specific timeout. \n",
" # if no min node count is provided it will use the scale settings for the cluster\n",
" cpu_cluster.wait_for_completion(show_output=True, min_node_count=None, timeout_in_minutes=20)\n",
" \n",
" # For a more detailed view of current Azure Machine Learning Compute status, use get_status()\n",
" print(cpu_cluster.get_status().serialize())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"From this point, you can either upload training data file directly or use Datastore for training data storage\n",
"## Upload training file from local"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scripts_folder = \"scripts_folder\"\n",
"if not os.path.isdir(scripts_folder):\n",
" os.mkdir(scripts_folder)\n",
"shutil.copy('./train.conf', os.path.join(scripts_folder, 'train.conf'))\n",
"shutil.copy('./binary0.train', os.path.join(scripts_folder, 'binary0.train'))\n",
"shutil.copy('./binary1.train', os.path.join(scripts_folder, 'binary1.train'))\n",
"shutil.copy('./binary0.test', os.path.join(scripts_folder, 'binary0.test'))\n",
"shutil.copy('./binary1.test', os.path.join(scripts_folder, 'binary1.test'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"training_data_list=[\"binary0.train\", \"binary1.train\"]\n",
"validation_data_list = [\"binary0.test\", \"binary1.test\"]\n",
"lgbm = LightGBM(source_directory=scripts_folder, \n",
" compute_target=cpu_cluster, \n",
" distributed_training=Mpi(),\n",
" node_count=2,\n",
" lightgbm_config='train.conf',\n",
" data=training_data_list,\n",
" valid=validation_data_list\n",
" )\n",
"experiment_name = 'lightgbm-estimator-test'\n",
"experiment = Experiment(ws, name=experiment_name)\n",
"run = experiment.submit(lgbm, tags={\"test public docker image\": None})\n",
"RunDetails(run).show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"run.wait_for_completion(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Use data reference"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.datastore import Datastore\n",
"from azureml.data.data_reference import DataReference\n",
"datastore = ws.get_default_datastore()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"datastore.upload(src_dir='.',\n",
" target_path='.',\n",
" show_progress=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"training_data_list=[\"binary0.train\", \"binary1.train\"]\n",
"validation_data_list = [\"binary0.test\", \"binary1.test\"]\n",
"lgbm = LightGBM(source_directory='.', \n",
" compute_target=cpu_cluster, \n",
" distributed_training=Mpi(),\n",
" node_count=2,\n",
" inputs=[datastore.as_mount()],\n",
" lightgbm_config='train.conf',\n",
" data=training_data_list,\n",
" valid=validation_data_list\n",
" )\n",
"experiment_name = 'lightgbm-estimator-test'\n",
"experiment = Experiment(ws, name=experiment_name)\n",
"run = experiment.submit(lgbm, tags={\"use datastore.as_mount()\": None})\n",
"RunDetails(run).show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"run.wait_for_completion(show_output=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# uncomment below and run if compute resources are no longer needed\n",
"# cpu_cluster.delete() "
]
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
"metadata": {
"authors": [
{
"name": "jingywa"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"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"
}
},
"language_info": {
"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"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,7 @@
name: lightgbm-example
dependencies:
- pip:
- azureml-sdk
- azureml-contrib-gbdt
- azureml-widgets
- azureml-core

View File

@@ -11,7 +11,6 @@ As a pre-requisite, run the [configuration Notebook](../configuration.ipynb) not
* [logging-api](./track-and-monitor-experiments/logging-api): Learn about the details of logging metrics to run history.
* [register-model-create-image-deploy-service](./deployment/register-model-create-image-deploy-service): Learn about the details of model management.
* [production-deploy-to-aks](./deployment/production-deploy-to-aks) Deploy a model to production at scale on Azure Kubernetes Service.
* [enable-data-collection-for-models-in-aks](./deployment/enable-data-collection-for-models-in-aks) Learn about data collection APIs for deployed model.
* [enable-app-insights-in-production-service](./deployment/enable-app-insights-in-production-service) Learn how to use App Insights with production web service.
Find quickstarts, end-to-end tutorials, and how-tos on the [official documentation site for Azure Machine Learning service](https://docs.microsoft.com/en-us/azure/machine-learning/service/).

View File

@@ -21,22 +21,14 @@ Below are the three execution environments supported by automated ML.
<a name="jupyter"></a>
## Setup using Azure Notebooks - Jupyter based notebooks in the Azure cloud
## Setup using Notebook VMs - Jupyter based notebooks from a Azure VM
1. [![Azure Notebooks](https://notebooks.azure.com/launch.png)](https://aka.ms/aml-clone-azure-notebooks)
[Import sample notebooks ](https://aka.ms/aml-clone-azure-notebooks) into Azure Notebooks.
1. Follow the instructions in the [configuration](../../configuration.ipynb) notebook to create and connect to a workspace.
1. Open one of the sample notebooks.
<a name="databricks"></a>
## Setup using Azure Databricks
**NOTE**: Please create your Azure Databricks cluster as v4.x (high concurrency preferred) with **Python 3** (dropdown).
**NOTE**: You should at least have contributor access to your Azure subcription to run the notebook.
- Please remove the previous SDK version if there is any and install the latest SDK by installing **azureml-sdk[automl_databricks]** as a PyPi library in Azure Databricks workspace.
- You can find the detail Readme instructions at [GitHub](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/azure-databricks).
- Download the sample notebook automl-databricks-local-01.ipynb from [GitHub](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/azure-databricks) and import into the Azure databricks workspace.
- Attach the notebook to the cluster.
1. Open the [ML Azure portal](https://ml.azure.com)
1. Select Compute
1. Select Notebook VMs
1. Click New
1. Type a name for the Vm and select a VM type
1. Click Create
<a name="localconda"></a>
## Setup using a Local Conda environment
@@ -102,111 +94,65 @@ source activate azure_automl
jupyter notebook
```
<a name="databricks"></a>
## Setup using Azure Databricks
**NOTE**: Please create your Azure Databricks cluster as v6.0 (high concurrency preferred) with **Python 3** (dropdown).
**NOTE**: You should at least have contributor access to your Azure subcription to run the notebook.
- Please remove the previous SDK version if there is any and install the latest SDK by installing **azureml-sdk[automl]** as a PyPi library in Azure Databricks workspace.
- You can find the detail Readme instructions at [GitHub](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/azure-databricks).
- Download the sample notebook automl-databricks-local-01.ipynb from [GitHub](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/azure-databricks) and import into the Azure databricks workspace.
- Attach the notebook to the cluster.
<a name="samples"></a>
# Automated ML SDK Sample Notebooks
- [auto-ml-classification.ipynb](classification/auto-ml-classification.ipynb)
- Dataset: scikit learn's [digit dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html#sklearn.datasets.load_digits)
- Simple example of using automated ML for classification
- Uses local compute for training
- [auto-ml-classification-credit-card-fraud.ipynb](classification-credit-card-fraud/auto-ml-classification-credit-card-fraud.ipynb)
- Dataset: Kaggle's [credit card fraud detection dataset](https://www.kaggle.com/mlg-ulb/creditcardfraud)
- Simple example of using automated ML for classification to fraudulent credit card transactions
- Uses azure compute for training
- [auto-ml-regression.ipynb](regression/auto-ml-regression.ipynb)
- Dataset: scikit learn's [diabetes dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_diabetes.html)
- Dataset: Hardware Performance Dataset
- Simple example of using automated ML for regression
- Uses local compute for training
- Uses azure compute for training
- [auto-ml-remote-amlcompute.ipynb](remote-amlcompute/auto-ml-remote-amlcompute.ipynb)
- Dataset: scikit learn's [digit dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html#sklearn.datasets.load_digits)
- Example of using automated ML for classification using remote AmlCompute for training
- Parallel execution of iterations
- Async tracking of progress
- Cancelling individual iterations or entire run
- Retrieving models for any iteration or logged metric
- Specify automated ML settings as kwargs
- [auto-ml-missing-data-blacklist-early-termination.ipynb](missing-data-blacklist-early-termination/auto-ml-missing-data-blacklist-early-termination.ipynb)
- Dataset: scikit learn's [digit dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html#sklearn.datasets.load_digits)
- Blacklist certain pipelines
- Specify a target metrics to indicate stopping criteria
- Handling Missing Data in the input
- [auto-ml-sparse-data-train-test-split.ipynb](sparse-data-train-test-split/auto-ml-sparse-data-train-test-split.ipynb)
- Dataset: Scikit learn's [20newsgroup](http://scikit-learn.org/stable/datasets/twenty_newsgroups.html)
- Handle sparse datasets
- Specify custom train and validation set
- [auto-ml-exploring-previous-runs.ipynb](exploring-previous-runs/auto-ml-exploring-previous-runs.ipynb)
- List all projects for the workspace
- List all automated ML Runs for a given project
- Get details for a automated ML Run. (automated ML settings, run widget & all metrics)
- Download fitted pipeline for any iteration
- [auto-ml-classification-with-deployment.ipynb](classification-with-deployment/auto-ml-classification-with-deployment.ipynb)
- Dataset: scikit learn's [digit dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html#sklearn.datasets.load_digits)
- Simple example of using automated ML for classification
- Registering the model
- Creating Image and creating aci service
- Testing the aci service
- [auto-ml-sample-weight.ipynb](sample-weight/auto-ml-sample-weight.ipynb)
- How to specifying sample_weight
- The difference that it makes to test results
- [auto-ml-subsampling-local.ipynb](subsampling/auto-ml-subsampling-local.ipynb)
- How to enable subsampling
- [auto-ml-dataset.ipynb](dataprep/auto-ml-dataset.ipynb)
- Using Dataset for reading data
- [auto-ml-dataset-remote-execution.ipynb](dataprep-remote-execution/auto-ml-dataset-remote-execution.ipynb)
- Using Dataset for reading data with remote execution
- [auto-ml-classification-with-whitelisting.ipynb](classification-with-whitelisting/auto-ml-classification-with-whitelisting.ipynb)
- Dataset: scikit learn's [digit dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html#sklearn.datasets.load_digits)
- Simple example of using automated ML for classification with whitelisting tensorflow models.
- Uses local compute for training
- [auto-ml-regression-hardware-performance-explanation-and-featurization.ipynb](regression-hardware-performance-explanation-and-featurization/auto-ml-regression-hardware-performance-explanation-and-featurization.ipynb)
- Dataset: Hardware Performance Dataset
- Shows featurization and excplanation
- Uses azure compute for training
- [auto-ml-forecasting-energy-demand.ipynb](forecasting-energy-demand/auto-ml-forecasting-energy-demand.ipynb)
- Dataset: [NYC energy demand data](forecasting-a/nyc_energy.csv)
- Example of using automated ML for training a forecasting model
- [auto-ml-forecasting-orange-juice-sales.ipynb](forecasting-orange-juice-sales/auto-ml-forecasting-orange-juice-sales.ipynb)
- Dataset: [Dominick's grocery sales of orange juice](forecasting-b/dominicks_OJ.csv)
- Example of training an automated ML forecasting model on multiple time-series
- [auto-ml-classification-with-onnx.ipynb](classification-with-onnx/auto-ml-classification-with-onnx.ipynb)
- Dataset: scikit learn's [iris dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_iris.html)
- Simple example of using automated ML for classification with ONNX models
- [auto-ml-classification-credit-card-fraud-local.ipynb](local-run-classification-credit-card-fraud/auto-ml-classification-credit-card-fraud-local.ipynb)
- Dataset: Kaggle's [credit card fraud detection dataset](https://www.kaggle.com/mlg-ulb/creditcardfraud)
- Simple example of using automated ML for classification to fraudulent credit card transactions
- Uses local compute for training
- [auto-ml-remote-amlcompute-with-onnx.ipynb](remote-amlcompute-with-onnx/auto-ml-remote-amlcompute-with-onnx.ipynb)
- Dataset: scikit learn's [iris dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_iris.html)
- Example of using automated ML for classification using remote AmlCompute for training
- Train the models with ONNX compatible config on
- Parallel execution of iterations
- Async tracking of progress
- Cancelling individual iterations or entire run
- Retrieving the ONNX models and do the inference with them
- [auto-ml-bank-marketing-subscribers-with-deployment.ipynb](bank-marketing-subscribers-with-deployment/auto-ml-bank-marketing-with-deployment.ipynb)
- [auto-ml-classification-bank-marketing-all-features.ipynb](classification-bank-marketing-all-features/auto-ml-classification-bank-marketing-all-features.ipynb)
- Dataset: UCI's [bank marketing dataset](https://www.kaggle.com/janiobachmann/bank-marketing-dataset)
- Simple example of using automated ML for classification to predict term deposit subscriptions for a bank
- Uses azure compute for training
- [auto-ml-creditcard-with-deployment.ipynb](credit-card-fraud-detection-with-deployment/auto-ml-creditcard-with-deployment.ipynb)
- Dataset: Kaggle's [credit card fraud detection dataset](https://www.kaggle.com/mlg-ulb/creditcardfraud)
- Simple example of using automated ML for classification to fraudulent credit card transactions
- Uses azure compute for training
- [auto-ml-forecasting-orange-juice-sales.ipynb](forecasting-orange-juice-sales/auto-ml-forecasting-orange-juice-sales.ipynb)
- Dataset: [Dominick's grocery sales of orange juice](forecasting-b/dominicks_OJ.csv)
- Example of training an automated ML forecasting model on multiple time-series
- [auto-ml-hardware-performance-with-deployment.ipynb](hardware-performance-prediction-with-deployment/auto-ml-hardware-performance-with-deployment.ipynb)
- Dataset: UCI's [computer hardware dataset](https://archive.ics.uci.edu/ml/datasets/Computer+Hardware)
- Simple example of using automated ML for regression to predict the performance of certain combinations of hardware components
- Uses azure compute for training
- [auto-ml-forecasting-bike-share.ipynb](forecasting-bike-share/auto-ml-forecasting-bike-share.ipynb)
- Dataset: forecasting for a bike-sharing
- Example of training an automated ML forecasting model on multiple time-series
- [auto-ml-concrete-strength-with-deployment.ipynb](predicting-concrete-strength-with-deployment/auto-ml-concrete-strength-with-deployment.ipynb)
- Dataset: UCI's [concrete compressive strength dataset](https://www.kaggle.com/pavanraj159/concrete-compressive-strength-data-set)
- Simple example of using automated ML for regression to predict the strength predict the compressive strength of concrete based off of different ingredient combinations and quantities of those ingredients
- Uses azure compute for training
- [automl-forecasting-function.ipynb](forecasting-high-frequency/automl-forecasting-function.ipynb)
- Example of training an automated ML forecasting model on multiple time-series
- [auto-ml-forecasting-beer-remote.ipynb](forecasting-beer-remote/auto-ml-forecasting-beer-remote.ipynb)
- Example of training an automated ML forecasting model on multiple time-series
- Beer Production Forecasting
- [auto-ml-continuous-retraining.ipynb](continuous-retraining/auto-ml-continuous-retraining.ipynb)
- Continous retraining using Pipelines and Time-Series TabularDataset
<a name="documentation"></a>
See [Configure automated machine learning experiments](https://docs.microsoft.com/azure/machine-learning/service/how-to-configure-auto-train) to learn how more about the the settings and features available for automated machine learning experiments.

View File

@@ -20,6 +20,7 @@ dependencies:
# Required packages for AzureML execution, history, and data preparation.
- azureml-defaults
- azureml-train-automl
- azureml-train
- azureml-widgets
- azureml-explain-model
- azureml-contrib-interpret

View File

@@ -21,6 +21,7 @@ dependencies:
# Required packages for AzureML execution, history, and data preparation.
- azureml-defaults
- azureml-train-automl
- azureml-train
- azureml-widgets
- azureml-explain-model
- azureml-contrib-interpret

View File

@@ -13,7 +13,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/classification-bank-marketing/auto-ml-classification-bank-marketing.png)"
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/classification-bank-marketing-all-features/auto-ml-classification-bank-marketing.png)"
]
},
{
@@ -43,15 +43,23 @@
"\n",
"If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, go through the [configuration](../../../configuration.ipynb) notebook first if you haven't already to establish your connection to the AzureML Workspace. \n",
"\n",
"Please find the ONNX related documentations [here](https://github.com/onnx/onnx).\n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an experiment using an existing workspace.\n",
"2. Configure AutoML using `AutoMLConfig`.\n",
"3. Train the model using local compute.\n",
"4. Explore the results.\n",
"5. Register the model.\n",
"6. Create a container image.\n",
"7. Create an Azure Container Instance (ACI) service.\n",
"8. Test the ACI service."
"3. Train the model using local compute with ONNX compatible config on.\n",
"4. Explore the results, featurization transparency options and save the ONNX model\n",
"5. Inference with the ONNX model.\n",
"6. Register the model.\n",
"7. Create a container image.\n",
"8. Create an Azure Container Instance (ACI) service.\n",
"9. Test the ACI service.\n",
"\n",
"In addition this notebook showcases the following features\n",
"- **Blacklisting** certain pipelines\n",
"- Specifying **target metrics** to indicate stopping criteria\n",
"- Handling **missing data** in the input"
]
},
{
@@ -78,8 +86,10 @@
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.automl.core.featurization import FeaturizationConfig\n",
"from azureml.core.dataset import Dataset\n",
"from azureml.train.automl import AutoMLConfig"
"from azureml.train.automl import AutoMLConfig\n",
"from azureml.explain.model._internal.explanation_client import ExplanationClient"
]
},
{
@@ -91,7 +101,7 @@
"ws = Workspace.from_config()\n",
"\n",
"# choose a name for experiment\n",
"experiment_name = 'automl-classification-bmarketing'\n",
"experiment_name = 'automl-classification-bmarketing-all'\n",
"\n",
"experiment=Experiment(ws, experiment_name)\n",
"\n",
@@ -128,7 +138,7 @@
"from azureml.core.compute import ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"automlcl\"\n",
"amlcompute_cluster_name = \"cpu-cluster-4\"\n",
"\n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
@@ -159,30 +169,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Data\n",
"\n",
"Create a run configuration for the remote run."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.runconfig import RunConfiguration\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"import pkg_resources\n",
"\n",
"# create a new RunConfig object\n",
"conda_run_config = RunConfiguration(framework=\"python\")\n",
"\n",
"# Set compute target to AmlCompute\n",
"conda_run_config.target = compute_target\n",
"conda_run_config.environment.docker.enabled = True\n",
"\n",
"cd = CondaDependencies.create(conda_packages=['numpy','py-xgboost<=0.80'])\n",
"conda_run_config.environment.python.conda_dependencies = cd"
"# Data"
]
},
{
@@ -191,7 +178,14 @@
"source": [
"### Load Data\n",
"\n",
"Load the bank marketing dataset from a csv file containing both training features and labels. The features are inputs to the model, while the training labels represent the expected output of the model."
"Leverage azure compute to load the bank marketing dataset as a Tabular Dataset into the dataset variable. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Training Data"
]
},
{
@@ -200,9 +194,82 @@
"metadata": {},
"outputs": [],
"source": [
"data = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/bankmarketing_train.csv\"\n",
"dataset = Dataset.Tabular.from_delimited_files(data)\n",
"dataset.take(5).to_pandas_dataframe()"
"data = pd.read_csv(\"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/bankmarketing_train.csv\")\n",
"data.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Add missing values in 75% of the lines.\n",
"import numpy as np\n",
"\n",
"missing_rate = 0.75\n",
"n_missing_samples = int(np.floor(data.shape[0] * missing_rate))\n",
"missing_samples = np.hstack((np.zeros(data.shape[0] - n_missing_samples, dtype=np.bool), np.ones(n_missing_samples, dtype=np.bool)))\n",
"rng = np.random.RandomState(0)\n",
"rng.shuffle(missing_samples)\n",
"missing_features = rng.randint(0, data.shape[1], n_missing_samples)\n",
"data.values[np.where(missing_samples)[0], missing_features] = np.nan"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if not os.path.isdir('data'):\n",
" os.mkdir('data')\n",
" \n",
"# Save the train data to a csv to be uploaded to the datastore\n",
"pd.DataFrame(data).to_csv(\"data/train_data.csv\", index=False)\n",
"\n",
"ds = ws.get_default_datastore()\n",
"ds.upload(src_dir='./data', target_path='bankmarketing', overwrite=True, show_progress=True)\n",
"\n",
" \n",
"\n",
"# Upload the training data as a tabular dataset for access during training on remote compute\n",
"train_data = Dataset.Tabular.from_delimited_files(path=ds.path('bankmarketing/train_data.csv'))\n",
"label = \"y\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Validation Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"validation_data = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/bankmarketing_validate.csv\"\n",
"validation_dataset = Dataset.Tabular.from_delimited_files(validation_data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Test Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"test_data = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/bankmarketing_test.csv\"\n",
"test_dataset = Dataset.Tabular.from_delimited_files(test_data)"
]
},
{
@@ -215,13 +282,18 @@
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**task**|classification or regression or forecasting|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**blacklist_models** or **whitelist_models** |*List* of *strings* indicating machine learning algorithms for AutoML to avoid in this run.<br><br> Allowed values for **Classification**<br><i>LogisticRegression</i><br><i>SGD</i><br><i>MultinomialNaiveBayes</i><br><i>BernoulliNaiveBayes</i><br><i>SVM</i><br><i>LinearSVM</i><br><i>KNN</i><br><i>DecisionTree</i><br><i>RandomForest</i><br><i>ExtremeRandomTrees</i><br><i>LightGBM</i><br><i>GradientBoosting</i><br><i>TensorFlowDNN</i><br><i>TensorFlowLinearClassifier</i><br><br>Allowed values for **Regression**<br><i>ElasticNet</i><br><i>GradientBoosting</i><br><i>DecisionTree</i><br><i>KNN</i><br><i>LassoLars</i><br><i>SGD</i><br><i>RandomForest</i><br><i>ExtremeRandomTrees</i><br><i>LightGBM</i><br><i>TensorFlowLinearRegressor</i><br><i>TensorFlowDNN</i><br><br>Allowed values for **Forecasting**<br><i>ElasticNet</i><br><i>GradientBoosting</i><br><i>DecisionTree</i><br><i>KNN</i><br><i>LassoLars</i><br><i>SGD</i><br><i>RandomForest</i><br><i>ExtremeRandomTrees</i><br><i>LightGBM</i><br><i>TensorFlowLinearRegressor</i><br><i>TensorFlowDNN</i><br><i>Arima</i><br><i>Prophet</i>|\n",
"|**experiment_exit_score**| Value indicating the target for *primary_metric*. <br>Once the target is surpassed the run terminates.|\n",
"|**experiment_timeout_minutes**| Maximum amount of time in minutes that all iterations combined can take before the experiment terminates.|\n",
"|**enable_early_stopping**| Flag to enble early termination if the score is not improving in the short term.|\n",
"|**featurization**| 'auto' / 'off' Indicator for whether featurization step should be done automatically or not. Note: If the input data is sparse, featurization cannot be turned on.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**training_data**|Input dataset, containing both features and label column.|\n",
"|**label_column_name**|The name of the label column.|\n",
"|**model_explainability**|Indicate to explain each trained pipeline or not.|\n",
"\n",
"**_You can find more information about primary metrics_** [here](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-configure-auto-train#primary-metric)"
]
@@ -233,20 +305,27 @@
"outputs": [],
"source": [
"automl_settings = {\n",
" \"experiment_timeout_minutes\" : 20,\n",
" \"enable_early_stopping\" : True,\n",
" \"iteration_timeout_minutes\": 5,\n",
" \"iterations\": 10,\n",
" \"n_cross_validations\": 2,\n",
" \"max_concurrent_iterations\": 4,\n",
" \"max_cores_per_iteration\": -1,\n",
" #\"n_cross_validations\": 2,\n",
" \"primary_metric\": 'AUC_weighted',\n",
" \"preprocess\": True,\n",
" \"max_concurrent_iterations\": 5,\n",
" \"featurization\": 'auto',\n",
" \"verbosity\": logging.INFO,\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" run_configuration=conda_run_config,\n",
" training_data = dataset,\n",
" label_column_name = 'y',\n",
" compute_target=compute_target,\n",
" experiment_exit_score = 0.9984,\n",
" blacklist_models = ['KNN','LinearSVM'],\n",
" enable_onnx_compatible_models=True,\n",
" training_data = train_data,\n",
" label_column_name = label,\n",
" validation_data = validation_dataset,\n",
" model_explainability=True,\n",
" **automl_settings\n",
" )"
]
@@ -265,7 +344,7 @@
"metadata": {},
"outputs": [],
"source": [
"remote_run = experiment.submit(automl_config, show_output = True)"
"remote_run = experiment.submit(automl_config, show_output = False)"
]
},
{
@@ -277,6 +356,91 @@
"remote_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Run the following cell to access previous runs. Uncomment the cell below and update the run_id."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#from azureml.train.automl.run import AutoMLRun\n",
"#experiment_name = 'automl-classification-bmarketing'\n",
"#experiment = Experiment(ws, experiment_name)\n",
"#remote_run = AutoMLRun(experiment=experiment, run_id='<run_ID_goes_here')\n",
"#remote_run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run.wait_for_completion()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run_customized, fitted_model_customized = remote_run.get_output()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Transparency\n",
"\n",
"View updated featurization summary"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"custom_featurizer = fitted_model_customized.named_steps['datatransformer']\n",
"df = custom_featurizer.get_featurization_summary()\n",
"pd.DataFrame(data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Set `is_user_friendly=False` to get a more detailed summary for the transforms being applied."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df = custom_featurizer.get_featurization_summary(is_user_friendly=False)\n",
"pd.DataFrame(data=df)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df = custom_featurizer.get_stats_feature_type_summary()\n",
"pd.DataFrame(data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -284,6 +448,151 @@
"## Results"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(remote_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model's explanation\n",
"Retrieve the explanation from the best_run which includes explanations for engineered features and raw features.\n",
"\n",
"#### Download engineered feature importance from artifact store\n",
"You can use ExplanationClient to download the engineered feature explanations from the artifact store of the best_run."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = remote_run.get_output()\n",
"client = ExplanationClient.from_run(best_run)\n",
"engineered_explanations = client.download_model_explanation(raw=False)\n",
"exp_data = engineered_explanations.get_feature_importance_dict()\n",
"exp_data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best ONNX Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method returns the best run and the fitted model. The Model includes the pipeline and any pre-processing. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*.\n",
"\n",
"Set the parameter return_onnx_model=True to retrieve the best ONNX model, instead of the Python model."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, onnx_mdl = remote_run.get_output(return_onnx_model=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Save the best ONNX model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.automl.core.onnx_convert import OnnxConverter\n",
"onnx_fl_path = \"./best_model.onnx\"\n",
"OnnxConverter.save_onnx_model(onnx_mdl, onnx_fl_path)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Predict with the ONNX model, using onnxruntime package"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"test_df = test_dataset.to_pandas_dataframe()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import json\n",
"from azureml.automl.core.onnx_convert import OnnxConvertConstants\n",
"from azureml.train.automl import constants\n",
"\n",
"if sys.version_info < OnnxConvertConstants.OnnxIncompatiblePythonVersion:\n",
" python_version_compatible = True\n",
"else:\n",
" python_version_compatible = False\n",
"\n",
"try:\n",
" import onnxruntime\n",
" from azureml.automl.core.onnx_convert import OnnxInferenceHelper \n",
" onnxrt_present = True\n",
"except ImportError:\n",
" onnxrt_present = False\n",
"\n",
"def get_onnx_res(run):\n",
" res_path = 'onnx_resource.json'\n",
" run.download_file(name=constants.MODEL_RESOURCE_PATH_ONNX, output_file_path=res_path)\n",
" with open(res_path) as f:\n",
" onnx_res = json.load(f)\n",
" return onnx_res\n",
"\n",
"if onnxrt_present and python_version_compatible: \n",
" mdl_bytes = onnx_mdl.SerializeToString()\n",
" onnx_res = get_onnx_res(best_run)\n",
"\n",
" onnxrt_helper = OnnxInferenceHelper(mdl_bytes, onnx_res)\n",
" pred_onnx, pred_prob_onnx = onnxrt_helper.predict(test_df)\n",
"\n",
" print(pred_onnx)\n",
" print(pred_prob_onnx)\n",
"else:\n",
" if not python_version_compatible:\n",
" print('Please use Python version 3.6 or 3.7 to run the inference helper.') \n",
" if not onnxrt_present:\n",
" print('Please install the onnxruntime package to do the prediction with ONNX model.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Deploy\n",
"\n",
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method on `automl_classifier` returns the best run and the fitted model for the last invocation. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -301,19 +610,7 @@
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(remote_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Deploy\n",
"\n",
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method on `automl_classifier` returns the best run and the fitted model for the last invocation. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
"best_run, fitted_model = remote_run.get_output()"
]
},
{
@@ -322,7 +619,27 @@
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = remote_run.get_output()"
"import os\n",
"import shutil\n",
"\n",
"sript_folder = os.path.join(os.getcwd(), 'inference')\n",
"project_folder = '/inference'\n",
"os.makedirs(project_folder, exist_ok=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"model_name = best_run.properties['model_name']\n",
"\n",
"script_file_name = 'inference/score.py'\n",
"conda_env_file_name = 'inference/env.yml'\n",
"\n",
"best_run.download_file('outputs/scoring_file_v_1_0_0.py', 'inference/score.py')\n",
"best_run.download_file('outputs/conda_env_v_1_0_0.yml', 'inference/env.yml')"
]
},
{
@@ -341,124 +658,11 @@
"source": [
"description = 'AutoML Model trained on bank marketing data to predict if a client will subscribe to a term deposit'\n",
"tags = None\n",
"model = remote_run.register_model(description = description, tags = tags)\n",
"model = remote_run.register_model(model_name = model_name, description = description, tags = tags)\n",
"\n",
"print(remote_run.model_id) # This will be written to the script file later in the notebook."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create Scoring Script\n",
"The scoring script is required to generate the image for deployment. It contains the code to do the predictions on input data."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%writefile score.py\n",
"import pickle\n",
"import json\n",
"import numpy\n",
"import azureml.train.automl\n",
"from sklearn.externals import joblib\n",
"from azureml.core.model import Model\n",
"\n",
"\n",
"def init():\n",
" global model\n",
" model_path = Model.get_model_path(model_name = '<<modelid>>') # this name is model.id of model that we want to deploy\n",
" # deserialize the model file back into a sklearn model\n",
" model = joblib.load(model_path)\n",
"\n",
"def run(rawdata):\n",
" try:\n",
" data = json.loads(rawdata)['data']\n",
" data = np.array(data)\n",
" result = model.predict(data)\n",
" except Exception as e:\n",
" result = str(e)\n",
" return json.dumps({\"error\": result})\n",
" return json.dumps({\"result\":result.tolist()})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create a YAML File for the Environment"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To ensure the fit results are consistent with the training results, the SDK dependency versions need to be the same as the environment that trains the model. Details about retrieving the versions can be found in notebook [12.auto-ml-retrieve-the-training-sdk-versions](12.auto-ml-retrieve-the-training-sdk-versions.ipynb)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dependencies = remote_run.get_run_sdk_dependencies(iteration = 1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for p in ['azureml-train-automl', 'azureml-core']:\n",
" print('{}\\t{}'.format(p, dependencies[p]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"myenv = CondaDependencies.create(conda_packages=['numpy','scikit-learn','py-xgboost<=0.80'],\n",
" pip_packages=['azureml-defaults','azureml-train-automl'])\n",
"\n",
"conda_env_file_name = 'myenv.yml'\n",
"myenv.save_to_file('.', conda_env_file_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Substitute the actual version number in the environment file.\n",
"# This is not strictly needed in this notebook because the model should have been generated using the current SDK version.\n",
"# However, we include this in case this code is used on an experiment from a previous SDK version.\n",
"\n",
"with open(conda_env_file_name, 'r') as cefr:\n",
" content = cefr.read()\n",
"\n",
"with open(conda_env_file_name, 'w') as cefw:\n",
" cefw.write(content.replace(azureml.core.VERSION, dependencies['azureml-train-automl']))\n",
"\n",
"# Substitute the actual model id in the script file.\n",
"\n",
"script_file_name = 'score.py'\n",
"\n",
"with open(script_file_name, 'r') as cefr:\n",
" content = cefr.read()\n",
"\n",
"with open(script_file_name, 'w') as cefw:\n",
" cefw.write(content.replace('<<modelid>>', remote_run.model_id))"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -486,7 +690,7 @@
" tags = {'area': \"bmData\", 'type': \"automl_classification\"}, \n",
" description = 'sample service for Automl Classification')\n",
"\n",
"aci_service_name = 'automl-sample-bankmarketing'\n",
"aci_service_name = 'automl-sample-bankmarketing-all'\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",
@@ -535,7 +739,7 @@
"source": [
"## Test\n",
"\n",
"Now that the model is trained split our 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."
"Now that the model is trained, run the test data through the trained model to get the predicted values."
]
},
{
@@ -554,11 +758,9 @@
"metadata": {},
"outputs": [],
"source": [
"data = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/bankmarketing_validate.csv\"\n",
"dataset = Dataset.Tabular.from_delimited_files(data)\n",
"X_test = dataset.drop_columns(columns=['y'])\n",
"y_test = dataset.keep_columns(columns=['y'], validate=True)\n",
"dataset.take(5).to_pandas_dataframe()"
"X_test = test_dataset.drop_columns(columns=['y'])\n",
"y_test = test_dataset.keep_columns(columns=['y'], validate=True)\n",
"test_dataset.take(5).to_pandas_dataframe()"
]
},
{
@@ -624,14 +826,37 @@
"\n",
"[Moro et al., 2014] S. Moro, P. Cortez and P. Rita. A Data-Driven Approach to Predict the Success of Bank Telemarketing. Decision Support Systems, Elsevier, 62:22-31, June 2014"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"authors": [
{
"name": "v-rasav"
"name": "anumamah"
}
],
"category": "tutorial",
"compute": [
"AML"
],
"datasets": [
"Bankmarketing"
],
"deployment": [
"ACI"
],
"exclude_from_index": false,
"framework": [
"None"
],
"friendly_name": "Automated ML run with basic edition features.",
"index_order": 5,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -648,7 +873,14 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"tags": [
"featurization",
"explainability",
"remote_run",
"AutomatedML"
],
"task": "Classification"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -1,12 +1,13 @@
name: auto-ml-remote-amlcompute-with-onnx
name: auto-ml-classification-bank-marketing-all-features
dependencies:
- pip:
- azureml-sdk
- interpret
- azureml-defaults
- azureml-explain-model
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml
- onnxruntime
- azureml-explain-model
- azureml-contrib-interpret

View File

@@ -1,11 +0,0 @@
name: auto-ml-classification-bank-marketing
dependencies:
- pip:
- azureml-sdk
- interpret
- azureml-defaults
- azureml-explain-model
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml

View File

@@ -21,14 +21,13 @@
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Classification with Deployment using Credit Card Dataset**_\n",
"_**Classification of credit card fraudulent transactions on remote compute **_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Deploy](#Deploy)\n",
"1. [Test](#Test)\n",
"1. [Acknowledgements](#Acknowledgements)"
]
@@ -39,19 +38,18 @@
"source": [
"## Introduction\n",
"\n",
"In this example we use the associated credit card dataset to showcase how you can use AutoML for a simple classification problem and deploy it to an Azure Container Instance (ACI). The classification goal is to predict if a creditcard transaction is or is not considered a fraudulent charge.\n",
"In this example we use the associated credit card dataset to showcase how you can use AutoML for a simple classification problem. The goal is to predict if a credit card transaction is considered a fraudulent charge.\n",
"\n",
"If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, go through the [configuration](../../../configuration.ipynb) notebook first if you haven't already to establish your connection to the AzureML Workspace. \n",
"This notebook is using remote compute to train the model.\n",
"\n",
"If you are using an Azure Machine Learning [Notebook VM](https://docs.microsoft.com/en-us/azure/machine-learning/service/tutorial-1st-experiment-sdk-setup), you are all set. Otherwise, go through the [configuration](../../../configuration.ipynb) notebook first if you haven't already to establish your connection to the AzureML Workspace. \n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an experiment using an existing workspace.\n",
"2. Configure AutoML using `AutoMLConfig`.\n",
"3. Train the model using local compute.\n",
"3. Train the model using remote compute.\n",
"4. Explore the results.\n",
"5. Register the model.\n",
"6. Create a container image.\n",
"7. Create an Azure Container Instance (ACI) service.\n",
"8. Test the ACI service."
"5. Test the fitted model."
]
},
{
@@ -60,7 +58,7 @@
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
"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."
]
},
{
@@ -91,7 +89,7 @@
"ws = Workspace.from_config()\n",
"\n",
"# choose a name for experiment\n",
"experiment_name = 'automl-classification-ccard'\n",
"experiment_name = 'automl-classification-ccard-remote'\n",
"\n",
"experiment=Experiment(ws, experiment_name)\n",
"\n",
@@ -112,10 +110,10 @@
"metadata": {},
"source": [
"## Create or Attach existing AmlCompute\n",
"You will need to create a compute target for your AutoML run. In this tutorial, you create AmlCompute as your training compute resource.\n",
"A compute target is required to execute the Automated ML run. In this tutorial, you create AmlCompute as your training compute resource.\n",
"#### 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 on the default limits and how to request more quota."
"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."
]
},
{
@@ -127,20 +125,20 @@
"from azureml.core.compute import AmlCompute\n",
"from azureml.core.compute import ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"automlcl\"\n",
"# Choose a name for your AmlCompute cluster.\n",
"amlcompute_cluster_name = \"cpu-cluster-1\"\n",
"\n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'cpu-cluster-1':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
" \n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_D2_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_DS12_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 6)\n",
"\n",
@@ -159,30 +157,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Data\n",
"\n",
"Create a run configuration for the remote run."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.runconfig import RunConfiguration\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"import pkg_resources\n",
"\n",
"# create a new RunConfig object\n",
"conda_run_config = RunConfiguration(framework=\"python\")\n",
"\n",
"# Set compute target to AmlCompute\n",
"conda_run_config.target = compute_target\n",
"conda_run_config.environment.docker.enabled = True\n",
"\n",
"cd = CondaDependencies.create(conda_packages=['numpy','py-xgboost<=0.80'])\n",
"conda_run_config.environment.python.conda_dependencies = cd"
"# Data"
]
},
{
@@ -203,9 +178,7 @@
"data = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/creditcard.csv\"\n",
"dataset = Dataset.Tabular.from_delimited_files(data)\n",
"training_data, validation_data = dataset.random_split(percentage=0.8, seed=223)\n",
"label_column_name = 'Class'\n",
"X_test = validation_data.drop_columns(columns=[label_column_name])\n",
"y_test = validation_data.keep_columns(columns=[label_column_name], validate=True)\n"
"label_column_name = 'Class'"
]
},
{
@@ -220,8 +193,7 @@
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**enable_early_stopping**|Stop the run if the metric score is not showing improvement.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**training_data**|Input dataset, containing both features and label column.|\n",
"|**label_column_name**|The name of the label column.|\n",
@@ -229,13 +201,6 @@
"**_You can find more information about primary metrics_** [here](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-configure-auto-train#primary-metric)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### If you would like to see even better results increase \"iteration_time_out minutes\" to 10+ mins and increase \"iterations\" to a minimum of 30"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -243,18 +208,18 @@
"outputs": [],
"source": [
"automl_settings = {\n",
" \"iteration_timeout_minutes\": 5,\n",
" \"iterations\": 10,\n",
" \"n_cross_validations\": 2,\n",
" \"n_cross_validations\": 3,\n",
" \"primary_metric\": 'average_precision_score_weighted',\n",
" \"preprocess\": True,\n",
" \"max_concurrent_iterations\": 5,\n",
" \"enable_early_stopping\": True,\n",
" \"max_concurrent_iterations\": 2, # This is a limit for testing purpose, please increase it as per cluster size\n",
" \"experiment_timeout_minutes\": 10, # This is a time limit for testing purposes, remove it for real use cases, this will drastically limit ablity to find the best model possible\n",
" \"verbosity\": logging.INFO,\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" run_configuration=conda_run_config,\n",
" compute_target = compute_target,\n",
" training_data = training_data,\n",
" label_column_name = label_column_name,\n",
" **automl_settings\n",
@@ -265,7 +230,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"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",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
@@ -275,7 +240,18 @@
"metadata": {},
"outputs": [],
"source": [
"remote_run = experiment.submit(automl_config, show_output = True)"
"remote_run = experiment.submit(automl_config, show_output = False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# If you need to retrieve a run that already started, use the following code\n",
"#from azureml.train.automl.run import AutoMLRun\n",
"#remote_run = AutoMLRun(experiment = experiment, run_id = '<replace with your run id>')"
]
},
{
@@ -312,14 +288,32 @@
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(remote_run).show() "
"RunDetails(remote_run).show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run.wait_for_completion(show_output=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Deploy\n",
"#### Explain model\n",
"\n",
"Automated ML models can be explained and visualized using the SDK Explainability library. [Learn how to use the explainer](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/model-explanation-remote-amlcompute/auto-ml-model-explanations-remote-compute.ipynb)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Analyze results\n",
"\n",
"### Retrieve the Best Model\n",
"\n",
@@ -332,217 +326,33 @@
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = remote_run.get_output()"
"best_run, fitted_model = remote_run.get_output()\n",
"fitted_model"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Register the Fitted Model for Deployment\n",
"If neither `metric` nor `iteration` are specified in the `register_model` call, the iteration with the best primary metric is registered."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"description = 'AutoML Model'\n",
"tags = None\n",
"model = remote_run.register_model(description = description, tags = tags)\n",
"\n",
"print(remote_run.model_id) # This will be written to the script file later in the notebook."
"#### Print the properties of the model\n",
"The fitted_model is a python object and you can read the different properties of the object.\n",
"See *Print the properties of the model* section in [this sample notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/classification/auto-ml-classification.ipynb)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create Scoring Script\n",
"The scoring script is required to generate the image for deployment. It contains the code to do the predictions on input data."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%writefile score.py\n",
"import pickle\n",
"import json\n",
"import numpy\n",
"import azureml.train.automl\n",
"from sklearn.externals import joblib\n",
"from azureml.core.model import Model\n",
"### Deploy\n",
"\n",
"def init():\n",
" global model\n",
" model_path = Model.get_model_path(model_name = '<<modelid>>') # this name is model.id of model that we want to deploy\n",
" # deserialize the model file back into a sklearn model\n",
" model = joblib.load(model_path)\n",
"\n",
"def run(rawdata):\n",
" try:\n",
" data = json.loads(rawdata)['data']\n",
" data = numpy.array(data)\n",
" result = model.predict(data)\n",
" except Exception as e:\n",
" result = str(e)\n",
" return json.dumps({\"error\": result})\n",
" return json.dumps({\"result\":result.tolist()})"
"To deploy the model into a web service endpoint, see _Deploy_ section in [this sample notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/classification-with-deployment/auto-ml-classification-with-deployment.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create a YAML File for the Environment"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To ensure the fit results are consistent with the training results, the SDK dependency versions need to be the same as the environment that trains the model. Details about retrieving the versions can be found in notebook [12.auto-ml-retrieve-the-training-sdk-versions](12.auto-ml-retrieve-the-training-sdk-versions.ipynb)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dependencies = remote_run.get_run_sdk_dependencies(iteration = 1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for p in ['azureml-train-automl', 'azureml-core']:\n",
" print('{}\\t{}'.format(p, dependencies[p]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"myenv = CondaDependencies.create(conda_packages=['numpy','scikit-learn','py-xgboost<=0.80'],\n",
" pip_packages=['azureml-defaults','azureml-train-automl'])\n",
"\n",
"conda_env_file_name = 'myenv.yml'\n",
"myenv.save_to_file('.', conda_env_file_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Substitute the actual version number in the environment file.\n",
"# This is not strictly needed in this notebook because the model should have been generated using the current SDK version.\n",
"# However, we include this in case this code is used on an experiment from a previous SDK version.\n",
"\n",
"with open(conda_env_file_name, 'r') as cefr:\n",
" content = cefr.read()\n",
"\n",
"with open(conda_env_file_name, 'w') as cefw:\n",
" cefw.write(content.replace(azureml.core.VERSION, dependencies['azureml-train-automl']))\n",
"\n",
"# Substitute the actual model id in the script file.\n",
"\n",
"script_file_name = 'score.py'\n",
"\n",
"with open(script_file_name, 'r') as cefr:\n",
" content = cefr.read()\n",
"\n",
"with open(script_file_name, 'w') as cefw:\n",
" cefw.write(content.replace('<<modelid>>', remote_run.model_id))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Deploy the model as a Web Service on Azure Container Instance"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.model import InferenceConfig\n",
"from azureml.core.webservice import AciWebservice\n",
"from azureml.core.webservice import Webservice\n",
"from azureml.core.model import Model\n",
"\n",
"inference_config = InferenceConfig(runtime = \"python\", \n",
" entry_script = script_file_name,\n",
" conda_file = conda_env_file_name)\n",
"\n",
"aciconfig = AciWebservice.deploy_configuration(cpu_cores = 1, \n",
" memory_gb = 1, \n",
" tags = {'area': \"cards\", 'type': \"automl_classification\"}, \n",
" description = 'sample service for Automl Classification')\n",
"\n",
"aci_service_name = 'automl-sample-creditcard'\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",
"print(aci_service.state)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Delete a Web Service\n",
"\n",
"Deletes the specified web service."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#aci_service.delete()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get Logs from a Deployed Web Service\n",
"\n",
"Gets logs from a deployed web service."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#aci_service.get_logs()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test\n",
"## Test the fitted model\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."
]
@@ -553,9 +363,9 @@
"metadata": {},
"outputs": [],
"source": [
"#Randomly select and test\n",
"X_test = X_test.to_pandas_dataframe()\n",
"y_test = y_test.to_pandas_dataframe()\n"
"# convert the test data to dataframe\n",
"X_test_df = validation_data.drop_columns(columns=[label_column_name]).to_pandas_dataframe()\n",
"y_test_df = validation_data.keep_columns(columns=[label_column_name], validate=True).to_pandas_dataframe()"
]
},
{
@@ -564,7 +374,8 @@
"metadata": {},
"outputs": [],
"source": [
"y_pred = fitted_model.predict(X_test)\n",
"# call the predict functions on the model\n",
"y_pred = fitted_model.predict(X_test_df)\n",
"y_pred"
]
},
@@ -584,14 +395,25 @@
"metadata": {},
"outputs": [],
"source": [
"#Randomly select and test\n",
"# Plot outputs\n",
"%matplotlib notebook\n",
"test_pred = plt.scatter(y_test, y_pred, color='b')\n",
"test_test = plt.scatter(y_test, y_test, color='g')\n",
"plt.legend((test_pred, test_test), ('prediction', 'truth'), loc='upper left', fontsize=8)\n",
"plt.show()\n",
"\n"
"from sklearn.metrics import confusion_matrix\n",
"import numpy as np\n",
"import itertools\n",
"\n",
"cf =confusion_matrix(y_test_df.values,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()"
]
},
{
@@ -608,23 +430,40 @@
"This Credit Card fraud Detection dataset is made available under the Open Database License: http://opendatacommons.org/licenses/odbl/1.0/. Any rights in individual contents of the database are licensed under the Database Contents License: http://opendatacommons.org/licenses/dbcl/1.0/ and is available at: https://www.kaggle.com/mlg-ulb/creditcardfraud\n",
"\n",
"\n",
"The dataset has been collected and analysed during a research collaboration of Worldline and the Machine Learning Group (http://mlg.ulb.ac.be) of ULB (Universit\u00c3\u00a9 Libre de Bruxelles) on big data mining and fraud detection. More details on current and past projects on related topics are available on https://www.researchgate.net/project/Fraud-detection-5 and the page of the DefeatFraud project\n",
"The dataset has been collected and analysed during a research collaboration of Worldline and the Machine Learning Group (http://mlg.ulb.ac.be) of ULB (Universit\u00c3\u0192\u00c2\u00a9 Libre de Bruxelles) on big data mining and fraud detection. More details on current and past projects on related topics are available on https://www.researchgate.net/project/Fraud-detection-5 and the page of the DefeatFraud project\n",
"Please cite the following works: \n",
"\u00e2\u20ac\u00a2\tAndrea Dal Pozzolo, Olivier Caelen, Reid A. Johnson and Gianluca Bontempi. Calibrating Probability with Undersampling for Unbalanced Classification. In Symposium on Computational Intelligence and Data Mining (CIDM), IEEE, 2015\n",
"\u00e2\u20ac\u00a2\tDal Pozzolo, Andrea; Caelen, Olivier; Le Borgne, Yann-Ael; Waterschoot, Serge; Bontempi, Gianluca. Learned lessons in credit card fraud detection from a practitioner perspective, Expert systems with applications,41,10,4915-4928,2014, Pergamon\n",
"\u00e2\u20ac\u00a2\tDal Pozzolo, Andrea; Boracchi, Giacomo; Caelen, Olivier; Alippi, Cesare; Bontempi, Gianluca. Credit card fraud detection: a realistic modeling and a novel learning strategy, IEEE transactions on neural networks and learning systems,29,8,3784-3797,2018,IEEE\n",
"\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00a2\tAndrea Dal Pozzolo, Olivier Caelen, Reid A. Johnson and Gianluca Bontempi. Calibrating Probability with Undersampling for Unbalanced Classification. In Symposium on Computational Intelligence and Data Mining (CIDM), IEEE, 2015\n",
"\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00a2\tDal Pozzolo, Andrea; Caelen, Olivier; Le Borgne, Yann-Ael; Waterschoot, Serge; Bontempi, Gianluca. Learned lessons in credit card fraud detection from a practitioner perspective, Expert systems with applications,41,10,4915-4928,2014, Pergamon\n",
"\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00a2\tDal Pozzolo, Andrea; Boracchi, Giacomo; Caelen, Olivier; Alippi, Cesare; Bontempi, Gianluca. Credit card fraud detection: a realistic modeling and a novel learning strategy, IEEE transactions on neural networks and learning systems,29,8,3784-3797,2018,IEEE\n",
"o\tDal Pozzolo, Andrea Adaptive Machine learning for credit card fraud detection ULB MLG PhD thesis (supervised by G. Bontempi)\n",
"\u00e2\u20ac\u00a2\tCarcillo, Fabrizio; Dal Pozzolo, Andrea; Le Borgne, Yann-A\u00c3\u00abl; Caelen, Olivier; Mazzer, Yannis; Bontempi, Gianluca. Scarff: a scalable framework for streaming credit card fraud detection with Spark, Information fusion,41, 182-194,2018,Elsevier\n",
"\u00e2\u20ac\u00a2\tCarcillo, Fabrizio; Le Borgne, Yann-A\u00c3\u00abl; Caelen, Olivier; Bontempi, Gianluca. Streaming active learning strategies for real-life credit card fraud detection: assessment and visualization, International Journal of Data Science and Analytics, 5,4,285-300,2018,Springer International Publishing"
"\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00a2\tCarcillo, Fabrizio; Dal Pozzolo, Andrea; Le Borgne, Yann-A\u00c3\u0192\u00c2\u00abl; Caelen, Olivier; Mazzer, Yannis; Bontempi, Gianluca. Scarff: a scalable framework for streaming credit card fraud detection with Spark, Information fusion,41, 182-194,2018,Elsevier\n",
"\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00a2\tCarcillo, Fabrizio; Le Borgne, Yann-A\u00c3\u0192\u00c2\u00abl; Caelen, Olivier; Bontempi, Gianluca. Streaming active learning strategies for real-life credit card fraud detection: assessment and visualization, International Journal of Data Science and Analytics, 5,4,285-300,2018,Springer International Publishing"
]
}
],
"metadata": {
"authors": [
{
"name": "v-rasav"
"name": "tzvikei"
}
],
"category": "tutorial",
"compute": [
"AML Compute"
],
"datasets": [
"creditcard"
],
"deployment": [
"None"
],
"exclude_from_index": false,
"file_extension": ".py",
"framework": [
"None"
],
"friendly_name": "Classification of credit card fraudulent transactions using Automated ML",
"index_order": 5,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -641,7 +480,17 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"tags": [
"remote_run",
"AutomatedML"
],
"task": "Classification",
"version": "3.6.7"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -1,479 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/classification-with-deployment/auto-ml-classification-with-deployment.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Classification with Deployment**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Train](#Train)\n",
"1. [Deploy](#Deploy)\n",
"1. [Test](#Test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"\n",
"In this example we use the scikit learn's [digit dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html) to showcase how you can use AutoML for a simple classification problem and deploy it to an Azure Container Instance (ACI).\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an experiment using an existing workspace.\n",
"2. Configure AutoML using `AutoMLConfig`.\n",
"3. Train the model using local compute.\n",
"4. Explore the results.\n",
"5. Register the model.\n",
"6. Create a container image.\n",
"7. Create an Azure Container Instance (ACI) service.\n",
"8. Test the ACI service."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import logging\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from sklearn import datasets\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.train.automl import AutoMLConfig\n",
"from azureml.train.automl.run import AutoMLRun"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# choose a name for experiment\n",
"experiment_name = 'automl-classification-deployment'\n",
"\n",
"experiment=Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate a AutoMLConfig object. This defines the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**X**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**y**|(sparse) array-like, shape = [n_samples, ], Multi-class targets.|"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"digits = datasets.load_digits()\n",
"X_train = digits.data[10:,:]\n",
"y_train = digits.target[10:]\n",
"\n",
"automl_config = AutoMLConfig(task = 'classification',\n",
" name = experiment_name,\n",
" debug_log = 'automl_errors.log',\n",
" primary_metric = 'AUC_weighted',\n",
" iteration_timeout_minutes = 20,\n",
" iterations = 10,\n",
" verbosity = logging.INFO,\n",
" X = X_train, \n",
" y = y_train)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output = True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Deploy\n",
"\n",
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method on `automl_classifier` returns the best run and the fitted model for the last invocation. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Register the Fitted Model for Deployment\n",
"If neither `metric` nor `iteration` are specified in the `register_model` call, the iteration with the best primary metric is registered."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"description = 'AutoML Model'\n",
"tags = None\n",
"model = local_run.register_model(description = description, tags = tags)\n",
"\n",
"print(local_run.model_id) # This will be written to the script file later in the notebook."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create Scoring Script"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%writefile score.py\n",
"import pickle\n",
"import json\n",
"import numpy\n",
"import azureml.train.automl\n",
"from sklearn.externals import joblib\n",
"from azureml.core.model import Model\n",
"\n",
"\n",
"def init():\n",
" global model\n",
" model_path = Model.get_model_path(model_name = '<<modelid>>') # this name is model.id of model that we want to deploy\n",
" # deserialize the model file back into a sklearn model\n",
" model = joblib.load(model_path)\n",
"\n",
"def run(rawdata):\n",
" try:\n",
" data = json.loads(rawdata)['data']\n",
" data = numpy.array(data)\n",
" result = model.predict(data)\n",
" except Exception as e:\n",
" result = str(e)\n",
" return json.dumps({\"error\": result})\n",
" return json.dumps({\"result\":result.tolist()})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create a YAML File for the Environment"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To ensure the fit results are consistent with the training results, the SDK dependency versions need to be the same as the environment that trains the model. The following cells create a file, myenv.yml, which specifies the dependencies from the run."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"experiment = Experiment(ws, experiment_name)\n",
"ml_run = AutoMLRun(experiment = experiment, run_id = local_run.id)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dependencies = ml_run.get_run_sdk_dependencies(iteration = 7)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for p in ['azureml-train-automl', 'azureml-core']:\n",
" print('{}\\t{}'.format(p, dependencies[p]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.conda_dependencies import CondaDependencies\n",
"\n",
"myenv = CondaDependencies.create(conda_packages=['numpy','scikit-learn','py-xgboost<=0.80'],\n",
" pip_packages=['azureml-defaults','azureml-train-automl'])\n",
"\n",
"conda_env_file_name = 'myenv.yml'\n",
"myenv.save_to_file('.', conda_env_file_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Substitute the actual version number in the environment file.\n",
"# This is not strictly needed in this notebook because the model should have been generated using the current SDK version.\n",
"# However, we include this in case this code is used on an experiment from a previous SDK version.\n",
"\n",
"with open(conda_env_file_name, 'r') as cefr:\n",
" content = cefr.read()\n",
"\n",
"with open(conda_env_file_name, 'w') as cefw:\n",
" cefw.write(content.replace(azureml.core.VERSION, dependencies['azureml-train-automl']))\n",
"\n",
"# Substitute the actual model id in the script file.\n",
"\n",
"script_file_name = 'score.py'\n",
"\n",
"with open(script_file_name, 'r') as cefr:\n",
" content = cefr.read()\n",
"\n",
"with open(script_file_name, 'w') as cefw:\n",
" cefw.write(content.replace('<<modelid>>', local_run.model_id))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Deploy the model as a Web Service on Azure Container Instance\n",
"\n",
"Create the configuration needed for deploying the model as a web service service."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.model import InferenceConfig\n",
"from azureml.core.webservice import AciWebservice\n",
"\n",
"inference_config = InferenceConfig(runtime = \"python\", \n",
" entry_script = script_file_name,\n",
" conda_file = conda_env_file_name)\n",
"\n",
"aciconfig = AciWebservice.deploy_configuration(cpu_cores = 1, \n",
" memory_gb = 1, \n",
" tags = {'area': \"digits\", 'type': \"automl_classification\"}, \n",
" description = 'sample service for Automl Classification')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.webservice import Webservice\n",
"from azureml.core.model import Model\n",
"\n",
"aci_service_name = 'automl-sample-01'\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",
"print(aci_service.state)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get the logs from service deployment"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if aci_service.state != 'Healthy':\n",
" # run this command for debugging.\n",
" print(aci_service.get_logs())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Delete a Web Service"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#aci_service.delete()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Randomly select digits and test\n",
"digits = datasets.load_digits()\n",
"X_test = digits.data[:10, :]\n",
"y_test = digits.target[:10]\n",
"images = digits.images[:10]\n",
"\n",
"for index in np.random.choice(len(y_test), 3, replace = False):\n",
" print(index)\n",
" test_sample = json.dumps({'data':X_test[index:index + 1].tolist()})\n",
" predicted = aci_service.run(input_data = test_sample)\n",
" label = y_test[index]\n",
" predictedDict = json.loads(predicted)\n",
" title = \"Label value = %d Predicted value = %s \" % ( label,predictedDict['result'][0])\n",
" fig = plt.figure(1, figsize = (3,3))\n",
" ax1 = fig.add_axes((0,0,.8,.8))\n",
" ax1.set_title(title)\n",
" plt.imshow(images[index], cmap = plt.cm.gray_r, interpolation = 'nearest')\n",
" plt.show()"
]
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,375 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/classification-with-onnx/auto-ml-classification-with-onnx.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Classification with Local Compute**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"\n",
"In this example we use the scikit-learn's [iris dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_iris.html) to showcase how you can use AutoML for a simple classification problem.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"Please find the ONNX related documentations [here](https://github.com/onnx/onnx).\n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an `Experiment` in an existing `Workspace`.\n",
"2. Configure AutoML using `AutoMLConfig`.\n",
"3. Train the model using local compute with ONNX compatible config on.\n",
"4. Explore the results and save the ONNX model.\n",
"5. Inference with the ONNX model."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from sklearn import datasets\n",
"from sklearn.model_selection import train_test_split\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.train.automl import AutoMLConfig, constants"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# Choose a name for the experiment.\n",
"experiment_name = 'automl-classification-onnx'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"\n",
"This uses scikit-learn's [load_iris](https://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_iris.html) method."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"iris = datasets.load_iris()\n",
"X_train, X_test, y_train, y_test = train_test_split(iris.data, \n",
" iris.target, \n",
" test_size=0.2, \n",
" random_state=0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Ensure the x_train and x_test are pandas DataFrame."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Convert the X_train and X_test to pandas DataFrame and set column names,\n",
"# This is needed for initializing the input variable names of ONNX model, \n",
"# and the prediction with the ONNX model using the inference helper.\n",
"X_train = pd.DataFrame(X_train, columns=['c1', 'c2', 'c3', 'c4'])\n",
"X_test = pd.DataFrame(X_test, columns=['c1', 'c2', 'c3', 'c4'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate an `AutoMLConfig` object to specify the settings and data used to run the experiment.\n",
"\n",
"**Note:** Set the parameter enable_onnx_compatible_models=True, if you also want to generate the ONNX compatible models. Please note, the forecasting task and TensorFlow models are not ONNX compatible yet.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**X**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**y**|(sparse) array-like, shape = [n_samples, ], Multi-class targets.|\n",
"|**enable_onnx_compatible_models**|Enable the ONNX compatible models in the experiment.|"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Set the preprocess=True, currently the InferenceHelper only supports this mode."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" primary_metric = 'AUC_weighted',\n",
" iteration_timeout_minutes = 60,\n",
" iterations = 10,\n",
" verbosity = logging.INFO, \n",
" X = X_train, \n",
" y = y_train,\n",
" preprocess=True,\n",
" enable_onnx_compatible_models=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output = True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(local_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best ONNX Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method returns the best run and the fitted model. The Model includes the pipeline and any pre-processing. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*.\n",
"\n",
"Set the parameter return_onnx_model=True to retrieve the best ONNX model, instead of the Python model."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, onnx_mdl = local_run.get_output(return_onnx_model=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Save the best ONNX model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.automl.core.onnx_convert import OnnxConverter\n",
"onnx_fl_path = \"./best_model.onnx\"\n",
"OnnxConverter.save_onnx_model(onnx_mdl, onnx_fl_path)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Predict with the ONNX model, using onnxruntime package"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import json\n",
"from azureml.automl.core.onnx_convert import OnnxConvertConstants\n",
"\n",
"if sys.version_info < OnnxConvertConstants.OnnxIncompatiblePythonVersion:\n",
" python_version_compatible = True\n",
"else:\n",
" python_version_compatible = False\n",
"\n",
"try:\n",
" import onnxruntime\n",
" from azureml.automl.core.onnx_convert import OnnxInferenceHelper \n",
" onnxrt_present = True\n",
"except ImportError:\n",
" onnxrt_present = False\n",
"\n",
"def get_onnx_res(run):\n",
" res_path = 'onnx_resource.json'\n",
" run.download_file(name=constants.MODEL_RESOURCE_PATH_ONNX, output_file_path=res_path)\n",
" with open(res_path) as f:\n",
" onnx_res = json.load(f)\n",
" return onnx_res\n",
"\n",
"if onnxrt_present and python_version_compatible: \n",
" mdl_bytes = onnx_mdl.SerializeToString()\n",
" onnx_res = get_onnx_res(best_run)\n",
"\n",
" onnxrt_helper = OnnxInferenceHelper(mdl_bytes, onnx_res)\n",
" pred_onnx, pred_prob_onnx = onnxrt_helper.predict(X_test)\n",
"\n",
" print(pred_onnx)\n",
" print(pred_prob_onnx)\n",
"else:\n",
" if not python_version_compatible:\n",
" print('Please use Python version 3.6 or 3.7 to run the inference helper.') \n",
" if not onnxrt_present:\n",
" print('Please install the onnxruntime package to do the prediction with ONNX model.')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,395 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/classification-with-whitelisting/auto-ml-classification-with-whitelisting.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Classification using whitelist models**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Test](#Test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"\n",
"In this example we use the scikit-learn's [digit dataset](http://scikit-learn.org/stable/datasets/index.html#optical-recognition-of-handwritten-digits-dataset) to showcase how you can use AutoML for a simple classification problem.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"This notebooks shows how can automl can be trained on a selected list of models, see the readme.md for the models.\n",
"This trains the model exclusively on tensorflow based models.\n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an `Experiment` in an existing `Workspace`.\n",
"2. Configure AutoML using `AutoMLConfig`.\n",
"3. Train the model on a whilelisted models using local compute. \n",
"4. Explore the results.\n",
"5. Test the best fitted model."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Note: This notebook will install tensorflow if not already installed in the enviornment..\n",
"import logging\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from sklearn import datasets\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"import sys\n",
"whitelist_models=[\"LightGBM\"]\n",
"if \"3.7\" != sys.version[0:3]:\n",
" try:\n",
" import tensorflow as tf1\n",
" except ImportError:\n",
" from pip._internal import main\n",
" main(['install', 'tensorflow>=1.10.0,<=1.12.0'])\n",
" logging.getLogger().setLevel(logging.ERROR)\n",
" whitelist_models=[\"TensorFlowLinearClassifier\", \"TensorFlowDNN\"]\n",
"\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# Choose a name for the experiment.\n",
"experiment_name = 'automl-local-whitelist'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"\n",
"This uses scikit-learn's [load_digits](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html) method."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"digits = datasets.load_digits()\n",
"\n",
"# Exclude the first 100 rows from training so that they can be used for test.\n",
"X_train = digits.data[100:,:]\n",
"y_train = digits.target[100:]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate an `AutoMLConfig` object to specify the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>balanced_accuracy</i><br><i>average_precision_score_weighted</i><br><i>precision_score_weighted</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**X**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**y**|(sparse) array-like, shape = [n_samples, ], Multi-class targets.|\n",
"|**whitelist_models**|List of models that AutoML should use. The possible values are listed [here](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-configure-auto-train#configure-your-experiment-settings).|"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" primary_metric = 'AUC_weighted',\n",
" iteration_timeout_minutes = 60,\n",
" iterations = 10,\n",
" verbosity = logging.INFO,\n",
" X = X_train, \n",
" y = y_train,\n",
" enable_tf=True,\n",
" whitelist_models=whitelist_models)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output = True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(local_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"#### Retrieve All Child Runs\n",
"You can also use SDK methods to fetch all the child runs and see individual metrics that we log."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"children = list(local_run.get_children())\n",
"metricslist = {}\n",
"for run in children:\n",
" properties = run.get_properties()\n",
" metrics = {k: v for k, v in run.get_metrics().items() if isinstance(v, float)}\n",
" metricslist[int(properties['iteration'])] = metrics\n",
"\n",
"rundata = pd.DataFrame(metricslist).sort_index(1)\n",
"rundata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method returns the best run and the fitted model. The Model includes the pipeline and any pre-processing. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Best Model Based on Any Other Metric\n",
"Show the run and the model that has the smallest `log_loss` value:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lookup_metric = \"log_loss\"\n",
"best_run, fitted_model = local_run.get_output(metric = lookup_metric)\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Model from a Specific Iteration\n",
"Show the run and the model from the third iteration:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"iteration = 3\n",
"third_run, third_model = local_run.get_output(iteration = iteration)\n",
"print(third_run)\n",
"print(third_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test\n",
"\n",
"#### Load Test Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"digits = datasets.load_digits()\n",
"X_test = digits.data[:10, :]\n",
"y_test = digits.target[:10]\n",
"images = digits.images[:10]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Testing Our Best Fitted Model\n",
"We will try to predict 2 digits and see how our model works."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Randomly select digits and test.\n",
"for index in np.random.choice(len(y_test), 2, replace = False):\n",
" print(index)\n",
" predicted = fitted_model.predict(X_test[index:index + 1])[0]\n",
" label = y_test[index]\n",
" title = \"Label value = %d Predicted value = %d \" % (label, predicted)\n",
" fig = plt.figure(1, figsize = (3,3))\n",
" ax1 = fig.add_axes((0,0,.8,.8))\n",
" ax1.set_title(title)\n",
" plt.imshow(images[index], cmap = plt.cm.gray_r, interpolation = 'nearest')\n",
" plt.show()"
]
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,8 +0,0 @@
name: auto-ml-classification-with-whitelisting
dependencies:
- pip:
- azureml-sdk
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml

View File

@@ -1,484 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/classification/auto-ml-classification.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Classification with Local Compute**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Test](#Test)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"\n",
"In this example we use the scikit-learn's [digit dataset](http://scikit-learn.org/stable/datasets/index.html#optical-recognition-of-handwritten-digits-dataset) to showcase how you can use AutoML for a simple classification problem.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an `Experiment` in an existing `Workspace`.\n",
"2. Configure AutoML using `AutoMLConfig`.\n",
"3. Train the model using local compute.\n",
"4. Explore the results.\n",
"5. Test the best fitted model."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from sklearn import datasets\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Accessing the Azure ML workspace requires authentication with Azure.\n",
"\n",
"The default authentication is interactive authentication using the default tenant. Executing the `ws = Workspace.from_config()` line in the cell below will prompt for authentication the first time that it is run.\n",
"\n",
"If you have multiple Azure tenants, you can specify the tenant by replacing the `ws = Workspace.from_config()` line in the cell below with the following:\n",
"\n",
"```\n",
"from azureml.core.authentication import InteractiveLoginAuthentication\n",
"auth = InteractiveLoginAuthentication(tenant_id = 'mytenantid')\n",
"ws = Workspace.from_config(auth = auth)\n",
"```\n",
"\n",
"If you need to run in an environment where interactive login is not possible, you can use Service Principal authentication by replacing the `ws = Workspace.from_config()` line in the cell below with the following:\n",
"\n",
"```\n",
"from azureml.core.authentication import ServicePrincipalAuthentication\n",
"auth = auth = ServicePrincipalAuthentication('mytenantid', 'myappid', 'mypassword')\n",
"ws = Workspace.from_config(auth = auth)\n",
"```\n",
"For more details, see [aka.ms/aml-notebook-auth](http://aka.ms/aml-notebook-auth)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# Choose a name for the experiment.\n",
"experiment_name = 'automl-classification'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"\n",
"This uses scikit-learn's [load_digits](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html) method."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"digits = datasets.load_digits()\n",
"\n",
"# Exclude the first 100 rows from training so that they can be used for test.\n",
"X_train = digits.data[100:,:]\n",
"y_train = digits.target[100:]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate an `AutoMLConfig` object to specify the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**X**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**y**|(sparse) array-like, shape = [n_samples, ], Multi-class targets.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|\n",
"\n",
"Automated machine learning trains multiple machine learning pipelines. Each pipelines training is known as an iteration.\n",
"* You can specify a maximum number of iterations using the `iterations` parameter.\n",
"* You can specify a maximum time for the run using the `experiment_timeout_minutes` parameter.\n",
"* If you specify neither the `iterations` nor the `experiment_timeout_minutes`, automated ML keeps running iterations while it continues to see improvements in the scores.\n",
"\n",
"The following example doesn't specify `iterations` or `experiment_timeout_minutes` and so runs until the scores stop improving.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_config = AutoMLConfig(task = 'classification',\n",
" primary_metric = 'AUC_weighted',\n",
" X = X_train, \n",
" y = y_train,\n",
" n_cross_validations = 3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output = True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Optionally, you can continue an interrupted local run by calling `continue_experiment` without the `iterations` parameter, or run more iterations for a completed run by specifying the `iterations` parameter:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = local_run.continue_experiment(X = X_train, \n",
" y = y_train, \n",
" show_output = True,\n",
" iterations = 5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"widget-rundetails-sample"
]
},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(local_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"#### Retrieve All Child Runs\n",
"You can also use SDK methods to fetch all the child runs and see individual metrics that we log."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"children = list(local_run.get_children())\n",
"metricslist = {}\n",
"for run in children:\n",
" properties = run.get_properties()\n",
" metrics = {k: v for k, v in run.get_metrics().items() if isinstance(v, float)}\n",
" metricslist[int(properties['iteration'])] = metrics\n",
"\n",
"rundata = pd.DataFrame(metricslist).sort_index(1)\n",
"rundata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method returns the best run and the fitted model. The Model includes the pipeline and any pre-processing. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()\n",
"print(best_run)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Print the properties of the model\n",
"The fitted_model is a python object and you can read the different properties of the object.\n",
"The following shows printing hyperparameters for each step in the pipeline."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pprint import pprint\n",
"\n",
"def print_model(model, prefix=\"\"):\n",
" for step in model.steps:\n",
" print(prefix + step[0])\n",
" if hasattr(step[1], 'estimators') and hasattr(step[1], 'weights'):\n",
" pprint({'estimators': list(e[0] for e in step[1].estimators), 'weights': step[1].weights})\n",
" print()\n",
" for estimator in step[1].estimators:\n",
" print_model(estimator[1], estimator[0]+ ' - ')\n",
" elif hasattr(step[1], '_base_learners') and hasattr(step[1], '_meta_learner'):\n",
" print(\"\\nMeta Learner\")\n",
" pprint(step[1]._meta_learner)\n",
" print()\n",
" for estimator in step[1]._base_learners:\n",
" print_model(estimator[1], estimator[0]+ ' - ')\n",
" else:\n",
" pprint(step[1].get_params())\n",
" print()\n",
" \n",
"print_model(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Best Model Based on Any Other Metric\n",
"Show the run and the model that has the smallest `log_loss` value:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lookup_metric = \"log_loss\"\n",
"best_run, fitted_model = local_run.get_output(metric = lookup_metric)\n",
"print(best_run)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print_model(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Model from a Specific Iteration\n",
"Show the run and the model from the third iteration:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"iteration = 3\n",
"third_run, third_model = local_run.get_output(iteration = iteration)\n",
"print(third_run)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print_model(third_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test \n",
"\n",
"#### Load Test Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"digits = datasets.load_digits()\n",
"X_test = digits.data[:10, :]\n",
"y_test = digits.target[:10]\n",
"images = digits.images[:10]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Testing Our Best Fitted Model\n",
"We will try to predict 2 digits and see how our model works."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Randomly select digits and test.\n",
"for index in np.random.choice(len(y_test), 2, replace = False):\n",
" print(index)\n",
" predicted = fitted_model.predict(X_test[index:index + 1])[0]\n",
" label = y_test[index]\n",
" title = \"Label value = %d Predicted value = %d \" % (label, predicted)\n",
" fig = plt.figure(1, figsize = (3,3))\n",
" ax1 = fig.add_axes((0,0,.8,.8))\n",
" ax1.set_title(title)\n",
" plt.imshow(images[index], cmap = plt.cm.gray_r, interpolation = 'nearest')\n",
" plt.show()"
]
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,8 +0,0 @@
name: auto-ml-classification
dependencies:
- pip:
- azureml-sdk
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml

View File

@@ -0,0 +1,555 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved. \n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/continous-retraining/auto-ml-continuous-retraining.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning \n",
"**Continous retraining using Pipelines and Time-Series TabularDataset**\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"2. [Setup](#Setup)\n",
"3. [Compute](#Compute)\n",
"4. [Run Configuration](#Run-Configuration)\n",
"5. [Data Ingestion Pipeline](#Data-Ingestion-Pipeline)\n",
"6. [Training Pipeline](#Training-Pipeline)\n",
"7. [Publish Retraining Pipeline and Schedule](#Publish-Retraining-Pipeline-and-Schedule)\n",
"8. [Test Retraining](#Test-Retraining)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"An Enterprise workspace is required for this notebook. To learn more about creating an Enterprise workspace or upgrading to an Enterprise workspace from the Azure portal, please visit our [Workspace page.](https://docs.microsoft.com/azure/machine-learning/service/concept-workspace#upgrade)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we use AutoML and Pipelines to enable contious retraining of a model based on updates to the training dataset. We will create two pipelines, the first one to demonstrate a training dataset that gets updated over time. We leverage time-series capabilities of `TabularDataset` to achieve this. The second pipeline utilizes pipeline `Schedule` to trigger continuous retraining. \n",
"Make sure you have executed the [configuration notebook](../../../configuration.ipynb) before running this notebook.\n",
"In this notebook you will learn how to:\n",
"* Create an Experiment in an existing Workspace.\n",
"* Configure AutoML using AutoMLConfig.\n",
"* Create data ingestion pipeline to update a time-series based TabularDataset\n",
"* Create training pipeline to prepare data, run AutoML, register the model and setup pipeline triggers.\n",
"\n",
"## Setup\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from sklearn import datasets\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Accessing the Azure ML workspace requires authentication with Azure.\n",
"\n",
"The default authentication is interactive authentication using the default tenant. Executing the ws = Workspace.from_config() line in the cell below will prompt for authentication the first time that it is run.\n",
"\n",
"If you have multiple Azure tenants, you can specify the tenant by replacing the ws = Workspace.from_config() line in the cell below with the following:\n",
"```\n",
"from azureml.core.authentication import InteractiveLoginAuthentication\n",
"auth = InteractiveLoginAuthentication(tenant_id = 'mytenantid')\n",
"ws = Workspace.from_config(auth = auth)\n",
"```\n",
"If you need to run in an environment where interactive login is not possible, you can use Service Principal authentication by replacing the ws = Workspace.from_config() line in the cell below with the following:\n",
"```\n",
"from azureml.core.authentication import ServicePrincipalAuthentication\n",
"auth = auth = ServicePrincipalAuthentication('mytenantid', 'myappid', 'mypassword')\n",
"ws = Workspace.from_config(auth = auth)\n",
"```\n",
"For more details, see aka.ms/aml-notebook-auth"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"dstor = ws.get_default_datastore()\n",
"\n",
"# Choose a name for the run history container in the workspace.\n",
"experiment_name = 'retrain-noaaweather'\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Run History Name'] = experiment_name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Compute \n",
"\n",
"#### Create or Attach existing AmlCompute\n",
"\n",
"You will need to create a compute target for your AutoML run. In this tutorial, you create AmlCompute as your training compute resource.\n",
"#### 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 on the default limits and how to request more quota."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.compute import AmlCompute, ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"cpu-cluster-42\"\n",
"\n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
" \n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_D2_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 4)\n",
"\n",
" # Create the cluster.\n",
" compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, provisioning_config)\n",
" \n",
" # Can poll for a minimum number of nodes and for a specific timeout.\n",
" # If no min_node_count is provided, it will use the scale settings for the cluster.\n",
" compute_target.wait_for_completion(show_output = True, min_node_count = 0, timeout_in_minutes = 10)\n",
" \n",
" # For a more detailed view of current AmlCompute status, use get_status()."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Run Configuration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.runconfig import CondaDependencies, DEFAULT_CPU_IMAGE, RunConfiguration\n",
"\n",
"# create a new RunConfig object\n",
"conda_run_config = RunConfiguration(framework=\"python\")\n",
"\n",
"# Set compute target to AmlCompute\n",
"conda_run_config.target = compute_target\n",
"\n",
"conda_run_config.environment.docker.enabled = True\n",
"conda_run_config.environment.docker.base_image = azureml.core.runconfig.DEFAULT_CPU_IMAGE\n",
"\n",
"cd = CondaDependencies.create(pip_packages=['azureml-sdk[automl]', 'applicationinsights', 'azureml-opendatasets'], \n",
" conda_packages=['numpy', 'py-xgboost'], \n",
" pin_sdk_version=False)\n",
"#cd.add_pip_package('azureml-explain-model')\n",
"conda_run_config.environment.python.conda_dependencies = cd\n",
"\n",
"print('run config is ready')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data Ingestion Pipeline \n",
"For this demo, we will use NOAA weather data from [Azure Open Datasets](https://azure.microsoft.com/services/open-datasets/). You can replace this with your own dataset, or you can skip this pipeline if you already have a time-series based `TabularDataset`.\n",
"\n",
"### Upload Data Step\n",
"The data ingestion pipeline has a single step with a script to query the latest weather data and upload it to the blob store. During the first run, the script will create and register a time-series based `TabularDataset` with the past one week of weather data. For each subsequent run, the script will create a partition in the blob store by querying NOAA for new weather data since the last modified time of the dataset (`dataset.data_changed_time`) and creating a data.csv file."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.pipeline.core import Pipeline, PipelineParameter\n",
"from azureml.pipeline.steps import PythonScriptStep\n",
"\n",
"# The name of the Dataset to create \n",
"dataset = \"NOAA-Weather-DS4\"\n",
"ds_name = PipelineParameter(name=\"ds_name\", default_value=dataset)\n",
"upload_data_step = PythonScriptStep(script_name=\"upload_weather_data.py\", \n",
" allow_reuse=False,\n",
" name=\"upload_weather_data\",\n",
" arguments=[\"--ds_name\", ds_name],\n",
" compute_target=compute_target, \n",
" runconfig=conda_run_config)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Submit Pipeline Run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data_pipeline = Pipeline(\n",
" description=\"pipeline_with_uploaddata\",\n",
" workspace=ws, \n",
" steps=[upload_data_step])\n",
"data_pipeline_run = experiment.submit(data_pipeline, pipeline_parameters={\"ds_name\":dataset})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data_pipeline_run.wait_for_completion()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Training Pipeline\n",
"### Prepare Training Data Step\n",
"\n",
"Script to bring data into common X,y format. We need to set allow_reuse flag to False to allow the pipeline to run even when inputs don't change. We also need the name of the model to check the time the model was last trained."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.pipeline.core import PipelineData\n",
"\n",
"target_column = PipelineParameter(\"target_column\", default_value=\"y\")\n",
"# The model name with which to register the trained model in the workspace.\n",
"model_name = PipelineParameter(\"model_name\", default_value=\"y\")\n",
"output_x = PipelineData(\"output_x\", datastore=dstor)\n",
"output_y = PipelineData(\"output_y\", datastore=dstor)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data_prep_step = PythonScriptStep(script_name=\"check_data.py\", \n",
" allow_reuse=False,\n",
" name=\"check_data\",\n",
" arguments=[\"--target_column\", target_column,\n",
" \"--output_x\", output_x,\n",
" \"--output_y\", output_y,\n",
" \"--ds_name\", ds_name,\n",
" \"--model_name\", model_name],\n",
" outputs=[output_x, output_y], \n",
" compute_target=compute_target, \n",
" runconfig=conda_run_config)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### AutoMLStep\n",
"Create an AutoMLConfig and a training step."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.train.automl import AutoMLStep, AutoMLConfig\n",
"\n",
"automl_settings = {\n",
" \"iteration_timeout_minutes\": 20,\n",
" \"experiment_timeout_minutes\": 30,\n",
" \"n_cross_validations\": 3,\n",
" \"primary_metric\": 'r2_score',\n",
" \"preprocess\": True,\n",
" \"max_concurrent_iterations\": 3,\n",
" \"max_cores_per_iteration\": -1,\n",
" \"verbosity\": logging.INFO,\n",
" \"enable_early_stopping\": True\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task = 'regression',\n",
" debug_log = 'automl_errors.log',\n",
" path = \".\",\n",
" compute_target=compute_target,\n",
" run_configuration=conda_run_config,\n",
" data_script = \"get_data.py\",\n",
" **automl_settings\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.pipeline.core import PipelineData, TrainingOutput\n",
"\n",
"metrics_output_name = 'metrics_output'\n",
"best_model_output_name = 'best_model_output'\n",
"\n",
"metirics_data = PipelineData(name='metrics_data',\n",
" datastore=dstor,\n",
" pipeline_output_name=metrics_output_name,\n",
" training_output=TrainingOutput(type='Metrics'))\n",
"model_data = PipelineData(name='model_data',\n",
" datastore=dstor,\n",
" pipeline_output_name=best_model_output_name,\n",
" training_output=TrainingOutput(type='Model'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_step = AutoMLStep(\n",
" name='automl_module',\n",
" automl_config=automl_config,\n",
" inputs=[output_x, output_y],\n",
" outputs=[metirics_data, model_data],\n",
" allow_reuse=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Register Model Step\n",
"Script to register the model to the workspace. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"register_model_step = PythonScriptStep(script_name=\"register_model.py\",\n",
" name=\"register_model\",\n",
" allow_reuse=False,\n",
" arguments=[\"--model_name\", model_name, \"--model_path\", model_data, \"--ds_name\", ds_name],\n",
" inputs=[model_data],\n",
" compute_target=compute_target,\n",
" runconfig=conda_run_config)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Submit Pipeline Run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"training_pipeline = Pipeline(\n",
" description=\"training_pipeline\",\n",
" workspace=ws, \n",
" steps=[data_prep_step, automl_step, register_model_step])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"training_pipeline_run = experiment.submit(training_pipeline, pipeline_parameters={\n",
" \"target_column\": \"temperature\", \"ds_name\": dataset, \"model_name\": \"noaaweatherds\"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"training_pipeline_run.wait_for_completion()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Publish Retraining Pipeline and Schedule\n",
"Once we are happy with the pipeline, we can publish the training pipeline to the workspace and create a schedule to trigger on blob change. The schedule polls the blob store where the data is being uploaded and runs the retraining pipeline if there is a data change. A new version of the model will be registered to the workspace once the run is complete."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pipeline_name = \"Retraining-Pipeline-NOAAWeather\"\n",
"\n",
"published_pipeline = training_pipeline.publish(\n",
" name=pipeline_name, \n",
" description=\"Pipeline that retrains AutoML model\")\n",
"\n",
"published_pipeline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.pipeline.core import Schedule\n",
"schedule = Schedule.create(workspace=ws, name=\"RetrainingSchedule\",\n",
" pipeline_parameters={\"target_column\": \"temperature\",\"ds_name\": dataset, \"model_name\": \"noaaweatherds\"},\n",
" pipeline_id=published_pipeline.id, \n",
" experiment_name=experiment_name, \n",
" datastore=dstor,\n",
" wait_for_provisioning=True,\n",
" polling_interval=1440)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test Retraining\n",
"Here we setup the data ingestion pipeline to run on a schedule, to verify that the retraining pipeline runs as expected. \n",
"\n",
"Note: \n",
"* Azure NOAA Weather data is updated daily and retraining will not trigger if there is no new data available. \n",
"* Depending on the polling interval set in the schedule, the retraining may take some time trigger after data ingestion pipeline completes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pipeline_name = \"DataIngestion-Pipeline-NOAAWeather\"\n",
"\n",
"published_pipeline = training_pipeline.publish(\n",
" name=pipeline_name, \n",
" description=\"Pipeline that updates NOAAWeather Dataset\")\n",
"\n",
"published_pipeline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.pipeline.core import Schedule\n",
"schedule = Schedule.create(workspace=ws, name=\"RetrainingSchedule-DataIngestion\",\n",
" pipeline_parameters={\"ds_name\":dataset},\n",
" pipeline_id=published_pipeline.id, \n",
" experiment_name=experiment_name, \n",
" datastore=dstor,\n",
" wait_for_provisioning=True,\n",
" polling_interval=1440)"
]
}
],
"metadata": {
"authors": [
{
"name": "vivijay"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,8 +1,9 @@
name: auto-ml-classification-with-deployment
name: auto-ml-continuous-retraining
dependencies:
- pip:
- azureml-sdk
- azureml-train-automl
- azureml-pipeline
- azureml-widgets
- matplotlib
- pandas_ml

View File

@@ -0,0 +1,75 @@
import argparse
import os
import azureml.core
from datetime import datetime
import pandas as pd
import pytz
from azureml.core import Dataset, Model
from azureml.core.run import Run, _OfflineRun
from azureml.core import Workspace
run = Run.get_context()
ws = None
if type(run) == _OfflineRun:
ws = Workspace.from_config()
else:
ws = run.experiment.workspace
def write_output(df, path):
os.makedirs(path, exist_ok=True)
print("%s created" % path)
df.to_csv(path + "/part-00000", index=False)
print("Check for new data and prepare the data")
parser = argparse.ArgumentParser("split")
parser.add_argument("--target_column", type=str, help="input split features")
parser.add_argument("--ds_name", help="input dataset name")
parser.add_argument("--model_name", help="name of the deployed model")
parser.add_argument("--output_x", type=str,
help="output features")
parser.add_argument("--output_y", type=str,
help="output labels")
args = parser.parse_args()
print("Argument 1(ds_name): %s" % args.ds_name)
print("Argument 2(target_column): %s" % args.target_column)
print("Argument 3(model_name): %s" % args.model_name)
print("Argument 4(output_x): %s" % args.output_x)
print("Argument 5(output_y): %s" % args.output_y)
# Get the latest registered model
try:
model = Model(ws, args.model_name)
last_train_time = model.created_time
print("Model was last trained on {0}.".format(last_train_time))
except Exception as e:
print("Could not get last model train time.")
last_train_time = datetime.min.replace(tzinfo=pytz.UTC)
train_ds = Dataset.get_by_name(ws, args.ds_name)
dataset_changed_time = train_ds.data_changed_time
if dataset_changed_time > last_train_time:
# New data is available since the model was last trained
print("Dataset was last updated on {0}. Retraining...".format(dataset_changed_time))
train_ds = train_ds.drop_columns(["partition_date"])
X_train = train_ds.drop_columns(
columns=[args.target_column]).to_pandas_dataframe()
y_train = train_ds.keep_columns(
columns=[args.target_column]).to_pandas_dataframe()
non_null = y_train[args.target_column].notnull()
y = y_train[non_null]
X = X_train[non_null]
if not (args.output_x is None and args.output_y is None):
write_output(X, args.output_x)
write_output(y, args.output_y)
else:
print("Cancelling run since there is no new data.")
run.parent.cancel()

View File

@@ -0,0 +1,15 @@
import os
import pandas as pd
def get_data():
print("In get_data")
print(os.environ['AZUREML_DATAREFERENCE_output_x'])
X_train = pd.read_csv(
os.environ['AZUREML_DATAREFERENCE_output_x'] + "/part-00000")
y_train = pd.read_csv(
os.environ['AZUREML_DATAREFERENCE_output_y'] + "/part-00000")
print(X_train.head(3))
return {"X": X_train.values, "y": y_train.values.flatten()}

View File

@@ -0,0 +1,33 @@
from azureml.core.model import Model, Dataset
from azureml.core.run import Run, _OfflineRun
from azureml.core import Workspace
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--model_name")
parser.add_argument("--model_path")
parser.add_argument("--ds_name")
args = parser.parse_args()
print("Argument 1(model_name): %s" % args.model_name)
print("Argument 2(model_path): %s" % args.model_path)
print("Argument 3(ds_name): %s" % args.ds_name)
run = Run.get_context()
ws = None
if type(run) == _OfflineRun:
ws = Workspace.from_config()
else:
ws = run.experiment.workspace
train_ds = Dataset.get_by_name(ws, args.ds_name)
datasets = [(Dataset.Scenario.TRAINING, train_ds)]
# Register model with training dataset
model = Model.register(workspace=ws,
model_path=args.model_path,
model_name=args.model_name,
datasets=datasets)
print("Registered version {0} of model {1}".format(model.version, model.name))

View File

@@ -0,0 +1,89 @@
import argparse
import os
from datetime import datetime
from dateutil.relativedelta import relativedelta
import pandas as pd
import traceback
from azureml.core import Dataset
from azureml.core.run import Run, _OfflineRun
from azureml.core import Workspace
from azureml.opendatasets import NoaaIsdWeather
run = Run.get_context()
ws = None
if type(run) == _OfflineRun:
ws = Workspace.from_config()
else:
ws = run.experiment.workspace
usaf_list = ['725724', '722149', '723090', '722159', '723910', '720279',
'725513', '725254', '726430', '720381', '723074', '726682',
'725486', '727883', '723177', '722075', '723086', '724053',
'725070', '722073', '726060', '725224', '725260', '724520',
'720305', '724020', '726510', '725126', '722523', '703333',
'722249', '722728', '725483', '722972', '724975', '742079',
'727468', '722193', '725624', '722030', '726380', '720309',
'722071', '720326', '725415', '724504', '725665', '725424',
'725066']
def get_noaa_data(start_time, end_time):
columns = ['usaf', 'wban', 'datetime', 'latitude', 'longitude', 'elevation',
'windAngle', 'windSpeed', 'temperature', 'stationName', 'p_k']
isd = NoaaIsdWeather(start_time, end_time, cols=columns)
noaa_df = isd.to_pandas_dataframe()
df_filtered = noaa_df[noaa_df["usaf"].isin(usaf_list)]
df_filtered.reset_index(drop=True)
print("Received {0} rows of training data between {1} and {2}".format(
df_filtered.shape[0], start_time, end_time))
return df_filtered
print("Check for new data and prepare the data")
parser = argparse.ArgumentParser("split")
parser.add_argument("--ds_name", help="name of the Dataset to update")
args = parser.parse_args()
print("Argument 1(ds_name): %s" % args.ds_name)
dstor = ws.get_default_datastore()
register_dataset = False
try:
ds = Dataset.get_by_name(ws, args.ds_name)
end_time_last_slice = ds.data_changed_time.replace(tzinfo=None)
print("Dataset {0} last updated on {1}".format(args.ds_name,
end_time_last_slice))
except Exception as e:
print(traceback.format_exc())
print("Dataset with name {0} not found, registering new dataset.".format(args.ds_name))
register_dataset = True
end_time_last_slice = datetime.today() - relativedelta(weeks=1)
end_time = datetime.utcnow()
train_df = get_noaa_data(end_time_last_slice, end_time)
if train_df.size > 0:
print("Received {0} rows of new data after {0}.".format(
train_df.shape[0], end_time_last_slice))
folder_name = "{}/{:04d}/{:02d}/{:02d}/{:02d}/{:02d}/{:02d}".format(args.ds_name, end_time.year,
end_time.month, end_time.day,
end_time.hour, end_time.minute,
end_time.second)
file_path = "{0}/data.csv".format(folder_name)
# Add a new partition to the registered dataset
os.makedirs(folder_name, exist_ok=True)
train_df.to_csv(file_path, index=False)
dstor.upload_files(files=[file_path],
target_path=folder_name,
overwrite=True,
show_progress=True)
if register_dataset:
ds = Dataset.Tabular.from_delimited_files(dstor.path("{}/**/*.csv".format(
args.ds_name)), partition_format='/{partition_date:yyyy/MM/dd/hh/mm/ss}/data.csv')
ds.register(ws, name=args.ds_name)
else:
print("No new data since {0}.".format(end_time_last_slice))

View File

@@ -1,505 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/dataprep-remote-execution/auto-ml-dataprep-remote-execution.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Load Data using `TabularDataset` for Remote Execution (AmlCompute)**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Test](#Test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we showcase how you can use AzureML Dataset to load data for AutoML.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create a `TabularDataset` pointing to the training data.\n",
"2. Pass the `TabularDataset` to AutoML for a remote run."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"import pandas as pd\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.dataset import Dataset\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# choose a name for experiment\n",
"experiment_name = 'automl-dataset-remote-bai'\n",
" \n",
"experiment = Experiment(ws, experiment_name)\n",
" \n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# The data referenced here was a 1MB simple random sample of the Chicago Crime data into a local temporary directory.\n",
"example_data = 'https://dprepdata.blob.core.windows.net/demo/crime0-random.csv'\n",
"dataset = Dataset.Tabular.from_delimited_files(example_data)\n",
"dataset.take(5).to_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Review the data\n",
"\n",
"You can peek the result of a `TabularDataset` at any range using `skip(i)` and `take(j).to_pandas_dataframe()`. Doing so evaluates only `j` records, which makes it fast even against large datasets.\n",
"\n",
"`TabularDataset` objects are immutable and are composed of a list of subsetting transformations (optional)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"training_data = dataset.drop_columns(columns=['FBI Code'])\n",
"label_column_name = 'Primary Type'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"This creates a general AutoML settings object applicable for both local and remote runs."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_settings = {\n",
" \"iteration_timeout_minutes\" : 10,\n",
" \"iterations\" : 2,\n",
" \"primary_metric\" : 'AUC_weighted',\n",
" \"preprocess\" : True,\n",
" \"verbosity\" : logging.INFO\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create or Attach an AmlCompute cluster"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.compute import AmlCompute\n",
"from azureml.core.compute import ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"automlc2\"\n",
"\n",
"found = False\n",
"\n",
"# Check if this compute target already exists in the workspace.\n",
"\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
"\n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_D2_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 6)\n",
"\n",
" # Create the cluster.\\n\",\n",
" compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, provisioning_config)\n",
"\n",
"print('Checking cluster status...')\n",
"# Can poll for a minimum number of nodes and for a specific timeout.\n",
"# If no min_node_count is provided, it will use the scale settings for the cluster.\n",
"compute_target.wait_for_completion(show_output = True, min_node_count = None, timeout_in_minutes = 20)\n",
"\n",
"# For a more detailed view of current AmlCompute status, use get_status()."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.runconfig import RunConfiguration\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"import pkg_resources\n",
"\n",
"# create a new RunConfig object\n",
"conda_run_config = RunConfiguration(framework=\"python\")\n",
"\n",
"# Set compute target to AmlCompute\n",
"conda_run_config.target = compute_target\n",
"conda_run_config.environment.docker.enabled = True\n",
"\n",
"cd = CondaDependencies.create(conda_packages=['numpy','py-xgboost<=0.80'])\n",
"conda_run_config.environment.python.conda_dependencies = cd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Pass Data with `TabularDataset` Objects\n",
"\n",
"The `TabularDataset` objects captured above can also be passed to the `submit` method for a remote run. AutoML will serialize the `TabularDataset` object and send it to the remote compute target. The `TabularDataset` will not be evaluated locally."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" run_configuration=conda_run_config,\n",
" training_data = training_data,\n",
" label_column_name = label_column_name,\n",
" **automl_settings)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run = experiment.submit(automl_config, show_output = True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Pre-process cache cleanup\n",
"The preprocess data gets cache at user default file store. When the run is completed the cache can be cleaned by running below cell"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run.clean_preprocessor_cache()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Cancelling Runs\n",
"You can cancel ongoing remote runs using the `cancel` and `cancel_iteration` functions."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Cancel the ongoing experiment and stop scheduling new iterations.\n",
"# remote_run.cancel()\n",
"\n",
"# Cancel iteration 1 and move onto iteration 2.\n",
"# remote_run.cancel_iteration(1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(remote_run).show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Retrieve All Child Runs\n",
"You can also use SDK methods to fetch all the child runs and see individual metrics that we log."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"children = list(remote_run.get_children())\n",
"metricslist = {}\n",
"for run in children:\n",
" properties = run.get_properties()\n",
" metrics = {k: v for k, v in run.get_metrics().items() if isinstance(v, float)}\n",
" metricslist[int(properties['iteration'])] = metrics\n",
" \n",
"rundata = pd.DataFrame(metricslist).sort_index(1)\n",
"rundata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method returns the best run and the fitted model. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = remote_run.get_output()\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Best Model Based on Any Other Metric\n",
"Show the run and the model that has the smallest `log_loss` value:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lookup_metric = \"log_loss\"\n",
"best_run, fitted_model = remote_run.get_output(metric = lookup_metric)\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Model from a Specific Iteration\n",
"Show the run and the model from the first iteration:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"iteration = 0\n",
"best_run, fitted_model = remote_run.get_output(iteration = iteration)\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test\n",
"\n",
"#### Load Test Data\n",
"For the test data, it should have the same preparation step as the train data. Otherwise it might get failed at the preprocessing step."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataset_test = Dataset.Tabular.from_delimited_files(path='https://dprepdata.blob.core.windows.net/demo/crime0-test.csv')\n",
"\n",
"df_test = dataset_test.to_pandas_dataframe()\n",
"df_test = df_test[pd.notnull(df_test['Primary Type'])]\n",
"\n",
"y_test = df_test[['Primary Type']]\n",
"X_test = df_test.drop(['Primary Type', 'FBI Code'], axis=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Testing Our Best Fitted Model\n",
"We will use confusion matrix to see how our model works."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pandas_ml import ConfusionMatrix\n",
"\n",
"ypred = fitted_model.predict(X_test)\n",
"\n",
"cm = ConfusionMatrix(y_test['Primary Type'], ypred)\n",
"\n",
"print(cm)\n",
"\n",
"cm.plot()"
]
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,399 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/dataprep/auto-ml-dataprep.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Load Data using `TabularDataset` for Local Execution**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Test](#Test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we showcase how you can use AzureML Dataset to load data for AutoML.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create a `TabularDataset` pointing to the training data.\n",
"2. Pass the `TabularDataset` to AutoML for a local run."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"import pandas as pd\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.dataset import Dataset\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
" \n",
"# choose a name for experiment\n",
"experiment_name = 'automl-dataset-local'\n",
" \n",
"experiment = Experiment(ws, experiment_name)\n",
" \n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# The data referenced here was a 1MB simple random sample of the Chicago Crime data into a local temporary directory.\n",
"example_data = 'https://dprepdata.blob.core.windows.net/demo/crime0-random.csv'\n",
"dataset = Dataset.Tabular.from_delimited_files(example_data)\n",
"dataset.take(5).to_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Review the data\n",
"\n",
"You can peek the result of a `TabularDataset` at any range using `skip(i)` and `take(j).to_pandas_dataframe()`. Doing so evaluates only `j` records, which makes it fast even against large datasets.\n",
"\n",
"`TabularDataset` objects are immutable and are composed of a list of subsetting transformations (optional)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"training_data = dataset.drop_columns(columns=['FBI Code'])\n",
"label_column_name = 'Primary Type'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"This creates a general AutoML settings object applicable for both local and remote runs."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_settings = {\n",
" \"iteration_timeout_minutes\" : 10,\n",
" \"iterations\" : 2,\n",
" \"primary_metric\" : 'AUC_weighted',\n",
" \"preprocess\" : True,\n",
" \"verbosity\" : logging.INFO\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Pass Data with `TabularDataset` Objects\n",
"\n",
"The `TabularDataset` objects captured above can be passed to the `submit` method for a local run. AutoML will retrieve the results from the `TabularDataset` for model training."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" training_data = training_data,\n",
" label_column_name = label_column_name,\n",
" **automl_settings)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output = True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(local_run).show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Retrieve All Child Runs\n",
"You can also use SDK methods to fetch all the child runs and see individual metrics that we log."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"children = list(local_run.get_children())\n",
"metricslist = {}\n",
"for run in children:\n",
" properties = run.get_properties()\n",
" metrics = {k: v for k, v in run.get_metrics().items() if isinstance(v, float)}\n",
" metricslist[int(properties['iteration'])] = metrics\n",
" \n",
"rundata = pd.DataFrame(metricslist).sort_index(1)\n",
"rundata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method returns the best run and the fitted model. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Best Model Based on Any Other Metric\n",
"Show the run and the model that has the smallest `log_loss` value:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lookup_metric = \"log_loss\"\n",
"best_run, fitted_model = local_run.get_output(metric = lookup_metric)\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Model from a Specific Iteration\n",
"Show the run and the model from the first iteration:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"iteration = 0\n",
"best_run, fitted_model = local_run.get_output(iteration = iteration)\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test\n",
"\n",
"#### Load Test Data\n",
"For the test data, it should have the same preparation step as the train data. Otherwise it might get failed at the preprocessing step."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataset_test = Dataset.Tabular.from_delimited_files(path='https://dprepdata.blob.core.windows.net/demo/crime0-test.csv')\n",
"\n",
"df_test = dataset_test.to_pandas_dataframe()\n",
"df_test = df_test[pd.notnull(df_test['Primary Type'])]\n",
"\n",
"y_test = df_test[['Primary Type']]\n",
"X_test = df_test.drop(['Primary Type', 'FBI Code'], axis=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Testing Our Best Fitted Model\n",
"We will use confusion matrix to see how our model works."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pandas_ml import ConfusionMatrix\n",
"\n",
"ypred = fitted_model.predict(X_test)\n",
"\n",
"cm = ConfusionMatrix(y_test['Primary Type'], ypred)\n",
"\n",
"print(cm)\n",
"\n",
"cm.plot()"
]
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,9 +0,0 @@
name: auto-ml-dataset
dependencies:
- pip:
- azureml-sdk
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml
- azureml-dataprep[pandas]

View File

@@ -1,349 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/exploring-previous-runs/auto-ml-exploring-previous-runs.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Exploring Previous Runs**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Explore](#Explore)\n",
"1. [Download](#Download)\n",
"1. [Register](#Register)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we present some examples on navigating previously executed runs. We also show how you can download a fitted model for any previous run.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you will learn how to:\n",
"1. List all experiments in a workspace.\n",
"2. List all AutoML runs in an experiment.\n",
"3. Get details for an AutoML run, including settings, run widget, and all metrics.\n",
"4. Download a fitted pipeline for any iteration."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import json\n",
"\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.train.automl.run import AutoMLRun"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Explore"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### List Experiments"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"experiment_list = Experiment.list(workspace=ws)\n",
"\n",
"summary_df = pd.DataFrame(index = ['No of Runs'])\n",
"for experiment in experiment_list:\n",
" automl_runs = list(experiment.get_runs(type='automl'))\n",
" summary_df[experiment.name] = [len(automl_runs)]\n",
" \n",
"pd.set_option('display.max_colwidth', -1)\n",
"summary_df.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### List runs for an experiment\n",
"Set `experiment_name` to any experiment name from the result of the Experiment.list cell to load the AutoML runs."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"experiment_name = 'automl-local-classification' # Replace this with any project name from previous cell.\n",
"\n",
"proj = ws.experiments[experiment_name]\n",
"summary_df = pd.DataFrame(index = ['Type', 'Status', 'Primary Metric', 'Iterations', 'Compute', 'Name'])\n",
"automl_runs = list(proj.get_runs(type='automl'))\n",
"automl_runs_project = []\n",
"for run in automl_runs:\n",
" properties = run.get_properties()\n",
" tags = run.get_tags()\n",
" amlsettings = json.loads(properties['AMLSettingsJsonString'])\n",
" if 'iterations' in tags:\n",
" iterations = tags['iterations']\n",
" else:\n",
" iterations = properties['num_iterations']\n",
" summary_df[run.id] = [amlsettings['task_type'], run.get_details()['status'], properties['primary_metric'], iterations, properties['target'], amlsettings['name']]\n",
" if run.get_details()['status'] == 'Completed':\n",
" automl_runs_project.append(run.id)\n",
" \n",
"from IPython.display import HTML\n",
"projname_html = HTML(\"<h3>{}</h3>\".format(proj.name))\n",
"\n",
"from IPython.display import display\n",
"display(projname_html)\n",
"display(summary_df.T)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get details for a run\n",
"\n",
"Copy the project name and run id from the previous cell output to find more details on a particular run."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"run_id = automl_runs_project[0] # Replace with your own run_id from above run ids\n",
"assert (run_id in summary_df.keys()), \"Run id not found! Please set run id to a value from above run ids\"\n",
"\n",
"from azureml.widgets import RunDetails\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"ml_run = AutoMLRun(experiment = experiment, run_id = run_id)\n",
"\n",
"summary_df = pd.DataFrame(index = ['Type', 'Status', 'Primary Metric', 'Iterations', 'Compute', 'Name', 'Start Time', 'End Time'])\n",
"properties = ml_run.get_properties()\n",
"tags = ml_run.get_tags()\n",
"status = ml_run.get_details()\n",
"amlsettings = json.loads(properties['AMLSettingsJsonString'])\n",
"if 'iterations' in tags:\n",
" iterations = tags['iterations']\n",
"else:\n",
" iterations = properties['num_iterations']\n",
"start_time = None\n",
"if 'startTimeUtc' in status:\n",
" start_time = status['startTimeUtc']\n",
"end_time = None\n",
"if 'endTimeUtc' in status:\n",
" end_time = status['endTimeUtc']\n",
"summary_df[ml_run.id] = [amlsettings['task_type'], status['status'], properties['primary_metric'], iterations, properties['target'], amlsettings['name'], start_time, end_time]\n",
"display(HTML('<h3>Runtime Details</h3>'))\n",
"display(summary_df)\n",
"\n",
"#settings_df = pd.DataFrame(data = amlsettings, index = [''])\n",
"display(HTML('<h3>AutoML Settings</h3>'))\n",
"display(amlsettings)\n",
"\n",
"display(HTML('<h3>Iterations</h3>'))\n",
"RunDetails(ml_run).show() \n",
"\n",
"all_metrics = ml_run.get_metrics(recursive=True)\n",
"metricslist = {}\n",
"for run_id, metrics in all_metrics.items():\n",
" iteration = int(run_id.split('_')[-1])\n",
" float_metrics = {k: v for k, v in metrics.items() if isinstance(v, float)}\n",
" metricslist[iteration] = float_metrics\n",
"\n",
"rundata = pd.DataFrame(metricslist).sort_index(1)\n",
"display(HTML('<h3>Metrics</h3>'))\n",
"display(rundata)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Download"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Download the Best Model for Any Given Metric"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"metric = 'AUC_weighted' # Replace with a metric name.\n",
"best_run, fitted_model = ml_run.get_output(metric = metric)\n",
"fitted_model"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Download the Model for Any Given Iteration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"iteration = 1 # Replace with an iteration number.\n",
"best_run, fitted_model = ml_run.get_output(iteration = iteration)\n",
"fitted_model"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Register"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Register fitted model for deployment\n",
"If neither `metric` nor `iteration` are specified in the `register_model` call, the iteration with the best primary metric is registered."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"description = 'AutoML Model'\n",
"tags = None\n",
"ml_run.register_model(description = description, tags = tags)\n",
"print(ml_run.model_id) # Use this id to deploy the model as a web service in Azure."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Register the Best Model for Any Given Metric"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"metric = 'AUC_weighted' # Replace with a metric name.\n",
"description = 'AutoML Model'\n",
"tags = None\n",
"ml_run.register_model(description = description, tags = tags, metric = metric)\n",
"print(ml_run.model_id) # Use this id to deploy the model as a web service in Azure."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Register the Model for Any Given Iteration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"iteration = 1 # Replace with an iteration number.\n",
"description = 'AutoML Model'\n",
"tags = None\n",
"ml_run.register_model(description = description, tags = tags, iteration = iteration)\n",
"print(ml_run.model_id) # Use this id to deploy the model as a web service in Azure."
]
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,8 +0,0 @@
name: auto-ml-exploring-previous-runs
dependencies:
- pip:
- azureml-sdk
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml

View File

@@ -0,0 +1,20 @@
DATE,grain,BeerProduction
2017-01-01,grain,9049
2017-02-01,grain,10458
2017-03-01,grain,12489
2017-04-01,grain,11499
2017-05-01,grain,13553
2017-06-01,grain,14740
2017-07-01,grain,11424
2017-08-01,grain,13412
2017-09-01,grain,11917
2017-10-01,grain,12721
2017-11-01,grain,13272
2017-12-01,grain,14278
2018-01-01,grain,9572
2018-02-01,grain,10423
2018-03-01,grain,12667
2018-04-01,grain,11904
2018-05-01,grain,14120
2018-06-01,grain,14565
2018-07-01,grain,12622
1 DATE grain BeerProduction
2 2017-01-01 grain 9049
3 2017-02-01 grain 10458
4 2017-03-01 grain 12489
5 2017-04-01 grain 11499
6 2017-05-01 grain 13553
7 2017-06-01 grain 14740
8 2017-07-01 grain 11424
9 2017-08-01 grain 13412
10 2017-09-01 grain 11917
11 2017-10-01 grain 12721
12 2017-11-01 grain 13272
13 2017-12-01 grain 14278
14 2018-01-01 grain 9572
15 2018-02-01 grain 10423
16 2018-03-01 grain 12667
17 2018-04-01 grain 11904
18 2018-05-01 grain 14120
19 2018-06-01 grain 14565
20 2018-07-01 grain 12622

View File

@@ -0,0 +1,301 @@
DATE,grain,BeerProduction
1992-01-01,grain,3459
1992-02-01,grain,3458
1992-03-01,grain,4002
1992-04-01,grain,4564
1992-05-01,grain,4221
1992-06-01,grain,4529
1992-07-01,grain,4466
1992-08-01,grain,4137
1992-09-01,grain,4126
1992-10-01,grain,4259
1992-11-01,grain,4240
1992-12-01,grain,4936
1993-01-01,grain,3031
1993-02-01,grain,3261
1993-03-01,grain,4160
1993-04-01,grain,4377
1993-05-01,grain,4307
1993-06-01,grain,4696
1993-07-01,grain,4458
1993-08-01,grain,4457
1993-09-01,grain,4364
1993-10-01,grain,4236
1993-11-01,grain,4500
1993-12-01,grain,4974
1994-01-01,grain,3075
1994-02-01,grain,3377
1994-03-01,grain,4443
1994-04-01,grain,4261
1994-05-01,grain,4460
1994-06-01,grain,4985
1994-07-01,grain,4324
1994-08-01,grain,4719
1994-09-01,grain,4374
1994-10-01,grain,4248
1994-11-01,grain,4784
1994-12-01,grain,4971
1995-01-01,grain,3370
1995-02-01,grain,3484
1995-03-01,grain,4269
1995-04-01,grain,3994
1995-05-01,grain,4715
1995-06-01,grain,4974
1995-07-01,grain,4223
1995-08-01,grain,5000
1995-09-01,grain,4235
1995-10-01,grain,4554
1995-11-01,grain,4851
1995-12-01,grain,4826
1996-01-01,grain,3699
1996-02-01,grain,3983
1996-03-01,grain,4262
1996-04-01,grain,4619
1996-05-01,grain,5219
1996-06-01,grain,4836
1996-07-01,grain,4941
1996-08-01,grain,5062
1996-09-01,grain,4365
1996-10-01,grain,5012
1996-11-01,grain,4850
1996-12-01,grain,5097
1997-01-01,grain,3758
1997-02-01,grain,3825
1997-03-01,grain,4454
1997-04-01,grain,4635
1997-05-01,grain,5210
1997-06-01,grain,5057
1997-07-01,grain,5231
1997-08-01,grain,5034
1997-09-01,grain,4970
1997-10-01,grain,5342
1997-11-01,grain,4831
1997-12-01,grain,5965
1998-01-01,grain,3796
1998-02-01,grain,4019
1998-03-01,grain,4898
1998-04-01,grain,5090
1998-05-01,grain,5237
1998-06-01,grain,5447
1998-07-01,grain,5435
1998-08-01,grain,5107
1998-09-01,grain,5515
1998-10-01,grain,5583
1998-11-01,grain,5346
1998-12-01,grain,6286
1999-01-01,grain,4032
1999-02-01,grain,4435
1999-03-01,grain,5479
1999-04-01,grain,5483
1999-05-01,grain,5587
1999-06-01,grain,6176
1999-07-01,grain,5621
1999-08-01,grain,5889
1999-09-01,grain,5828
1999-10-01,grain,5849
1999-11-01,grain,6180
1999-12-01,grain,6771
2000-01-01,grain,4243
2000-02-01,grain,4952
2000-03-01,grain,6008
2000-04-01,grain,5353
2000-05-01,grain,6435
2000-06-01,grain,6673
2000-07-01,grain,5636
2000-08-01,grain,6630
2000-09-01,grain,5887
2000-10-01,grain,6322
2000-11-01,grain,6520
2000-12-01,grain,6678
2001-01-01,grain,5082
2001-02-01,grain,5216
2001-03-01,grain,5893
2001-04-01,grain,5894
2001-05-01,grain,6799
2001-06-01,grain,6667
2001-07-01,grain,6374
2001-08-01,grain,6840
2001-09-01,grain,5575
2001-10-01,grain,6545
2001-11-01,grain,6789
2001-12-01,grain,7180
2002-01-01,grain,5117
2002-02-01,grain,5442
2002-03-01,grain,6337
2002-04-01,grain,6525
2002-05-01,grain,7216
2002-06-01,grain,6761
2002-07-01,grain,6958
2002-08-01,grain,7070
2002-09-01,grain,6148
2002-10-01,grain,6924
2002-11-01,grain,6716
2002-12-01,grain,7975
2003-01-01,grain,5326
2003-02-01,grain,5609
2003-03-01,grain,6414
2003-04-01,grain,6741
2003-05-01,grain,7144
2003-06-01,grain,7133
2003-07-01,grain,7568
2003-08-01,grain,7266
2003-09-01,grain,6634
2003-10-01,grain,7626
2003-11-01,grain,6843
2003-12-01,grain,8540
2004-01-01,grain,5629
2004-02-01,grain,5898
2004-03-01,grain,7045
2004-04-01,grain,7094
2004-05-01,grain,7333
2004-06-01,grain,7918
2004-07-01,grain,7289
2004-08-01,grain,7396
2004-09-01,grain,7259
2004-10-01,grain,7268
2004-11-01,grain,7731
2004-12-01,grain,9058
2005-01-01,grain,5557
2005-02-01,grain,6237
2005-03-01,grain,7723
2005-04-01,grain,7262
2005-05-01,grain,8241
2005-06-01,grain,8757
2005-07-01,grain,7352
2005-08-01,grain,8496
2005-09-01,grain,7741
2005-10-01,grain,7710
2005-11-01,grain,8247
2005-12-01,grain,8902
2006-01-01,grain,6066
2006-02-01,grain,6590
2006-03-01,grain,7923
2006-04-01,grain,7335
2006-05-01,grain,8843
2006-06-01,grain,9327
2006-07-01,grain,7792
2006-08-01,grain,9156
2006-09-01,grain,8037
2006-10-01,grain,8640
2006-11-01,grain,9128
2006-12-01,grain,9545
2007-01-01,grain,6627
2007-02-01,grain,6743
2007-03-01,grain,8195
2007-04-01,grain,7828
2007-05-01,grain,9570
2007-06-01,grain,9484
2007-07-01,grain,8608
2007-08-01,grain,9543
2007-09-01,grain,8123
2007-10-01,grain,9649
2007-11-01,grain,9390
2007-12-01,grain,10065
2008-01-01,grain,7093
2008-02-01,grain,7483
2008-03-01,grain,8365
2008-04-01,grain,8895
2008-05-01,grain,9794
2008-06-01,grain,9977
2008-07-01,grain,9553
2008-08-01,grain,9375
2008-09-01,grain,9225
2008-10-01,grain,9948
2008-11-01,grain,8758
2008-12-01,grain,10839
2009-01-01,grain,7266
2009-02-01,grain,7578
2009-03-01,grain,8688
2009-04-01,grain,9162
2009-05-01,grain,9369
2009-06-01,grain,10167
2009-07-01,grain,9507
2009-08-01,grain,8923
2009-09-01,grain,9272
2009-10-01,grain,9075
2009-11-01,grain,8949
2009-12-01,grain,10843
2010-01-01,grain,6558
2010-02-01,grain,7481
2010-03-01,grain,9475
2010-04-01,grain,9424
2010-05-01,grain,9351
2010-06-01,grain,10552
2010-07-01,grain,9077
2010-08-01,grain,9273
2010-09-01,grain,9420
2010-10-01,grain,9413
2010-11-01,grain,9866
2010-12-01,grain,11455
2011-01-01,grain,6901
2011-02-01,grain,8014
2011-03-01,grain,9832
2011-04-01,grain,9281
2011-05-01,grain,9967
2011-06-01,grain,11344
2011-07-01,grain,9106
2011-08-01,grain,10469
2011-09-01,grain,10085
2011-10-01,grain,9612
2011-11-01,grain,10328
2011-12-01,grain,11483
2012-01-01,grain,7486
2012-02-01,grain,8641
2012-03-01,grain,9709
2012-04-01,grain,9423
2012-05-01,grain,11342
2012-06-01,grain,11274
2012-07-01,grain,9845
2012-08-01,grain,11163
2012-09-01,grain,9532
2012-10-01,grain,10754
2012-11-01,grain,10953
2012-12-01,grain,11922
2013-01-01,grain,8395
2013-02-01,grain,8888
2013-03-01,grain,10110
2013-04-01,grain,10493
2013-05-01,grain,12218
2013-06-01,grain,11385
2013-07-01,grain,11186
2013-08-01,grain,11462
2013-09-01,grain,10494
2013-10-01,grain,11540
2013-11-01,grain,11138
2013-12-01,grain,12709
2014-01-01,grain,8557
2014-02-01,grain,9059
2014-03-01,grain,10055
2014-04-01,grain,10977
2014-05-01,grain,11792
2014-06-01,grain,11904
2014-07-01,grain,10965
2014-08-01,grain,10981
2014-09-01,grain,10828
2014-10-01,grain,11817
2014-11-01,grain,10470
2014-12-01,grain,13310
2015-01-01,grain,8400
2015-02-01,grain,9062
2015-03-01,grain,10722
2015-04-01,grain,11107
2015-05-01,grain,11508
2015-06-01,grain,12904
2015-07-01,grain,11869
2015-08-01,grain,11224
2015-09-01,grain,12022
2015-10-01,grain,11983
2015-11-01,grain,11506
2015-12-01,grain,14183
2016-01-01,grain,8650
2016-02-01,grain,10323
2016-03-01,grain,12110
2016-04-01,grain,11424
2016-05-01,grain,12243
2016-06-01,grain,13686
2016-07-01,grain,10956
2016-08-01,grain,12706
2016-09-01,grain,12279
2016-10-01,grain,11914
2016-11-01,grain,13025
2016-12-01,grain,14431
1 DATE grain BeerProduction
2 1992-01-01 grain 3459
3 1992-02-01 grain 3458
4 1992-03-01 grain 4002
5 1992-04-01 grain 4564
6 1992-05-01 grain 4221
7 1992-06-01 grain 4529
8 1992-07-01 grain 4466
9 1992-08-01 grain 4137
10 1992-09-01 grain 4126
11 1992-10-01 grain 4259
12 1992-11-01 grain 4240
13 1992-12-01 grain 4936
14 1993-01-01 grain 3031
15 1993-02-01 grain 3261
16 1993-03-01 grain 4160
17 1993-04-01 grain 4377
18 1993-05-01 grain 4307
19 1993-06-01 grain 4696
20 1993-07-01 grain 4458
21 1993-08-01 grain 4457
22 1993-09-01 grain 4364
23 1993-10-01 grain 4236
24 1993-11-01 grain 4500
25 1993-12-01 grain 4974
26 1994-01-01 grain 3075
27 1994-02-01 grain 3377
28 1994-03-01 grain 4443
29 1994-04-01 grain 4261
30 1994-05-01 grain 4460
31 1994-06-01 grain 4985
32 1994-07-01 grain 4324
33 1994-08-01 grain 4719
34 1994-09-01 grain 4374
35 1994-10-01 grain 4248
36 1994-11-01 grain 4784
37 1994-12-01 grain 4971
38 1995-01-01 grain 3370
39 1995-02-01 grain 3484
40 1995-03-01 grain 4269
41 1995-04-01 grain 3994
42 1995-05-01 grain 4715
43 1995-06-01 grain 4974
44 1995-07-01 grain 4223
45 1995-08-01 grain 5000
46 1995-09-01 grain 4235
47 1995-10-01 grain 4554
48 1995-11-01 grain 4851
49 1995-12-01 grain 4826
50 1996-01-01 grain 3699
51 1996-02-01 grain 3983
52 1996-03-01 grain 4262
53 1996-04-01 grain 4619
54 1996-05-01 grain 5219
55 1996-06-01 grain 4836
56 1996-07-01 grain 4941
57 1996-08-01 grain 5062
58 1996-09-01 grain 4365
59 1996-10-01 grain 5012
60 1996-11-01 grain 4850
61 1996-12-01 grain 5097
62 1997-01-01 grain 3758
63 1997-02-01 grain 3825
64 1997-03-01 grain 4454
65 1997-04-01 grain 4635
66 1997-05-01 grain 5210
67 1997-06-01 grain 5057
68 1997-07-01 grain 5231
69 1997-08-01 grain 5034
70 1997-09-01 grain 4970
71 1997-10-01 grain 5342
72 1997-11-01 grain 4831
73 1997-12-01 grain 5965
74 1998-01-01 grain 3796
75 1998-02-01 grain 4019
76 1998-03-01 grain 4898
77 1998-04-01 grain 5090
78 1998-05-01 grain 5237
79 1998-06-01 grain 5447
80 1998-07-01 grain 5435
81 1998-08-01 grain 5107
82 1998-09-01 grain 5515
83 1998-10-01 grain 5583
84 1998-11-01 grain 5346
85 1998-12-01 grain 6286
86 1999-01-01 grain 4032
87 1999-02-01 grain 4435
88 1999-03-01 grain 5479
89 1999-04-01 grain 5483
90 1999-05-01 grain 5587
91 1999-06-01 grain 6176
92 1999-07-01 grain 5621
93 1999-08-01 grain 5889
94 1999-09-01 grain 5828
95 1999-10-01 grain 5849
96 1999-11-01 grain 6180
97 1999-12-01 grain 6771
98 2000-01-01 grain 4243
99 2000-02-01 grain 4952
100 2000-03-01 grain 6008
101 2000-04-01 grain 5353
102 2000-05-01 grain 6435
103 2000-06-01 grain 6673
104 2000-07-01 grain 5636
105 2000-08-01 grain 6630
106 2000-09-01 grain 5887
107 2000-10-01 grain 6322
108 2000-11-01 grain 6520
109 2000-12-01 grain 6678
110 2001-01-01 grain 5082
111 2001-02-01 grain 5216
112 2001-03-01 grain 5893
113 2001-04-01 grain 5894
114 2001-05-01 grain 6799
115 2001-06-01 grain 6667
116 2001-07-01 grain 6374
117 2001-08-01 grain 6840
118 2001-09-01 grain 5575
119 2001-10-01 grain 6545
120 2001-11-01 grain 6789
121 2001-12-01 grain 7180
122 2002-01-01 grain 5117
123 2002-02-01 grain 5442
124 2002-03-01 grain 6337
125 2002-04-01 grain 6525
126 2002-05-01 grain 7216
127 2002-06-01 grain 6761
128 2002-07-01 grain 6958
129 2002-08-01 grain 7070
130 2002-09-01 grain 6148
131 2002-10-01 grain 6924
132 2002-11-01 grain 6716
133 2002-12-01 grain 7975
134 2003-01-01 grain 5326
135 2003-02-01 grain 5609
136 2003-03-01 grain 6414
137 2003-04-01 grain 6741
138 2003-05-01 grain 7144
139 2003-06-01 grain 7133
140 2003-07-01 grain 7568
141 2003-08-01 grain 7266
142 2003-09-01 grain 6634
143 2003-10-01 grain 7626
144 2003-11-01 grain 6843
145 2003-12-01 grain 8540
146 2004-01-01 grain 5629
147 2004-02-01 grain 5898
148 2004-03-01 grain 7045
149 2004-04-01 grain 7094
150 2004-05-01 grain 7333
151 2004-06-01 grain 7918
152 2004-07-01 grain 7289
153 2004-08-01 grain 7396
154 2004-09-01 grain 7259
155 2004-10-01 grain 7268
156 2004-11-01 grain 7731
157 2004-12-01 grain 9058
158 2005-01-01 grain 5557
159 2005-02-01 grain 6237
160 2005-03-01 grain 7723
161 2005-04-01 grain 7262
162 2005-05-01 grain 8241
163 2005-06-01 grain 8757
164 2005-07-01 grain 7352
165 2005-08-01 grain 8496
166 2005-09-01 grain 7741
167 2005-10-01 grain 7710
168 2005-11-01 grain 8247
169 2005-12-01 grain 8902
170 2006-01-01 grain 6066
171 2006-02-01 grain 6590
172 2006-03-01 grain 7923
173 2006-04-01 grain 7335
174 2006-05-01 grain 8843
175 2006-06-01 grain 9327
176 2006-07-01 grain 7792
177 2006-08-01 grain 9156
178 2006-09-01 grain 8037
179 2006-10-01 grain 8640
180 2006-11-01 grain 9128
181 2006-12-01 grain 9545
182 2007-01-01 grain 6627
183 2007-02-01 grain 6743
184 2007-03-01 grain 8195
185 2007-04-01 grain 7828
186 2007-05-01 grain 9570
187 2007-06-01 grain 9484
188 2007-07-01 grain 8608
189 2007-08-01 grain 9543
190 2007-09-01 grain 8123
191 2007-10-01 grain 9649
192 2007-11-01 grain 9390
193 2007-12-01 grain 10065
194 2008-01-01 grain 7093
195 2008-02-01 grain 7483
196 2008-03-01 grain 8365
197 2008-04-01 grain 8895
198 2008-05-01 grain 9794
199 2008-06-01 grain 9977
200 2008-07-01 grain 9553
201 2008-08-01 grain 9375
202 2008-09-01 grain 9225
203 2008-10-01 grain 9948
204 2008-11-01 grain 8758
205 2008-12-01 grain 10839
206 2009-01-01 grain 7266
207 2009-02-01 grain 7578
208 2009-03-01 grain 8688
209 2009-04-01 grain 9162
210 2009-05-01 grain 9369
211 2009-06-01 grain 10167
212 2009-07-01 grain 9507
213 2009-08-01 grain 8923
214 2009-09-01 grain 9272
215 2009-10-01 grain 9075
216 2009-11-01 grain 8949
217 2009-12-01 grain 10843
218 2010-01-01 grain 6558
219 2010-02-01 grain 7481
220 2010-03-01 grain 9475
221 2010-04-01 grain 9424
222 2010-05-01 grain 9351
223 2010-06-01 grain 10552
224 2010-07-01 grain 9077
225 2010-08-01 grain 9273
226 2010-09-01 grain 9420
227 2010-10-01 grain 9413
228 2010-11-01 grain 9866
229 2010-12-01 grain 11455
230 2011-01-01 grain 6901
231 2011-02-01 grain 8014
232 2011-03-01 grain 9832
233 2011-04-01 grain 9281
234 2011-05-01 grain 9967
235 2011-06-01 grain 11344
236 2011-07-01 grain 9106
237 2011-08-01 grain 10469
238 2011-09-01 grain 10085
239 2011-10-01 grain 9612
240 2011-11-01 grain 10328
241 2011-12-01 grain 11483
242 2012-01-01 grain 7486
243 2012-02-01 grain 8641
244 2012-03-01 grain 9709
245 2012-04-01 grain 9423
246 2012-05-01 grain 11342
247 2012-06-01 grain 11274
248 2012-07-01 grain 9845
249 2012-08-01 grain 11163
250 2012-09-01 grain 9532
251 2012-10-01 grain 10754
252 2012-11-01 grain 10953
253 2012-12-01 grain 11922
254 2013-01-01 grain 8395
255 2013-02-01 grain 8888
256 2013-03-01 grain 10110
257 2013-04-01 grain 10493
258 2013-05-01 grain 12218
259 2013-06-01 grain 11385
260 2013-07-01 grain 11186
261 2013-08-01 grain 11462
262 2013-09-01 grain 10494
263 2013-10-01 grain 11540
264 2013-11-01 grain 11138
265 2013-12-01 grain 12709
266 2014-01-01 grain 8557
267 2014-02-01 grain 9059
268 2014-03-01 grain 10055
269 2014-04-01 grain 10977
270 2014-05-01 grain 11792
271 2014-06-01 grain 11904
272 2014-07-01 grain 10965
273 2014-08-01 grain 10981
274 2014-09-01 grain 10828
275 2014-10-01 grain 11817
276 2014-11-01 grain 10470
277 2014-12-01 grain 13310
278 2015-01-01 grain 8400
279 2015-02-01 grain 9062
280 2015-03-01 grain 10722
281 2015-04-01 grain 11107
282 2015-05-01 grain 11508
283 2015-06-01 grain 12904
284 2015-07-01 grain 11869
285 2015-08-01 grain 11224
286 2015-09-01 grain 12022
287 2015-10-01 grain 11983
288 2015-11-01 grain 11506
289 2015-12-01 grain 14183
290 2016-01-01 grain 8650
291 2016-02-01 grain 10323
292 2016-03-01 grain 12110
293 2016-04-01 grain 11424
294 2016-05-01 grain 12243
295 2016-06-01 grain 13686
296 2016-07-01 grain 10956
297 2016-08-01 grain 12706
298 2016-09-01 grain 12279
299 2016-10-01 grain 11914
300 2016-11-01 grain 13025
301 2016-12-01 grain 14431

View File

@@ -0,0 +1,665 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/forecasting-beer-remote/auto-ml-forecasting-beer-remote.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"# Automated Machine Learning\n",
"**Beer Production Forecasting**\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Evaluate](#Evaluate)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"## Introduction\n",
"This notebook demonstrates demand forecasting for Beer Production Dataset using AutoML.\n",
"\n",
"AutoML highlights here include using Deep Learning forecasts, Arima, Prophet, Remote Execution and Remote Inferencing, and working with the `forecast` function. Please also look at the additional forecasting notebooks, which document lagging, rolling windows, forecast quantiles, other ways to use the forecast function, and forecaster deployment.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"An Enterprise workspace is required for this notebook. To learn more about creating an Enterprise workspace or upgrading to an Enterprise workspace from the Azure portal, please visit our [Workspace page.](https://docs.microsoft.com/azure/machine-learning/service/concept-workspace#upgrade)\n",
"\n",
"Notebook synopsis:\n",
"1. Creating an Experiment in an existing Workspace\n",
"2. Configuration and remote run of AutoML for a time-series model exploring Regression learners, Arima, Prophet and DNNs\n",
"4. Evaluating the fitted model using a rolling test "
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"## Setup\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"import os\n",
"import azureml.core\n",
"import pandas as pd\n",
"import numpy as np\n",
"import logging\n",
"import warnings\n",
"\n",
"from pandas.tseries.frequencies import to_offset\n",
"\n",
"# Squash warning messages for cleaner output in the notebook\n",
"warnings.showwarning = lambda *args, **kwargs: None\n",
"\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.train.automl import AutoMLConfig\n",
"from matplotlib import pyplot as plt\n",
"from sklearn.metrics import mean_absolute_error, mean_squared_error\n",
"from azureml.train.estimator import Estimator"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"As part of the setup you have already created a <b>Workspace</b>. To run AutoML, you also need to create an <b>Experiment</b>. An Experiment corresponds to a prediction problem you are trying to solve, while a Run corresponds to a specific approach to the problem."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# choose a name for the run history container in the workspace\n",
"experiment_name = 'beer-remote-cpu'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Run History Name'] = experiment_name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"### Using AmlCompute\n",
"You will need to create a [compute target](https://docs.microsoft.com/azure/machine-learning/service/concept-azure-machine-learning-architecture#compute-target) for your AutoML run. In this tutorial, you use `AmlCompute` as your training compute resource."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"from azureml.core.compute import ComputeTarget, AmlCompute\n",
"from azureml.core.compute_target import ComputeTargetException\n",
"\n",
"# Choose a name for your CPU cluster\n",
"cpu_cluster_name = \"cpu-cluster\"\n",
"\n",
"# Verify that cluster does not exist already\n",
"try:\n",
" compute_target = ComputeTarget(workspace=ws, name=cpu_cluster_name)\n",
" print('Found existing cluster, use it.')\n",
"except ComputeTargetException:\n",
" compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2',\n",
" max_nodes=4)\n",
" compute_target = ComputeTarget.create(ws, cpu_cluster_name, compute_config)\n",
"\n",
"compute_target.wait_for_completion(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"## Data\n",
"Read Beer demand data from file, and preview data."
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"Let's set up what we know about the dataset. \n",
"\n",
"**Target column** is what we want to forecast.\n",
"\n",
"**Time column** is the time axis along which to predict.\n",
"\n",
"**Grain** is another word for an individual time series in your dataset. Grains are identified by values of the columns listed `grain_column_names`, for example \"store\" and \"item\" if your data has multiple time series of sales, one series for each combination of store and item sold.\n",
"\n",
"This dataset has only one time series. Please see the [orange juice notebook](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/automated-machine-learning/forecasting-orange-juice-sales) for an example of a multi-time series dataset."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"import pandas as pd\n",
"from pandas import DataFrame\n",
"from pandas import Grouper\n",
"from matplotlib import pyplot\n",
"from pandas import concat\n",
"from matplotlib import pyplot\n",
"from pandas.plotting import register_matplotlib_converters\n",
"register_matplotlib_converters()\n",
"plt.tight_layout()\n",
"plt.figure(figsize=(20, 10))\n",
"\n",
"plt.subplot(2, 1, 1)\n",
"plt.title('Beer Production By Year')\n",
"df = pd.read_csv(\"Beer_no_valid_split_train.csv\", parse_dates=True, index_col= 'DATE').drop(columns='grain')\n",
"test_df = pd.read_csv(\"Beer_no_valid_split_test.csv\", parse_dates=True, index_col= 'DATE').drop(columns='grain')\n",
"pyplot.plot(df)\n",
"\n",
"plt.subplot(2, 1, 2)\n",
"plt.title('Beer Production By Month')\n",
"groups = df.groupby(df.index.month)\n",
"months = concat([DataFrame(x[1].values) for x in groups], axis=1)\n",
"months = DataFrame(months)\n",
"months.columns = range(1,13)\n",
"months.boxplot()\n",
"pyplot.show()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"target_column_name = 'BeerProduction'\n",
"time_column_name = 'DATE'\n",
"grain_column_names = []\n",
"freq = 'M' #Monthly data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Split Training data into Train and Validation set and Upload to Datastores"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"from helper import split_fraction_by_grain\n",
"from helper import split_full_for_forecasting\n",
"\n",
"train, valid = split_full_for_forecasting(df, time_column_name)\n",
"train.to_csv(\"train.csv\")\n",
"valid.to_csv(\"valid.csv\")\n",
"test_df.to_csv(\"test.csv\")\n",
"\n",
"datastore = ws.get_default_datastore()\n",
"datastore.upload_files(files = ['./train.csv'], target_path = 'beer-dataset/tabular/', overwrite = True,show_progress = True)\n",
"datastore.upload_files(files = ['./valid.csv'], target_path = 'beer-dataset/tabular/', overwrite = True,show_progress = True)\n",
"datastore.upload_files(files = ['./test.csv'], target_path = 'beer-dataset/tabular/', overwrite = True,show_progress = True)\n",
"\n",
"from azureml.core import Dataset\n",
"train_dataset = Dataset.Tabular.from_delimited_files(path = [(datastore, 'beer-dataset/tabular/train.csv')])\n",
"valid_dataset = Dataset.Tabular.from_delimited_files(path = [(datastore, 'beer-dataset/tabular/valid.csv')])\n",
"test_dataset = Dataset.Tabular.from_delimited_files(path = [(datastore, 'beer-dataset/tabular/test.csv')])"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"### Setting forecaster maximum horizon \n",
"\n",
"The forecast horizon is the number of periods into the future that the model should predict. Here, we set the horizon to 4 periods (i.e. 4 months). Notice that this is much shorter than the number of days in the test set; we will need to use a rolling test to evaluate the performance on the whole test set. For more discussion of forecast horizons and guiding principles for setting them, please see the [energy demand notebook](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/automated-machine-learning/forecasting-energy-demand). "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"max_horizon = 12"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"## Train\n",
"\n",
"Instantiate a AutoMLConfig object. This defines the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|forecasting|\n",
"|**primary_metric**|This is the metric that you want to optimize.<br> Forecasting supports the following primary metrics <br><i>spearman_correlation</i><br><i>normalized_root_mean_squared_error</i><br><i>r2_score</i><br><i>normalized_mean_absolute_error</i>\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**training_data**|Input dataset, containing both features and label column.|\n",
"|**label_column_name**|The name of the label column.|\n",
"|**enable_dnn**|Enable Forecasting DNNs|\n",
"\n",
"This notebook uses the blacklist_models parameter to exclude some models that take a longer time to train on this dataset. You can choose to remove models from the blacklist_models list but you may need to increase the iteration_timeout_minutes parameter value to get results.\n",
"\n",
"This step requires an Enterprise workspace to gain access to this feature. To learn more about creating an Enterprise workspace or upgrading to an Enterprise workspace from the Azure portal, please visit our [Workspace page.](https://docs.microsoft.com/azure/machine-learning/service/concept-workspace#upgrade)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"automl_settings = {\n",
" 'time_column_name': time_column_name,\n",
" 'max_horizon': max_horizon,\n",
" 'enable_dnn' : True,\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task='forecasting', \n",
" primary_metric='normalized_root_mean_squared_error',\n",
" experiment_timeout_minutes = 60,\n",
" training_data=train_dataset,\n",
" label_column_name=target_column_name,\n",
" validation_data=valid_dataset, \n",
" verbosity=logging.INFO,\n",
" compute_target = compute_target,\n",
" max_concurrent_iterations=4,\n",
" max_cores_per_iteration=-1,\n",
" **automl_settings)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"We will now run the experiment, starting with 10 iterations of model search. The experiment can be continued for more iterations if more accurate results are required. You will see the currently running iterations printing to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"remote_run = experiment.submit(automl_config, show_output= False)\n",
"remote_run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"# If you need to retrieve a run that already started, use the following code\n",
"# from azureml.train.automl.run import AutoMLRun\n",
"# remote_run = AutoMLRun(experiment = experiment, run_id = '<replace with your run id>')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run.wait_for_completion()"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"Displaying the run objects gives you links to the visual tools in the Azure Portal. Go try them!"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"### Retrieve the Best Model for Each Algorithm\n",
"Below we select the best pipeline from our iterations. The get_output method on automl_classifier returns the best run and the fitted model for the last fit invocation. There are overloads on get_output that allow you to retrieve the best run and fitted model for any logged metric or a particular iteration."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"from helper import get_result_df\n",
"summary_df = get_result_df(remote_run)\n",
"summary_df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"from azureml.core.run import Run\n",
"from azureml.widgets import RunDetails\n",
"forecast_model = 'TCNForecaster'\n",
"if not forecast_model in summary_df['run_id']:\n",
" forecast_model = 'ForecastTCN'\n",
" \n",
"best_dnn_run_id = summary_df['run_id'][forecast_model]\n",
"best_dnn_run = Run(experiment, best_dnn_run_id)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"best_dnn_run.parent\n",
"RunDetails(best_dnn_run.parent).show() "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"best_dnn_run\n",
"RunDetails(best_dnn_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"## Evaluate on Test Data"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"source": [
"We now use the best fitted model from the AutoML Run to make forecasts for the test set. \n",
"\n",
"We always score on the original dataset whose schema matches the training set schema."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"from azureml.core import Dataset\n",
"test_dataset = Dataset.Tabular.from_delimited_files(path = [(datastore, 'beer-dataset/tabular/test.csv')])\n",
"# preview the first 3 rows of the dataset\n",
"test_dataset.take(5).to_pandas_dataframe()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"compute_target = ws.compute_targets['cpu-cluster']\n",
"test_experiment = Experiment(ws, experiment_name + \"_test\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"import os\n",
"import shutil\n",
"\n",
"script_folder = os.path.join(os.getcwd(), 'inference')\n",
"project_folder = './inference'\n",
"os.makedirs(project_folder, exist_ok=True)\n",
"\n",
"!copy infer.py inference"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from helper import run_inference\n",
"\n",
"test_run = run_inference(test_experiment, compute_target, script_folder, best_dnn_run, test_dataset, valid_dataset, max_horizon,\n",
" target_column_name, time_column_name, freq)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"RunDetails(test_run).show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from helper import run_multiple_inferences\n",
"\n",
"summary_df = run_multiple_inferences(summary_df, experiment, test_experiment, compute_target, script_folder, test_dataset, \n",
" valid_dataset, max_horizon, target_column_name, time_column_name, freq)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"for run_name, run_summary in summary_df.iterrows():\n",
" print(run_name)\n",
" print(run_summary)\n",
" run_id = run_summary.run_id\n",
" test_run_id = run_summary.test_run_id\n",
" test_run = Run(test_experiment, test_run_id)\n",
" test_run.wait_for_completion()\n",
" test_score = test_run.get_metrics()[run_summary.primary_metric]\n",
" summary_df.loc[summary_df.run_id == run_id, 'Test Score'] = test_score\n",
" print(\"Test Score: \", test_score)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hideCode": false,
"hidePrompt": false
},
"outputs": [],
"source": [
"summary_df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"authors": [
{
"name": "omkarm"
}
],
"hide_code_all_hidden": false,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,9 +1,12 @@
name: auto-ml-classification-with-onnx
name: auto-ml-forecasting-beer-remote
dependencies:
- fbprophet==0.5
- py-xgboost<=0.80
- pip:
- azureml-sdk
- azureml-train-automl
- azureml-train
- azureml-widgets
- matplotlib
- pandas_ml
- onnxruntime
- statsmodels

View File

@@ -0,0 +1,133 @@
import pandas as pd
from azureml.core import Environment
from azureml.core.conda_dependencies import CondaDependencies
from azureml.train.estimator import Estimator
from azureml.core.run import Run
def split_fraction_by_grain(df, fraction, time_column_name,
grain_column_names=None):
if not grain_column_names:
df['tmp_grain_column'] = 'grain'
grain_column_names = ['tmp_grain_column']
"""Group df by grain and split on last n rows for each group."""
df_grouped = (df.sort_values(time_column_name)
.groupby(grain_column_names, group_keys=False))
df_head = df_grouped.apply(lambda dfg: dfg.iloc[:-int(len(dfg) *
fraction)] if fraction > 0 else dfg)
df_tail = df_grouped.apply(lambda dfg: dfg.iloc[-int(len(dfg) *
fraction):] if fraction > 0 else dfg[:0])
if 'tmp_grain_column' in grain_column_names:
for df2 in (df, df_head, df_tail):
df2.drop('tmp_grain_column', axis=1, inplace=True)
grain_column_names.remove('tmp_grain_column')
return df_head, df_tail
def split_full_for_forecasting(df, time_column_name,
grain_column_names=None, test_split=0.2):
index_name = df.index.name
# Assumes that there isn't already a column called tmpindex
df['tmpindex'] = df.index
train_df, test_df = split_fraction_by_grain(
df, test_split, time_column_name, grain_column_names)
train_df = train_df.set_index('tmpindex')
train_df.index.name = index_name
test_df = test_df.set_index('tmpindex')
test_df.index.name = index_name
df.drop('tmpindex', axis=1, inplace=True)
return train_df, test_df
def get_result_df(remote_run):
children = list(remote_run.get_children(recursive=True))
summary_df = pd.DataFrame(index=['run_id', 'run_algorithm',
'primary_metric', 'Score'])
goal_minimize = False
for run in children:
if('run_algorithm' in run.properties and 'score' in run.properties):
summary_df[run.id] = [run.id, run.properties['run_algorithm'],
run.properties['primary_metric'],
float(run.properties['score'])]
if('goal' in run.properties):
goal_minimize = run.properties['goal'].split('_')[-1] == 'min'
summary_df = summary_df.T.sort_values(
'Score',
ascending=goal_minimize).drop_duplicates(['run_algorithm'])
summary_df = summary_df.set_index('run_algorithm')
return summary_df
def run_inference(test_experiment, compute_target, script_folder, train_run,
test_dataset, lookback_dataset, max_horizon,
target_column_name, time_column_name, freq):
train_run.download_file('outputs/model.pkl', 'inference/model.pkl')
train_run.download_file('outputs/conda_env_v_1_0_0.yml',
'inference/condafile.yml')
inference_env = Environment("myenv")
inference_env.docker.enabled = True
inference_env.python.conda_dependencies = CondaDependencies(
conda_dependencies_file_path='inference/condafile.yml')
est = Estimator(source_directory=script_folder,
entry_script='infer.py',
script_params={
'--max_horizon': max_horizon,
'--target_column_name': target_column_name,
'--time_column_name': time_column_name,
'--frequency': freq
},
inputs=[test_dataset.as_named_input('test_data'),
lookback_dataset.as_named_input('lookback_data')],
compute_target=compute_target,
environment_definition=inference_env)
run = test_experiment.submit(
est, tags={
'training_run_id': train_run.id,
'run_algorithm': train_run.properties['run_algorithm'],
'valid_score': train_run.properties['score'],
'primary_metric': train_run.properties['primary_metric']
})
run.log("run_algorithm", run.tags['run_algorithm'])
return run
def run_multiple_inferences(summary_df, train_experiment, test_experiment,
compute_target, script_folder, test_dataset,
lookback_dataset, max_horizon, target_column_name,
time_column_name, freq):
for run_name, run_summary in summary_df.iterrows():
print(run_name)
print(run_summary)
run_id = run_summary.run_id
train_run = Run(train_experiment, run_id)
test_run = run_inference(
test_experiment, compute_target, script_folder, train_run,
test_dataset, lookback_dataset, max_horizon, target_column_name,
time_column_name, freq)
print(test_run)
summary_df.loc[summary_df.run_id == run_id,
'test_run_id'] = test_run.id
return summary_df

View File

@@ -0,0 +1,319 @@
import pandas as pd
import numpy as np
import argparse
from azureml.core import Run
from sklearn.externals import joblib
from sklearn.metrics import mean_absolute_error, mean_squared_error
from azureml.automl.core._vendor.automl.client.core.common import metrics
from automl.client.core.common import constants
from pandas.tseries.frequencies import to_offset
def align_outputs(y_predicted, X_trans, X_test, y_test,
predicted_column_name='predicted',
horizon_colname='horizon_origin'):
"""
Demonstrates how to get the output aligned to the inputs
using pandas indexes. Helps understand what happened if
the output's shape differs from the input shape, or if
the data got re-sorted by time and grain during forecasting.
Typical causes of misalignment are:
* we predicted some periods that were missing in actuals -> drop from eval
* model was asked to predict past max_horizon -> increase max horizon
* data at start of X_test was needed for lags -> provide previous periods
"""
if (horizon_colname in X_trans):
df_fcst = pd.DataFrame({predicted_column_name: y_predicted,
horizon_colname: X_trans[horizon_colname]})
else:
df_fcst = pd.DataFrame({predicted_column_name: y_predicted})
# y and X outputs are aligned by forecast() function contract
df_fcst.index = X_trans.index
# align original X_test to y_test
X_test_full = X_test.copy()
X_test_full[target_column_name] = y_test
# X_test_full's index does not include origin, so reset for merge
df_fcst.reset_index(inplace=True)
X_test_full = X_test_full.reset_index().drop(columns='index')
together = df_fcst.merge(X_test_full, how='right')
# drop rows where prediction or actuals are nan
# happens because of missing actuals
# or at edges of time due to lags/rolling windows
clean = together[together[[target_column_name,
predicted_column_name]].notnull().all(axis=1)]
return(clean)
def do_rolling_forecast_with_lookback(fitted_model, X_test, y_test,
max_horizon, X_lookback, y_lookback,
freq='D'):
"""
Produce forecasts on a rolling origin over the given test set.
Each iteration makes a forecast for the next 'max_horizon' periods
with respect to the current origin, then advances the origin by the
horizon time duration. The prediction context for each forecast is set so
that the forecaster uses the actual target values prior to the current
origin time for constructing lag features.
This function returns a concatenated DataFrame of rolling forecasts.
"""
print("Using lookback of size: ", y_lookback.size)
df_list = []
origin_time = X_test[time_column_name].min()
X = X_lookback.append(X_test)
y = np.concatenate((y_lookback, y_test), axis=0)
while origin_time <= X_test[time_column_name].max():
# Set the horizon time - end date of the forecast
horizon_time = origin_time + max_horizon * to_offset(freq)
# Extract test data from an expanding window up-to the horizon
expand_wind = (X[time_column_name] < horizon_time)
X_test_expand = X[expand_wind]
y_query_expand = np.zeros(len(X_test_expand)).astype(np.float)
y_query_expand.fill(np.NaN)
if origin_time != X[time_column_name].min():
# Set the context by including actuals up-to the origin time
test_context_expand_wind = (X[time_column_name] < origin_time)
context_expand_wind = (
X_test_expand[time_column_name] < origin_time)
y_query_expand[context_expand_wind] = y[test_context_expand_wind]
# Print some debug info
print("Horizon_time:", horizon_time,
" origin_time: ", origin_time,
" max_horizon: ", max_horizon,
" freq: ", freq)
print("expand_wind: ", expand_wind)
print("y_query_expand")
print(y_query_expand)
print("X_test")
print(X)
print("X_test_expand")
print(X_test_expand)
print("Type of X_test_expand: ", type(X_test_expand))
print("Type of y_query_expand: ", type(y_query_expand))
print("y_query_expand")
print(y_query_expand)
# Make a forecast out to the maximum horizon
# y_fcst, X_trans = y_query_expand, X_test_expand
y_fcst, X_trans = fitted_model.forecast(X_test_expand, y_query_expand)
print("y_fcst")
print(y_fcst)
# Align forecast with test set for dates within
# the current rolling window
trans_tindex = X_trans.index.get_level_values(time_column_name)
trans_roll_wind = (trans_tindex >= origin_time) & (
trans_tindex < horizon_time)
test_roll_wind = expand_wind & (X[time_column_name] >= origin_time)
df_list.append(align_outputs(
y_fcst[trans_roll_wind], X_trans[trans_roll_wind],
X[test_roll_wind], y[test_roll_wind]))
# Advance the origin time
origin_time = horizon_time
return pd.concat(df_list, ignore_index=True)
def do_rolling_forecast(fitted_model, X_test, y_test, max_horizon, freq='D'):
"""
Produce forecasts on a rolling origin over the given test set.
Each iteration makes a forecast for the next 'max_horizon' periods
with respect to the current origin, then advances the origin by the
horizon time duration. The prediction context for each forecast is set so
that the forecaster uses the actual target values prior to the current
origin time for constructing lag features.
This function returns a concatenated DataFrame of rolling forecasts.
"""
df_list = []
origin_time = X_test[time_column_name].min()
while origin_time <= X_test[time_column_name].max():
# Set the horizon time - end date of the forecast
horizon_time = origin_time + max_horizon * to_offset(freq)
# Extract test data from an expanding window up-to the horizon
expand_wind = (X_test[time_column_name] < horizon_time)
X_test_expand = X_test[expand_wind]
y_query_expand = np.zeros(len(X_test_expand)).astype(np.float)
y_query_expand.fill(np.NaN)
if origin_time != X_test[time_column_name].min():
# Set the context by including actuals up-to the origin time
test_context_expand_wind = (X_test[time_column_name] < origin_time)
context_expand_wind = (
X_test_expand[time_column_name] < origin_time)
y_query_expand[context_expand_wind] = y_test[
test_context_expand_wind]
# Print some debug info
print("Horizon_time:", horizon_time,
" origin_time: ", origin_time,
" max_horizon: ", max_horizon,
" freq: ", freq)
print("expand_wind: ", expand_wind)
print("y_query_expand")
print(y_query_expand)
print("X_test")
print(X_test)
print("X_test_expand")
print(X_test_expand)
print("Type of X_test_expand: ", type(X_test_expand))
print("Type of y_query_expand: ", type(y_query_expand))
print("y_query_expand")
print(y_query_expand)
# Make a forecast out to the maximum horizon
y_fcst, X_trans = fitted_model.forecast(X_test_expand, y_query_expand)
print("y_fcst")
print(y_fcst)
# Align forecast with test set for dates within the
# current rolling window
trans_tindex = X_trans.index.get_level_values(time_column_name)
trans_roll_wind = (trans_tindex >= origin_time) & (
trans_tindex < horizon_time)
test_roll_wind = expand_wind & (
X_test[time_column_name] >= origin_time)
df_list.append(align_outputs(y_fcst[trans_roll_wind],
X_trans[trans_roll_wind],
X_test[test_roll_wind],
y_test[test_roll_wind]))
# Advance the origin time
origin_time = horizon_time
return pd.concat(df_list, ignore_index=True)
def APE(actual, pred):
"""
Calculate absolute percentage error.
Returns a vector of APE values with same length as actual/pred.
"""
return 100 * np.abs((actual - pred) / actual)
def MAPE(actual, pred):
"""
Calculate mean absolute percentage error.
Remove NA and values where actual is close to zero
"""
not_na = ~(np.isnan(actual) | np.isnan(pred))
not_zero = ~np.isclose(actual, 0.0)
actual_safe = actual[not_na & not_zero]
pred_safe = pred[not_na & not_zero]
return np.mean(APE(actual_safe, pred_safe))
parser = argparse.ArgumentParser()
parser.add_argument(
'--max_horizon', type=int, dest='max_horizon',
default=10, help='Max Horizon for forecasting')
parser.add_argument(
'--target_column_name', type=str, dest='target_column_name',
help='Target Column Name')
parser.add_argument(
'--time_column_name', type=str, dest='time_column_name',
help='Time Column Name')
parser.add_argument(
'--frequency', type=str, dest='freq',
help='Frequency of prediction')
args = parser.parse_args()
max_horizon = args.max_horizon
target_column_name = args.target_column_name
time_column_name = args.time_column_name
freq = args.freq
print('args passed are: ')
print(max_horizon)
print(target_column_name)
print(time_column_name)
print(freq)
run = Run.get_context()
# get input dataset by name
test_dataset = run.input_datasets['test_data']
lookback_dataset = run.input_datasets['lookback_data']
grain_column_names = []
df = test_dataset.to_pandas_dataframe()
print('Read df')
print(df)
X_test_df = test_dataset.drop_columns(columns=[target_column_name])
y_test_df = test_dataset.with_timestamp_columns(
None).keep_columns(columns=[target_column_name])
X_lookback_df = lookback_dataset.drop_columns(columns=[target_column_name])
y_lookback_df = lookback_dataset.with_timestamp_columns(
None).keep_columns(columns=[target_column_name])
fitted_model = joblib.load('model.pkl')
if hasattr(fitted_model, 'get_lookback'):
lookback = fitted_model.get_lookback()
df_all = do_rolling_forecast_with_lookback(
fitted_model,
X_test_df.to_pandas_dataframe(),
y_test_df.to_pandas_dataframe().values.T[0],
max_horizon,
X_lookback_df.to_pandas_dataframe()[-lookback:],
y_lookback_df.to_pandas_dataframe().values.T[0][-lookback:],
freq)
else:
df_all = do_rolling_forecast(
fitted_model,
X_test_df.to_pandas_dataframe(),
y_test_df.to_pandas_dataframe().values.T[0],
max_horizon,
freq)
print(df_all)
print("target values:::")
print(df_all[target_column_name])
print("predicted values:::")
print(df_all['predicted'])
# use automl metrics module
scores = metrics.compute_metrics_regression(
df_all['predicted'],
df_all[target_column_name],
list(constants.Metric.SCALAR_REGRESSION_SET),
None, None, None)
print("scores:")
print(scores)
for key, value in scores.items():
run.log(key, value)
print("Simple forecasting model")
rmse = np.sqrt(mean_squared_error(
df_all[target_column_name], df_all['predicted']))
print("[Test Data] \nRoot Mean squared error: %.2f" % rmse)
mae = mean_absolute_error(df_all[target_column_name], df_all['predicted'])
print('mean_absolute_error score: %.2f' % mae)
print('MAPE: %.2f' % MAPE(df_all[target_column_name], df_all['predicted']))
run.log('rmse', rmse)
run.log('mae', mae)

View File

@@ -26,8 +26,10 @@
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Compute](#Compute)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Featurization](#Featurization)\n",
"1. [Evaluate](#Evaluate)"
]
},
@@ -40,7 +42,7 @@
"\n",
"AutoML highlights here include built-in holiday featurization, accessing engineered feature names, and working with the `forecast` function. Please also look at the additional forecasting notebooks, which document lagging, rolling windows, forecast quantiles, other ways to use the forecast function, and forecaster deployment.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"Make sure you have executed the [configuration](../configuration.ipynb) before running this notebook.\n",
"\n",
"Notebook synopsis:\n",
"1. Creating an Experiment in an existing Workspace\n",
@@ -66,18 +68,10 @@
"import pandas as pd\n",
"import numpy as np\n",
"import logging\n",
"import warnings\n",
"\n",
"from pandas.tseries.frequencies import to_offset\n",
"\n",
"# Squash warning messages for cleaner output in the notebook\n",
"warnings.showwarning = lambda *args, **kwargs: None\n",
"\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core import Workspace, Experiment, Dataset\n",
"from azureml.train.automl import AutoMLConfig\n",
"from matplotlib import pyplot as plt\n",
"from sklearn.metrics import mean_absolute_error, mean_squared_error"
"from datetime import datetime"
]
},
{
@@ -116,8 +110,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"Read bike share demand data from file, and preview data."
"## Compute\n",
"You will 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",
"#### 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 on the default limits and how to request more quota."
]
},
{
@@ -126,8 +123,54 @@
"metadata": {},
"outputs": [],
"source": [
"data = pd.read_csv('bike-no.csv', parse_dates=['date'])\n",
"data.head()"
"from azureml.core.compute import AmlCompute\n",
"from azureml.core.compute import ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"cpu-cluster-6\"\n",
"\n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
" \n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_D2_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 4)\n",
"\n",
" # Create the cluster.\n",
" compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, provisioning_config)\n",
" \n",
"print('Checking cluster status...')\n",
"# Can poll for a minimum number of nodes and for a specific timeout.\n",
"# If no min_node_count is provided, it will use the scale settings for the cluster.\n",
"compute_target.wait_for_completion(show_output = True, min_node_count = None, timeout_in_minutes = 20)\n",
" \n",
"# For a more detailed view of current AmlCompute status, use get_status()."
]
},
{
"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(files = ['./bike-no.csv'], target_path = 'dataset/', overwrite = True,show_progress = True)"
]
},
{
@@ -138,11 +181,7 @@
"\n",
"**Target column** is what we want to forecast.\n",
"\n",
"**Time column** is the time axis along which to predict.\n",
"\n",
"**Grain** is another word for an individual time series in your dataset. Grains are identified by values of the columns listed `grain_column_names`, for example \"store\" and \"item\" if your data has multiple time series of sales, one series for each combination of store and item sold.\n",
"\n",
"This dataset has only one time series. Please see the [orange juice notebook](https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/automated-machine-learning/forecasting-orange-juice-sales) for an example of a multi-time series dataset."
"**Time column** is the time axis along which to predict."
]
},
{
@@ -152,17 +191,7 @@
"outputs": [],
"source": [
"target_column_name = 'cnt'\n",
"time_column_name = 'date'\n",
"grain_column_names = []"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Split the data\n",
"\n",
"The first split we make is into train and test sets. Note we are splitting on time."
"time_column_name = 'date'"
]
},
{
@@ -171,19 +200,66 @@
"metadata": {},
"outputs": [],
"source": [
"train = data[data[time_column_name] < '2012-09-01']\n",
"test = data[data[time_column_name] >= '2012-09-01']\n",
"dataset = Dataset.Tabular.from_delimited_files(path = [(datastore, 'dataset/bike-no.csv')]).with_timestamp_columns(fine_grain_timestamp=time_column_name) \n",
"dataset.take(5).to_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Split the data\n",
"\n",
"X_train = train.copy()\n",
"y_train = X_train.pop(target_column_name).values\n",
"The first split we make is into train and test sets. Note we are splitting on time. Data before 9/1 will be used for training, and data after and including 9/1 will be used for testing."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# select data that occurs before a specified date\n",
"train = dataset.time_before(datetime(2012, 9, 1))\n",
"train.to_pandas_dataframe().tail(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"test = dataset.time_after(datetime(2012, 8, 31))\n",
"test.to_pandas_dataframe().head(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"X_test = test.copy()\n",
"y_test = X_test.pop(target_column_name).values\n",
"Instantiate a AutoMLConfig object. This defines the settings and data used to run the experiment.\n",
"\n",
"print(X_train.shape)\n",
"print(y_train.shape)\n",
"print(X_test.shape)\n",
"print(y_test.shape)"
"|Property|Description|\n",
"|-|-|\n",
"|**task**|forecasting|\n",
"|**primary_metric**|This is the metric that you want to optimize.<br> Forecasting supports the following primary metrics <br><i>spearman_correlation</i><br><i>normalized_root_mean_squared_error</i><br><i>r2_score</i><br><i>normalized_mean_absolute_error</i>\n",
"|**blacklist_models**|Models in blacklist won't be used by AutoML. All supported models can be found at [here](https://docs.microsoft.com/en-us/python/api/azureml-train-automl/azureml.train.automl.constants.supportedmodels.regression?view=azure-ml-py).|\n",
"|**experiment_timeout_minutes**|Experimentation timeout in minutes.|\n",
"|**training_data**|Input dataset, containing both features and label column.|\n",
"|**label_column_name**|The name of the label column.|\n",
"|**compute_target**|The remote compute for training.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**enable_early_stopping**|If early stopping is on, training will stop when the primary metric is no longer improving.|\n",
"|**time_column_name**|Name of the datetime column in the input data|\n",
"|**max_horizon**|Maximum desired forecast horizon in units of time-series frequency|\n",
"|**country_or_region**|The country/region used to generate holiday features. These should be ISO 3166 two-letter country/region codes (i.e. 'US', 'GB').|\n",
"|**target_lags**|The target_lags specifies how far back we will construct the lags of the target variable.|\n",
"|**drop_column_names**|Name(s) of columns to drop prior to modeling|\n",
"\n",
"This notebook uses the blacklist_models parameter to exclude some models that take a longer time to train on this dataset. You can choose to remove models from the blacklist_models list but you may need to increase the experiment_timeout_minutes parameter value to get results."
]
},
{
@@ -208,22 +284,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate a AutoMLConfig object. This defines the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|forecasting|\n",
"|**primary_metric**|This is the metric that you want to optimize.<br> Forecasting supports the following primary metrics <br><i>spearman_correlation</i><br><i>normalized_root_mean_squared_error</i><br><i>r2_score</i><br><i>normalized_mean_absolute_error</i>\n",
"|**iterations**|Number of iterations. In each iteration, Auto ML trains a specific pipeline on the given data|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**training_data**|Input dataset, containing both features and label column.|\n",
"|**label_column_name**|The name of the label column.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**country_or_region**|The country/region used to generate holiday features. These should be ISO 3166 two-letter country/region codes (i.e. 'US', 'GB').|\n",
"\n",
"This notebook uses the blacklist_models parameter to exclude some models that take a longer time to train on this dataset. You can choose to remove models from the blacklist_models list but you may need to increase the iteration_timeout_minutes parameter value to get results."
"### Config AutoML"
]
},
{
@@ -232,33 +293,34 @@
"metadata": {},
"outputs": [],
"source": [
"automl_settings = {\n",
"time_series_settings = {\n",
" 'time_column_name': time_column_name,\n",
" 'max_horizon': max_horizon,\n",
" # knowing the country/region allows Automated ML to bring in holidays\n",
" 'country_or_region': 'US',\n",
" 'target_lags': 1,\n",
" # these columns are a breakdown of the total and therefore a leak\n",
" 'drop_column_names': ['casual', 'registered']\n",
" 'max_horizon': max_horizon, \n",
" 'country_or_region': 'US', # set country_or_region will trigger holiday featurizer\n",
" 'target_lags': 'auto', # use heuristic based lag setting \n",
" 'drop_column_names': ['casual', 'registered'] # these columns are a breakdown of the total and therefore a leak\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task='forecasting', \n",
" primary_metric='normalized_root_mean_squared_error',\n",
" blacklist_models = ['ExtremeRandomTrees'],\n",
" iterations=10,\n",
" iteration_timeout_minutes=5,\n",
" blacklist_models = ['ExtremeRandomTrees'], \n",
" experiment_timeout_minutes=20,\n",
" training_data=train,\n",
" label_column_name=target_column_name,\n",
" n_cross_validations=3, \n",
" compute_target=compute_target,\n",
" enable_early_stopping = True,\n",
" n_cross_validations=3, \n",
" max_concurrent_iterations=4,\n",
" max_cores_per_iteration=-1,\n",
" verbosity=logging.INFO,\n",
" **automl_settings)"
" **time_series_settings)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will now run the experiment, starting with 10 iterations of model search. The experiment can be continued for more iterations if more accurate results are required. You will see the currently running iterations printing to the console."
"We will now run the experiment, you can go to Azure ML portal to view the run details. "
]
},
{
@@ -267,14 +329,8 @@
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Displaying the run objects gives you links to the visual tools in the Azure Portal. Go try them!"
"remote_run = experiment.submit(automl_config, show_output=False)\n",
"remote_run"
]
},
{
@@ -283,7 +339,7 @@
"metadata": {},
"outputs": [],
"source": [
"local_run"
"remote_run.wait_for_completion()"
]
},
{
@@ -291,7 +347,7 @@
"metadata": {},
"source": [
"### Retrieve the Best Model\n",
"Below we select the best pipeline from our iterations. The get_output method on automl_classifier returns the best run and the fitted model for the last fit invocation. There are overloads on get_output that allow you to retrieve the best run and fitted model for any logged metric or a particular iteration."
"Below we select the best model from all the training iterations using get_output method."
]
},
{
@@ -300,7 +356,7 @@
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()\n",
"best_run, fitted_model = remote_run.get_output()\n",
"fitted_model.steps"
]
},
@@ -308,9 +364,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### View the engineered names for featurized data\n",
"## Featurization\n",
"\n",
"You can accees the engineered feature names generated in time-series featurization. Note that a number of named holiday periods are represented. We recommend that you have at least one year of data when using this feature to ensure that all yearly holidays are captured in the training featurization."
"You can access the engineered feature names generated in time-series featurization. Note that a number of named holiday periods are represented. We recommend that you have at least one year of data when using this feature to ensure that all yearly holidays are captured in the training featurization."
]
},
{
@@ -360,9 +416,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We now use the best fitted model from the AutoML Run to make forecasts for the test set. \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",
"We always score on the original dataset whose schema matches the training set schema."
"The scoring will run on a remote compute. In this example, it will reuse the training compute.|"
]
},
{
@@ -371,16 +427,15 @@
"metadata": {},
"outputs": [],
"source": [
"X_test.head()"
"test_experiment = Experiment(ws, experiment_name + \"_test\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now define some functions for aligning output to input and for producing rolling forecasts over the full test set. As previously stated, the forecast horizon of 14 days is shorter than the length of the test set - which is about 120 days. To get predictions over the full test set, we iterate over the test set, making forecasts 14 days at a time and combining the results. We also make sure that each 14-day forecast uses up-to-date actuals - the current context - to construct lag features. \n",
"\n",
"It is a good practice to always align the output explicitly to the input, as the count and order of the rows may have changed during transformations that span multiple rows."
"### Retrieving forecasts from the model\n",
"To run the forecast on the remote compute we will use two helper scripts: forecasting_script and forecasting_helper. These scripts contain the utility methods which will be used by the remote estimator. We copy these scripts to the project folder to upload them to remote compute."
]
},
{
@@ -389,99 +444,21 @@
"metadata": {},
"outputs": [],
"source": [
"def align_outputs(y_predicted, X_trans, X_test, y_test, predicted_column_name='predicted',\n",
" horizon_colname='horizon_origin'):\n",
" \"\"\"\n",
" Demonstrates how to get the output aligned to the inputs\n",
" using pandas indexes. Helps understand what happened if\n",
" the output's shape differs from the input shape, or if\n",
" the data got re-sorted by time and grain during forecasting.\n",
" \n",
" Typical causes of misalignment are:\n",
" * we predicted some periods that were missing in actuals -> drop from eval\n",
" * model was asked to predict past max_horizon -> increase max horizon\n",
" * data at start of X_test was needed for lags -> provide previous periods\n",
" \"\"\"\n",
" df_fcst = pd.DataFrame({predicted_column_name : y_predicted,\n",
" horizon_colname: X_trans[horizon_colname]})\n",
" # y and X outputs are aligned by forecast() function contract\n",
" df_fcst.index = X_trans.index\n",
" \n",
" # align original X_test to y_test \n",
" X_test_full = X_test.copy()\n",
" X_test_full[target_column_name] = y_test\n",
"import os\n",
"\n",
" # X_test_full's index does not include origin, so reset for merge\n",
" df_fcst.reset_index(inplace=True)\n",
" X_test_full = X_test_full.reset_index().drop(columns='index')\n",
" together = df_fcst.merge(X_test_full, how='right')\n",
" \n",
" # drop rows where prediction or actuals are nan \n",
" # happens because of missing actuals \n",
" # or at edges of time due to lags/rolling windows\n",
" clean = together[together[[target_column_name, predicted_column_name]].notnull().all(axis=1)]\n",
" return(clean)\n",
"script_folder = os.path.join(os.getcwd(), 'forecast')\n",
"project_folder = './forecast'\n",
"os.makedirs(project_folder, exist_ok=True)\n",
"\n",
"def do_rolling_forecast(fitted_model, X_test, y_test, max_horizon, freq='D'):\n",
" \"\"\"\n",
" Produce forecasts on a rolling origin over the given test set.\n",
" \n",
" Each iteration makes a forecast for the next 'max_horizon' periods \n",
" with respect to the current origin, then advances the origin by the horizon time duration. \n",
" The prediction context for each forecast is set so that the forecaster uses \n",
" the actual target values prior to the current origin time for constructing lag features.\n",
" \n",
" This function returns a concatenated DataFrame of rolling forecasts.\n",
" \"\"\"\n",
" df_list = []\n",
" origin_time = X_test[time_column_name].min()\n",
" while origin_time <= X_test[time_column_name].max():\n",
" # Set the horizon time - end date of the forecast\n",
" horizon_time = origin_time + max_horizon * to_offset(freq)\n",
" \n",
" # Extract test data from an expanding window up-to the horizon \n",
" expand_wind = (X_test[time_column_name] < horizon_time)\n",
" X_test_expand = X_test[expand_wind]\n",
" y_query_expand = np.zeros(len(X_test_expand)).astype(np.float)\n",
" y_query_expand.fill(np.NaN)\n",
" \n",
" if origin_time != X_test[time_column_name].min():\n",
" # Set the context by including actuals up-to the origin time\n",
" test_context_expand_wind = (X_test[time_column_name] < origin_time)\n",
" context_expand_wind = (X_test_expand[time_column_name] < origin_time)\n",
" y_query_expand[context_expand_wind] = y_test[test_context_expand_wind]\n",
" \n",
" # Make a forecast out to the maximum horizon\n",
" y_fcst, X_trans = fitted_model.forecast(X_test_expand, y_query_expand)\n",
" \n",
" # Align forecast with test set for dates within the current rolling window \n",
" trans_tindex = X_trans.index.get_level_values(time_column_name)\n",
" trans_roll_wind = (trans_tindex >= origin_time) & (trans_tindex < horizon_time)\n",
" test_roll_wind = expand_wind & (X_test[time_column_name] >= origin_time)\n",
" df_list.append(align_outputs(y_fcst[trans_roll_wind], X_trans[trans_roll_wind],\n",
" X_test[test_roll_wind], y_test[test_roll_wind]))\n",
" \n",
" # Advance the origin time\n",
" origin_time = horizon_time\n",
" \n",
" return pd.concat(df_list, ignore_index=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_all = do_rolling_forecast(fitted_model, X_test, y_test, max_horizon)\n",
"df_all"
"!copy forecasting_script.py forecast\n",
"!copy forecasting_helper.py forecast"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now calculate some error metrics for the forecasts and vizualize the predictions vs. the actuals."
"For brevity we have created the function called run_forecast. It submits the test data to the best model and run the estimation on the selected compute target."
]
},
{
@@ -490,23 +467,11 @@
"metadata": {},
"outputs": [],
"source": [
"def APE(actual, pred):\n",
" \"\"\"\n",
" Calculate absolute percentage error.\n",
" Returns a vector of APE values with same length as actual/pred.\n",
" \"\"\"\n",
" return 100*np.abs((actual - pred)/actual)\n",
"from run_forecast import run_rolling_forecast\n",
"\n",
"def MAPE(actual, pred):\n",
" \"\"\"\n",
" Calculate mean absolute percentage error.\n",
" Remove NA and values where actual is close to zero\n",
" \"\"\"\n",
" not_na = ~(np.isnan(actual) | np.isnan(pred))\n",
" not_zero = ~np.isclose(actual, 0.0)\n",
" actual_safe = actual[not_na & not_zero]\n",
" pred_safe = pred[not_na & not_zero]\n",
" return np.mean(APE(actual_safe, pred_safe))"
"remote_run = run_rolling_forecast(test_experiment, compute_target, best_run, test, max_horizon,\n",
" target_column_name, time_column_name)\n",
"remote_run"
]
},
{
@@ -515,17 +480,53 @@
"metadata": {},
"outputs": [],
"source": [
"print(\"Simple forecasting model\")\n",
"rmse = np.sqrt(mean_squared_error(df_all[target_column_name], df_all['predicted']))\n",
"print(\"[Test Data] \\nRoot Mean squared error: %.2f\" % rmse)\n",
"mae = mean_absolute_error(df_all[target_column_name], df_all['predicted'])\n",
"print('mean_absolute_error score: %.2f' % mae)\n",
"print('MAPE: %.2f' % MAPE(df_all[target_column_name], df_all['predicted']))\n",
"remote_run.wait_for_completion(show_output=False)"
]
},
{
"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. You can download it and calculation some error metrics for the forecasts and vizualize the predictions vs. the actuals."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run.download_file('outputs/predictions.csv', 'predictions.csv')\n",
"df_all = pd.read_csv('predictions.csv')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.automl.core._vendor.automl.client.core.common import metrics\n",
"from sklearn.metrics import mean_absolute_error, mean_squared_error\n",
"from matplotlib import pyplot as plt\n",
"from automl.client.core.common import constants\n",
"\n",
"# use automl metrics module\n",
"scores = metrics.compute_metrics_regression(\n",
" df_all['predicted'],\n",
" df_all[target_column_name],\n",
" list(constants.Metric.SCALAR_REGRESSION_SET),\n",
" None, None, None)\n",
"\n",
"print(\"[Test data scores]\\n\")\n",
"for key, value in scores.items(): \n",
" print('{}: {:.3f}'.format(key, value))\n",
" \n",
"# Plot outputs\n",
"%matplotlib inline\n",
"test_pred = plt.scatter(df_all[target_column_name], df_all['predicted'], color='b')\n",
"test_test = plt.scatter(y_test, y_test, color='g')\n",
"test_test = plt.scatter(df_all[target_column_name], df_all[target_column_name], color='g')\n",
"plt.legend((test_pred, test_test), ('prediction', 'truth'), loc='upper left', fontsize=8)\n",
"plt.show()"
]
@@ -543,6 +544,7 @@
"metadata": {},
"outputs": [],
"source": [
"from metrics_helper import MAPE, APE\n",
"df_all.groupby('horizon_origin').apply(\n",
" lambda df: pd.Series({'MAPE': MAPE(df[target_column_name], df['predicted']),\n",
" 'RMSE': np.sqrt(mean_squared_error(df[target_column_name], df['predicted'])),\n",
@@ -582,6 +584,23 @@
"name": "erwright"
}
],
"category": "tutorial",
"compute": [
"remote"
],
"datasets": [
"BikeShare"
],
"deployment": [
"None"
],
"exclude_from_index": false,
"file_extension": ".py",
"framework": [
"Azure ML AutoML"
],
"friendly_name": "Forecasting BikeShare Demand",
"index_order": 1,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -597,8 +616,17 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
"version": "3.6.7"
},
"mimetype": "text/x-python",
"name": "python",
"npconvert_exporter": "python",
"pygments_lexer": "ipython3",
"tags": [
"Forecasting"
],
"task": "forecasting",
"version": 3
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -1,5 +1,7 @@
name: auto-ml-forecasting-bike-share
dependencies:
- fbprophet==0.5
- py-xgboost<=0.80
- pip:
- azureml-sdk
- azureml-train-automl

View File

@@ -0,0 +1,99 @@
import pandas as pd
import numpy as np
from pandas.tseries.frequencies import to_offset
def align_outputs(y_predicted, X_trans, X_test, y_test, target_column_name,
predicted_column_name='predicted',
horizon_colname='horizon_origin'):
"""
Demonstrates how to get the output aligned to the inputs
using pandas indexes. Helps understand what happened if
the output's shape differs from the input shape, or if
the data got re-sorted by time and grain during forecasting.
Typical causes of misalignment are:
* we predicted some periods that were missing in actuals -> drop from eval
* model was asked to predict past max_horizon -> increase max horizon
* data at start of X_test was needed for lags -> provide previous periods
"""
if (horizon_colname in X_trans):
df_fcst = pd.DataFrame({predicted_column_name: y_predicted,
horizon_colname: X_trans[horizon_colname]})
else:
df_fcst = pd.DataFrame({predicted_column_name: y_predicted})
# y and X outputs are aligned by forecast() function contract
df_fcst.index = X_trans.index
# align original X_test to y_test
X_test_full = X_test.copy()
X_test_full[target_column_name] = y_test
# X_test_full's index does not include origin, so reset for merge
df_fcst.reset_index(inplace=True)
X_test_full = X_test_full.reset_index().drop(columns='index')
together = df_fcst.merge(X_test_full, how='right')
# drop rows where prediction or actuals are nan
# happens because of missing actuals
# or at edges of time due to lags/rolling windows
clean = together[together[[target_column_name,
predicted_column_name]].notnull().all(axis=1)]
return(clean)
def do_rolling_forecast(fitted_model, X_test, y_test, target_column_name,
time_column_name, max_horizon, freq='D'):
"""
Produce forecasts on a rolling origin over the given test set.
Each iteration makes a forecast for the next 'max_horizon' periods
with respect to the current origin, then advances the origin by the
horizon time duration. The prediction context for each forecast is set so
that the forecaster uses the actual target values prior to the current
origin time for constructing lag features.
This function returns a concatenated DataFrame of rolling forecasts.
"""
df_list = []
origin_time = X_test[time_column_name].min()
while origin_time <= X_test[time_column_name].max():
# Set the horizon time - end date of the forecast
horizon_time = origin_time + max_horizon * to_offset(freq)
# Extract test data from an expanding window up-to the horizon
expand_wind = (X_test[time_column_name] < horizon_time)
X_test_expand = X_test[expand_wind]
y_query_expand = np.zeros(len(X_test_expand)).astype(np.float)
y_query_expand.fill(np.NaN)
if origin_time != X_test[time_column_name].min():
# Set the context by including actuals up-to the origin time
test_context_expand_wind = (X_test[time_column_name] < origin_time)
context_expand_wind = (
X_test_expand[time_column_name] < origin_time)
y_query_expand[context_expand_wind] = y_test[
test_context_expand_wind]
# Make a forecast out to the maximum horizon
y_fcst, X_trans = fitted_model.forecast(X_test_expand, y_query_expand)
# Align forecast with test set for dates within the
# current rolling window
trans_tindex = X_trans.index.get_level_values(time_column_name)
trans_roll_wind = (trans_tindex >= origin_time) & (
trans_tindex < horizon_time)
test_roll_wind = expand_wind & (
X_test[time_column_name] >= origin_time)
df_list.append(align_outputs(y_fcst[trans_roll_wind],
X_trans[trans_roll_wind],
X_test[test_roll_wind],
y_test[test_roll_wind],
target_column_name))
# Advance the origin time
origin_time = horizon_time
return pd.concat(df_list, ignore_index=True)

View File

@@ -0,0 +1,56 @@
import argparse
import azureml.train.automl
from azureml.automl.core._vendor.automl.client.core.runtime import forecasting_models
from azureml.core import Run
from sklearn.externals import joblib
import forecasting_helper
parser = argparse.ArgumentParser()
parser.add_argument(
'--max_horizon', type=int, dest='max_horizon',
default=10, help='Max Horizon for forecasting')
parser.add_argument(
'--target_column_name', type=str, dest='target_column_name',
help='Target Column Name')
parser.add_argument(
'--time_column_name', type=str, dest='time_column_name',
help='Time Column Name')
parser.add_argument(
'--frequency', type=str, dest='freq',
help='Frequency of prediction')
args = parser.parse_args()
max_horizon = args.max_horizon
target_column_name = args.target_column_name
time_column_name = args.time_column_name
freq = args.freq
run = Run.get_context()
# get input dataset by name
test_dataset = run.input_datasets['test_data']
grain_column_names = []
df = test_dataset.to_pandas_dataframe()
X_test_df = test_dataset.drop_columns(columns=[target_column_name])
y_test_df = test_dataset.with_timestamp_columns(
None).keep_columns(columns=[target_column_name])
fitted_model = joblib.load('model.pkl')
df_all = forecasting_helper.do_rolling_forecast(
fitted_model,
X_test_df.to_pandas_dataframe(),
y_test_df.to_pandas_dataframe().values.T[0],
target_column_name,
time_column_name,
max_horizon,
freq)
file_name = 'outputs/predictions.csv'
export_csv = df_all.to_csv(file_name, header=True)
# Upload the predictions into artifacts
run.upload_file(name=file_name, path_or_stream=file_name)

View File

@@ -0,0 +1,22 @@
import pandas as pd
import numpy as np
def APE(actual, pred):
"""
Calculate absolute percentage error.
Returns a vector of APE values with same length as actual/pred.
"""
return 100 * np.abs((actual - pred) / actual)
def MAPE(actual, pred):
"""
Calculate mean absolute percentage error.
Remove NA and values where actual is close to zero
"""
not_na = ~(np.isnan(actual) | np.isnan(pred))
not_zero = ~np.isclose(actual, 0.0)
actual_safe = actual[not_na & not_zero]
pred_safe = pred[not_na & not_zero]
return np.mean(APE(actual_safe, pred_safe))

View File

@@ -0,0 +1,41 @@
from azureml.core import Environment
from azureml.core.conda_dependencies import CondaDependencies
from azureml.train.estimator import Estimator
from azureml.core.run import Run
def run_rolling_forecast(test_experiment, compute_target, train_run, test_dataset,
max_horizon, target_column_name, time_column_name,
freq='D', inference_folder='./forecast'):
condafile = inference_folder + '/condafile.yml'
train_run.download_file('outputs/model.pkl',
inference_folder + '/model.pkl')
train_run.download_file('outputs/conda_env_v_1_0_0.yml', condafile)
inference_env = Environment("myenv")
inference_env.docker.enabled = True
inference_env.python.conda_dependencies = CondaDependencies(
conda_dependencies_file_path=condafile)
est = Estimator(source_directory=inference_folder,
entry_script='forecasting_script.py',
script_params={
'--max_horizon': max_horizon,
'--target_column_name': target_column_name,
'--time_column_name': time_column_name,
'--frequency': freq
},
inputs=[test_dataset.as_named_input('test_data')],
compute_target=compute_target,
environment_definition=inference_env)
run = test_experiment.submit(est,
tags={
'training_run_id': train_run.id,
'run_algorithm': train_run.properties['run_algorithm'],
'valid_score': train_run.properties['score'],
'primary_metric': train_run.properties['primary_metric']
})
run.log("run_algorithm", run.tags['run_algorithm'])
return run

View File

@@ -21,13 +21,18 @@
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Energy Demand Forecasting**_\n",
"_**Forecasting using the Energy Demand Dataset**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)"
"1. [Data and Forecasting Configurations](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"\n",
"Advanced Forecasting\n",
"1. [Advanced Training](#Advanced Training)\n",
"1. [Advanced Results](#Advanced Results)"
]
},
{
@@ -35,23 +40,25 @@
"metadata": {},
"source": [
"## Introduction\n",
"In this example, we show how AutoML can be used to forecast a single time-series in the energy demand application area. \n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"In this example we use the associated New York City energy demand dataset to showcase how you can use AutoML for a simple forecasting problem and explore the results. The goal is predict the energy demand for the next 48 hours based on historic time-series data.\n",
"\n",
"Notebook synopsis:\n",
"1. Creating an Experiment in an existing Workspace\n",
"2. Configuration and local run of AutoML for a simple time-series model\n",
"3. View engineered features and prediction results\n",
"4. Configuration and local run of AutoML for a time-series model with lag and rolling window features\n",
"5. Estimate feature importance"
"If you are using an Azure Machine Learning [Notebook VM](https://docs.microsoft.com/en-us/azure/machine-learning/service/tutorial-1st-experiment-sdk-setup), you are all set. Otherwise, go through the [configuration notebook](../../../configuration.ipynb) first, if you haven't already, to establish your connection to the AzureML Workspace.\n",
"\n",
"In this notebook you will learn how to:\n",
"1. Creating an Experiment using an existing Workspace\n",
"1. Configure AutoML using 'AutoMLConfig'\n",
"1. Train the model using AmlCompute\n",
"1. Explore the engineered features and results\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"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n"
"## Setup"
]
},
{
@@ -60,27 +67,29 @@
"metadata": {},
"outputs": [],
"source": [
"import azureml.core\n",
"import logging\n",
"\n",
"from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score\n",
"from matplotlib import pyplot as plt\n",
"import pandas as pd\n",
"import numpy as np\n",
"import logging\n",
"import warnings\n",
"import os\n",
"\n",
"# Squash warning messages for cleaner output in the notebook\n",
"warnings.showwarning = lambda *args, **kwargs: None\n",
"\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.experiment import Experiment\n",
"import azureml.core\n",
"from azureml.core import Experiment, Workspace, Dataset\n",
"from azureml.train.automl import AutoMLConfig\n",
"from matplotlib import pyplot as plt\n",
"from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score"
"from datetime import datetime"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As part of the setup you have already created a <b>Workspace</b>. To run AutoML, you also need to create an <b>Experiment</b>. An Experiment corresponds to a prediction problem you are trying to solve, while a Run corresponds to a specific approach to the problem."
"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."
]
},
{
@@ -92,7 +101,10 @@
"ws = Workspace.from_config()\n",
"\n",
"# choose a name for the run history container in the workspace\n",
"experiment_name = 'automl-energydemandforecasting'\n",
"experiment_name = 'automl-forecasting-energydemand'\n",
"\n",
"# # project folder\n",
"# project_folder = './sample_projects/automl-forecasting-energy-demand'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
@@ -112,8 +124,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"We will use energy consumption data from New York City for model training. The data is stored in a tabular format and includes energy demand and basic weather data at an hourly frequency. Pandas CSV reader is used to read the file into memory. Special attention is given to the \"timeStamp\" column in the data since it contains text which should be parsed as datetime-type objects. "
"## Create or Attach existing AmlCompute\n",
"A compute target is required to execute a remote Automated ML run. \n",
"\n",
"[Azure Machine Learning Compute](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-set-up-training-targets#amlcompute) is a managed-compute infrastructure that allows the user to easily create a single or multi-node compute. In this tutorial, you create AmlCompute as your training compute resource.\n",
"\n",
"#### 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."
]
},
{
@@ -122,15 +140,58 @@
"metadata": {},
"outputs": [],
"source": [
"data = pd.read_csv(\"nyc_energy.csv\", parse_dates=['timeStamp'])\n",
"data.head()"
"from azureml.core.compute import AmlCompute\n",
"from azureml.core.compute import ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"aml-compute\"\n",
"\n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
"\n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_DS12_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 6)\n",
"\n",
" # Create the cluster.\\n\",\n",
" compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, provisioning_config)\n",
"\n",
"print('Checking cluster status...')\n",
"# Can poll for a minimum number of nodes and for a specific timeout.\n",
"# If no min_node_count is provided, it will use the scale settings for the cluster.\n",
"compute_target.wait_for_completion(show_output = True, min_node_count = None, timeout_in_minutes = 20)\n",
"\n",
"# For a more detailed view of current AmlCompute status, use get_status()."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We must now define the schema of this dataset. Every time-series must have a time column and a target. The target quantity is what will be eventually forecasted by a trained model. In this case, the target is the \"demand\" column. The other columns, \"temp\" and \"precip,\" are implicitly designated as features."
"# 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."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's set up what we know about the dataset.\n",
"\n",
"<b>Target column</b> is what we want to forecast.<br></br>\n",
"<b>Time column</b> is the time axis along which to predict.\n",
"\n",
"The other columns, \"temp\" and \"precip\", are implicitly designated as features."
]
},
{
@@ -139,23 +200,84 @@
"metadata": {},
"outputs": [],
"source": [
"# Dataset schema\n",
"time_column_name = 'timeStamp'\n",
"target_column_name = 'demand'"
"target_column_name = 'demand'\n",
"time_column_name = 'timeStamp'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dataset = Dataset.Tabular.from_delimited_files(path = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/nyc_energy.csv\").with_timestamp_columns(fine_grain_timestamp=time_column_name) \n",
"dataset.take(5).to_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Forecast Horizon\n",
"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."
]
},
{
"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))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Split the data into train and test sets"
]
},
{
"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."
]
},
{
"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().sort_values(time_column_name).tail(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# split into test based on time\n",
"test = dataset.time_between(datetime(2017, 8, 8, 5), datetime(2017, 8, 10, 5))\n",
"test.to_pandas_dataframe().head(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setting the maximum forecast horizon\n",
"\n",
"In addition to the data schema, we must also specify the forecast horizon. A forecast horizon is a time span into the future (or just beyond the latest date in the training data) where forecasts of the target quantity are needed. Choosing a forecast horizon is application specific, but a rule-of-thumb is that **the horizon should be the time-frame where you need actionable decisions based on the forecast.** The horizon usually has a strong relationship with the frequency of the time-series data, that is, the sampling interval of the target quantity and the features. For instance, the NYC energy demand data has an hourly frequency. A decision that requires a demand forecast to the hour is unlikely to be made weeks or months in advance, particularly if we expect weather to be a strong determinant of demand. We may have fairly accurate meteorological forecasts of the hourly temperature and precipitation on a the time-scale of a day or two, however.\n",
"The forecast horizon is the number of periods into the future that the model should predict. It is generally recommend that users set forecast horizons to less than 100 time periods (i.e. less than 100 hours in the NYC energy example). Furthermore, **AutoML's memory use and computation time increase in proportion to the length of the horizon**, so consider carefully how this value is set. If a long horizon forecast really is necessary, consider aggregating the series to a coarser time scale. \n",
"\n",
"Given the above discussion, we generally recommend that users set forecast horizons to less than 100 time periods (i.e. less than 100 hours in the NYC energy example). Furthermore, **AutoML's memory use and computation time increase in proportion to the length of the horizon**, so the user should consider carefully how they set this value. If a long horizon forecast really is necessary, it may be good practice to aggregate the series to a coarser time scale. \n",
"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",
"\n",
"Forecast horizons in AutoML are given as integer multiples of the time-series frequency. In this example, we set the horizon to 48 hours."
"In this example, we set the horizon to 48 hours."
]
},
{
@@ -167,50 +289,34 @@
"max_horizon = 48"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Split the data into train and test sets\n",
"We now split the data into a train and a test set so that we may evaluate model performance. We note that the tail of the dataset contains a large number of NA values in the target column, so we designate the test set as the 48 hour window ending on the latest date of known energy demand. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Find time point to split on\n",
"latest_known_time = data[~pd.isnull(data[target_column_name])][time_column_name].max()\n",
"split_time = latest_known_time - pd.Timedelta(hours=max_horizon)\n",
"\n",
"# Split into train/test sets\n",
"X_train = data[data[time_column_name] <= split_time]\n",
"X_test = data[(data[time_column_name] > split_time) & (data[time_column_name] <= latest_known_time)]\n",
"\n",
"# Move the target values into their own arrays \n",
"y_train = X_train.pop(target_column_name).values\n",
"y_test = X_test.pop(target_column_name).values"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"We now instantiate an AutoMLConfig object. This config defines the settings and data used to run the experiment. For forecasting tasks, we must provide extra configuration related to the time-series data schema and forecasting context. Here, only the name of the time column and the maximum forecast horizon are needed. Other settings are described below:\n",
"Instantiate an AutoMLConfig object. This config defines the settings and data used to run the experiment. We can provide extra configurations within 'automl_settings', for this forecasting task we add the name of the time column and the maximum forecast horizon.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|forecasting|\n",
"|**primary_metric**|This is the metric that you want to optimize.<br> Forecasting supports the following primary metrics <br><i>spearman_correlation</i><br><i>normalized_root_mean_squared_error</i><br><i>r2_score</i><br><i>normalized_mean_absolute_error</i>\n",
"|**iterations**|Number of iterations. In each iteration, Auto ML trains a specific pipeline on the given data|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**X**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**y**|(sparse) array-like, shape = [n_samples, ], targets values.|\n",
"|**n_cross_validations**|Number of cross validation splits. Rolling Origin Validation is used to split time-series in a temporally consistent way.|"
"|**primary_metric**|This is the metric that you want to optimize.<br> Forecasting supports the following primary metrics <br><i>spearman_correlation</i><br><i>normalized_root_mean_squared_error</i><br><i>r2_score</i><br><i>normalized_mean_absolute_error</i>|\n",
"|**blacklist_models**|Models in blacklist won't be used by AutoML. All supported models can be found at [here](https://docs.microsoft.com/en-us/python/api/azureml-train-automl/azureml.train.automl.constants.supportedmodels.regression?view=azure-ml-py).|\n",
"|**experiment_timeout_minutes**|Maximum amount of time in minutes that the experiment take before it terminates.|\n",
"|**training_data**|The training data to be used within the experiment.|\n",
"|**label_column_name**|The name of the label column.|\n",
"|**compute_target**|The remote compute for training.|\n",
"|**n_cross_validations**|Number of cross validation splits. Rolling Origin Validation is used to split time-series in a temporally consistent way.|\n",
"|**enable_early_stopping**|Flag to enble early termination if the score is not improving in the short term.|\n",
"|**time_column_name**|The name of your time column.|\n",
"|**max_horizon**|The number of periods out you would like to predict past your training data. Periods are inferred from your data.|\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook uses the blacklist_models parameter to exclude some models that take a longer time to train on this dataset. You can choose to remove models from the blacklist_models list but you may need to increase the experiment_timeout_minutes parameter value to get results."
]
},
{
@@ -219,31 +325,30 @@
"metadata": {},
"outputs": [],
"source": [
"time_series_settings = {\n",
"automl_settings = {\n",
" 'time_column_name': time_column_name,\n",
" 'max_horizon': max_horizon\n",
" 'max_horizon': max_horizon,\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task='forecasting',\n",
" debug_log='automl_nyc_energy_errors.log',\n",
"automl_config = AutoMLConfig(task='forecasting', \n",
" primary_metric='normalized_root_mean_squared_error',\n",
" blacklist_models = ['ExtremeRandomTrees', 'AutoArima'],\n",
" iterations=10,\n",
" iteration_timeout_minutes=5,\n",
" X=X_train,\n",
" y=y_train,\n",
" n_cross_validations=3,\n",
" verbosity = logging.INFO,\n",
" **time_series_settings)"
" blacklist_models = ['ExtremeRandomTrees', 'AutoArima', 'Prophet'], \n",
" experiment_timeout_minutes=20,\n",
" training_data=train,\n",
" label_column_name=target_column_name,\n",
" compute_target=compute_target,\n",
" enable_early_stopping = True,\n",
" n_cross_validations=3, \n",
" verbosity=logging.INFO,\n",
" **automl_settings)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Submitting the configuration will start a new run in this experiment. For local runs, the execution is synchronous. Depending on the data and number of iterations, this can run for a while. Parameters controlling concurrency may speed up the process, depending on your hardware.\n",
"\n",
"You will see the currently running iterations printing to the console."
"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."
]
},
{
@@ -252,7 +357,7 @@
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output=True)"
"remote_run = experiment.submit(automl_config, show_output=False)"
]
},
{
@@ -261,15 +366,24 @@
"metadata": {},
"outputs": [],
"source": [
"local_run"
"remote_run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run.wait_for_completion()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model\n",
"Below we select the best pipeline from our iterations. The get_output method on automl_classifier returns the best run and the fitted model for the last fit invocation. There are overloads on get_output that allow you to retrieve the best run and fitted model for any logged metric or a particular iteration."
"## Retrieve the Best Model\n",
"Below we select the best model from all the training iterations using get_output method."
]
},
{
@@ -278,7 +392,7 @@
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()\n",
"best_run, fitted_model = remote_run.get_output()\n",
"fitted_model.steps"
]
},
@@ -286,8 +400,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### View the engineered names for featurized data\n",
"Below we display the engineered feature names generated for the featurized data using the time-series featurization."
"## Featurization\n",
"You can access the engineered feature names generated in time-series featurization."
]
},
{
@@ -303,13 +417,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Test the Best Fitted Model\n",
"### 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",
"\n",
"For forecasting, we will use the `forecast` function instead of the `predict` function. There are two reasons for this.\n",
"\n",
"We need to pass the recent values of the target variable `y`, whereas the scikit-compatible `predict` function only takes the non-target variables `X`. In our case, the test data immediately follows the training data, and we fill the `y` variable with `NaN`. The `NaN` serves as a question mark for the forecaster to fill with the actuals. Using the forecast function will produce forecasts using the shortest possible forecast horizon. The last time at which a definite (non-NaN) value is seen is the _forecast origin_ - the last time when the value of the target is known. \n",
"\n",
"Using the `predict` method would result in getting predictions for EVERY horizon the forecaster can predict at. This is useful when training and evaluating the performance of the forecaster at various horizons, but the level of detail is excessive for normal use."
"+ Raw feature name\n",
"+ Number of engineered features formed out of this raw feature\n",
"+ Type detected\n",
"+ If feature was dropped\n",
"+ List of feature transformations for the raw feature"
]
},
{
@@ -318,15 +433,68 @@
"metadata": {},
"outputs": [],
"source": [
"# Replace ALL values in y_pred by NaN. \n",
"# The forecast origin will be at the beginning of the first forecast period\n",
"# (which is the same time as the end of the last training period).\n",
"# Get the featurization summary as a list of JSON\n",
"featurization_summary = fitted_model.named_steps['timeseriestransformer'].get_featurization_summary()\n",
"# View the featurization summary as a pandas dataframe\n",
"pd.DataFrame.from_records(featurization_summary)"
]
},
{
"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. First, we remove the target values from the test set:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"X_test = test.to_pandas_dataframe()\n",
"y_test = X_test.pop(target_column_name).values"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Forecast Function\n",
"For forecasting, we will use the forecast function instead of the predict function. There are two reasons for this.\n",
"\n",
"We need to pass the recent values of the target variable y, whereas the scikit-compatible predict function only takes the non-target variables 'test'. In our case, the test data immediately follows the training data, and we fill the target variable with NaN. The NaN serves as a question mark for the forecaster to fill with the actuals. Using the forecast function will produce forecasts using the shortest possible forecast horizon. The last time at which a definite (non-NaN) value is seen is the forecast origin - the last time when the value of the target is known.\n",
"\n",
"Using the predict method would result in getting predictions for EVERY horizon the forecaster can predict at. This is useful when training and evaluating the performance of the forecaster at various horizons, but the level of detail is excessive for normal use."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Replace ALL values in y by NaN.\n",
"# The forecast origin will be at the beginning of the first forecast period.\n",
"# (Which is the same time as the end of the last training period.)\n",
"y_query = y_test.copy().astype(np.float)\n",
"y_query.fill(np.nan)\n",
"# The featurized data, aligned to y, will also be returned.\n",
"# This contains the assumptions that were made in the forecast\n",
"# and helps align the forecast to the original data\n",
"y_fcst, X_trans = fitted_model.forecast(X_test, y_query)"
"y_predictions, X_trans = fitted_model.forecast(X_test, y_query)"
]
},
{
"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).\n",
"\n",
"It is a good practice to always align the output explicitly to the input, as the count and order of the rows may have changed during transformations that span multiple rows."
]
},
{
@@ -335,40 +503,38 @@
"metadata": {},
"outputs": [],
"source": [
"# limit the evaluation to data where y_test has actuals\n",
"def align_outputs(y_predicted, X_trans, X_test, y_test, predicted_column_name = 'predicted'):\n",
" \"\"\"\n",
" Demonstrates how to get the output aligned to the inputs\n",
" using pandas indexes. Helps understand what happened if\n",
" the output's shape differs from the input shape, or if\n",
" the data got re-sorted by time and grain during forecasting.\n",
" \n",
" Typical causes of misalignment are:\n",
" * we predicted some periods that were missing in actuals -> drop from eval\n",
" * model was asked to predict past max_horizon -> increase max horizon\n",
" * data at start of X_test was needed for lags -> provide previous periods\n",
" \"\"\"\n",
" df_fcst = pd.DataFrame({predicted_column_name : y_predicted})\n",
" # y and X outputs are aligned by forecast() function contract\n",
" df_fcst.index = X_trans.index\n",
" \n",
" # align original X_test to y_test \n",
" X_test_full = X_test.copy()\n",
" X_test_full[target_column_name] = y_test\n",
"from forecasting_helper import align_outputs\n",
"\n",
" # X_test_full's does not include origin, so reset for merge\n",
" df_fcst.reset_index(inplace=True)\n",
" X_test_full = X_test_full.reset_index().drop(columns='index')\n",
" together = df_fcst.merge(X_test_full, how='right')\n",
" \n",
" # drop rows where prediction or actuals are nan \n",
" # happens because of missing actuals \n",
" # or at edges of time due to lags/rolling windows\n",
" clean = together[together[[target_column_name, predicted_column_name]].notnull().all(axis=1)]\n",
" return(clean)\n",
"df_all = align_outputs(y_predictions, X_trans, X_test, y_test, target_column_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.automl.core._vendor.automl.client.core.common import metrics\n",
"from matplotlib import pyplot as plt\n",
"from automl.client.core.common import constants\n",
"\n",
"df_all = align_outputs(y_fcst, X_trans, X_test, y_test)\n",
"df_all.head()"
"# use automl metrics module\n",
"scores = metrics.compute_metrics_regression(\n",
" df_all['predicted'],\n",
" df_all[target_column_name],\n",
" list(constants.Metric.SCALAR_REGRESSION_SET),\n",
" None, None, None)\n",
"\n",
"print(\"[Test data scores]\\n\")\n",
"for key, value in scores.items(): \n",
" print('{}: {:.3f}'.format(key, value))\n",
" \n",
"# Plot outputs\n",
"%matplotlib inline\n",
"test_pred = plt.scatter(df_all[target_column_name], df_all['predicted'], color='b')\n",
"test_test = plt.scatter(df_all[target_column_name], df_all[target_column_name], color='g')\n",
"plt.legend((test_pred, test_test), ('prediction', 'truth'), loc='upper left', fontsize=8)\n",
"plt.show()"
]
},
{
@@ -391,74 +557,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Calculate accuracy metrics\n",
"Finally, we calculate some accuracy metrics for the forecast and plot the predictions vs. the actuals over the time range in the test set."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def MAPE(actual, pred):\n",
" \"\"\"\n",
" Calculate mean absolute percentage error.\n",
" Remove NA and values where actual is close to zero\n",
" \"\"\"\n",
" not_na = ~(np.isnan(actual) | np.isnan(pred))\n",
" not_zero = ~np.isclose(actual, 0.0)\n",
" actual_safe = actual[not_na & not_zero]\n",
" pred_safe = pred[not_na & not_zero]\n",
" APE = 100*np.abs((actual_safe - pred_safe)/actual_safe)\n",
" return np.mean(APE)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"Simple forecasting model\")\n",
"rmse = np.sqrt(mean_squared_error(df_all[target_column_name], df_all['predicted']))\n",
"print(\"[Test Data] \\nRoot Mean squared error: %.2f\" % rmse)\n",
"mae = mean_absolute_error(df_all[target_column_name], df_all['predicted'])\n",
"print('mean_absolute_error score: %.2f' % mae)\n",
"print('MAPE: %.2f' % MAPE(df_all[target_column_name], df_all['predicted']))\n",
"\n",
"# Plot outputs\n",
"%matplotlib inline\n",
"pred, = plt.plot(df_all[time_column_name], df_all['predicted'], color='b')\n",
"actual, = plt.plot(df_all[time_column_name], df_all[target_column_name], color='g')\n",
"plt.xticks(fontsize=8)\n",
"plt.legend((pred, actual), ('prediction', 'truth'), loc='upper left', fontsize=8)\n",
"plt.title('Prediction vs. Actual Time-Series')\n",
"\n",
"plt.show()"
"## 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, grain 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."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The distribution looks a little heavy tailed: we underestimate the excursions of the extremes. A normal-quantile transform of the target might help, but let's first try using some past data with the lags and rolling window transforms.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Using lags and rolling window features"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We did not use lags in the previous model specification. In effect, the prediction was the result of a simple regression on date, grain 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.\n",
"\n",
"Now that we configured target lags, that is the previous values of the target variables, and the prediction is no longer horizon-less. We therefore must still specify the `max_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",
"### 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 `max_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 blacklist_models parameter to exclude some models that take a longer time to train on this dataset. You can choose to remove models from the blacklist_models list but you may need to increase the iteration_timeout_minutes parameter value to get results."
]
@@ -469,31 +577,31 @@
"metadata": {},
"outputs": [],
"source": [
"time_series_settings_with_lags = {\n",
"automl_advanced_settings = {\n",
" 'time_column_name': time_column_name,\n",
" 'max_horizon': max_horizon,\n",
" 'target_lags': 12,\n",
" 'target_rolling_window_size': 4\n",
" 'target_rolling_window_size': 4,\n",
"}\n",
"\n",
"automl_config_lags = AutoMLConfig(task='forecasting',\n",
" debug_log='automl_nyc_energy_errors.log',\n",
" primary_metric='normalized_root_mean_squared_error',\n",
" blacklist_models=['ElasticNet','ExtremeRandomTrees','GradientBoosting','XGBoostRegressor'],\n",
" iterations=10,\n",
" iteration_timeout_minutes=10,\n",
" X=X_train,\n",
" y=y_train,\n",
" n_cross_validations=3,\n",
" verbosity=logging.INFO,\n",
" **time_series_settings_with_lags)"
"automl_config = AutoMLConfig(task='forecasting', \n",
" primary_metric='normalized_root_mean_squared_error',\n",
" blacklist_models = ['ElasticNet','ExtremeRandomTrees','GradientBoosting','XGBoostRegressor','ExtremeRandomTrees', 'AutoArima', 'Prophet'], #These models are blacklisted for tutorial purposes, remove this for real use cases. \n",
" experiment_timeout_minutes=20,\n",
" training_data=train,\n",
" label_column_name=target_column_name,\n",
" compute_target=compute_target,\n",
" enable_early_stopping = True,\n",
" n_cross_validations=3, \n",
" verbosity=logging.INFO,\n",
" **automl_advanced_settings)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now start a new local 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."
"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."
]
},
{
@@ -502,7 +610,7 @@
"metadata": {},
"outputs": [],
"source": [
"local_run_lags = experiment.submit(automl_config_lags, show_output=True)"
"advanced_remote_run = experiment.submit(automl_config, show_output=False)"
]
},
{
@@ -511,10 +619,14 @@
"metadata": {},
"outputs": [],
"source": [
"best_run_lags, fitted_model_lags = local_run_lags.get_output()\n",
"y_fcst_lags, X_trans_lags = fitted_model_lags.forecast(X_test, y_query)\n",
"df_lags = align_outputs(y_fcst_lags, X_trans_lags, X_test, y_test)\n",
"df_lags.head()"
"advanced_remote_run.wait_for_completion()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model"
]
},
{
@@ -523,7 +635,15 @@
"metadata": {},
"outputs": [],
"source": [
"X_trans_lags"
"best_run_lags, fitted_model_lags = advanced_remote_run.get_output()"
]
},
{
"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, grain 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."
]
},
{
@@ -532,127 +652,56 @@
"metadata": {},
"outputs": [],
"source": [
"print(\"Forecasting model with lags\")\n",
"rmse = np.sqrt(mean_squared_error(df_lags[target_column_name], df_lags['predicted']))\n",
"print(\"[Test Data] \\nRoot Mean squared error: %.2f\" % rmse)\n",
"mae = mean_absolute_error(df_lags[target_column_name], df_lags['predicted'])\n",
"print('mean_absolute_error score: %.2f' % mae)\n",
"print('MAPE: %.2f' % MAPE(df_lags[target_column_name], df_lags['predicted']))\n",
"# Replace ALL values in y by NaN.\n",
"# The forecast origin will be at the beginning of the first forecast period.\n",
"# (Which is the same time as the end of the last training period.)\n",
"y_query = y_test.copy().astype(np.float)\n",
"y_query.fill(np.nan)\n",
"# The featurized data, aligned to y, will also be returned.\n",
"# This contains the assumptions that were made in the forecast\n",
"# and helps align the forecast to the original data\n",
"y_predictions, X_trans = fitted_model_lags.forecast(X_test, y_query)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from forecasting_helper import align_outputs\n",
"\n",
"df_all = align_outputs(y_predictions, X_trans, X_test, y_test, target_column_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.automl.core._vendor.automl.client.core.common import metrics\n",
"from matplotlib import pyplot as plt\n",
"from automl.client.core.common import constants\n",
"\n",
"# use automl metrics module\n",
"scores = metrics.compute_metrics_regression(\n",
" df_all['predicted'],\n",
" df_all[target_column_name],\n",
" list(constants.Metric.SCALAR_REGRESSION_SET),\n",
" None, None, None)\n",
"\n",
"print(\"[Test data scores]\\n\")\n",
"for key, value in scores.items(): \n",
" print('{}: {:.3f}'.format(key, value))\n",
" \n",
"# Plot outputs\n",
"%matplotlib inline\n",
"pred, = plt.plot(df_lags[time_column_name], df_lags['predicted'], color='b')\n",
"actual, = plt.plot(df_lags[time_column_name], df_lags[target_column_name], color='g')\n",
"plt.xticks(fontsize=8)\n",
"plt.legend((pred, actual), ('prediction', 'truth'), loc='upper left', fontsize=8)\n",
"test_pred = plt.scatter(df_all[target_column_name], df_all['predicted'], color='b')\n",
"test_test = plt.scatter(df_all[target_column_name], df_all[target_column_name], color='g')\n",
"plt.legend((test_pred, test_test), ('prediction', 'truth'), loc='upper left', fontsize=8)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### What features matter for the forecast?\n",
"The following steps will allow you to compute and visualize engineered feature importance based on your test data for forecasting. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Setup the model explanations for AutoML models\n",
"The *fitted_model* can generate the following which will be used for getting the engineered and raw feature explanations using *automl_setup_model_explanations*:-\n",
"1. Featurized data from train samples/test samples \n",
"2. Gather engineered and raw feature name lists\n",
"3. Find the classes in your labeled column in classification scenarios\n",
"\n",
"The *automl_explainer_setup_obj* contains all the structures from above list. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.train.automl.automl_explain_utilities import AutoMLExplainerSetupClass, automl_setup_model_explanations\n",
"automl_explainer_setup_obj = automl_setup_model_explanations(fitted_model, X=X_train.copy(), \n",
" X_test=X_test.copy(), y=y_train, \n",
" task='forecasting')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Initialize the Mimic Explainer for feature importance\n",
"For explaining the AutoML models, use the *MimicWrapper* from *azureml.explain.model* package. The *MimicWrapper* can be initialized with fields in *automl_explainer_setup_obj*, your workspace and a LightGBM model which acts as a surrogate model to explain the AutoML model (*fitted_model* here). The *MimicWrapper* also takes the *best_run* object where the raw and engineered explanations will be uploaded."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.explain.model.mimic.models.lightgbm_model import LGBMExplainableModel\n",
"from azureml.explain.model.mimic_wrapper import MimicWrapper\n",
"explainer = MimicWrapper(ws, automl_explainer_setup_obj.automl_estimator, LGBMExplainableModel, \n",
" init_dataset=automl_explainer_setup_obj.X_transform, run=best_run,\n",
" features=automl_explainer_setup_obj.engineered_feature_names, \n",
" feature_maps=[automl_explainer_setup_obj.feature_map])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Use Mimic Explainer for computing and visualizing engineered feature importance\n",
"The *explain()* method in *MimicWrapper* can be called with the transformed test samples to get the feature importance for the generated engineered features. You can also use *ExplanationDashboard* to view the dash board visualization of the feature importance values of the generated engineered features by AutoML featurizers."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"engineered_explanations = explainer.explain(['local', 'global'], eval_dataset=automl_explainer_setup_obj.X_test_transform)\n",
"print(engineered_explanations.get_feature_importance_dict())\n",
"from azureml.contrib.interpret.visualize import ExplanationDashboard\n",
"ExplanationDashboard(engineered_explanations, automl_explainer_setup_obj.automl_estimator, automl_explainer_setup_obj.X_test_transform)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Use Mimic Explainer for computing and visualizing raw feature importance\n",
"The *explain()* method in *MimicWrapper* can be again called with the transformed test samples and setting *get_raw* to *True* to get the feature importance for the raw features. You can also use *ExplanationDashboard* to view the dash board visualization of the feature importance values of the raw features."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"raw_explanations = explainer.explain(['local', 'global'], get_raw=True, \n",
" raw_feature_names=automl_explainer_setup_obj.raw_feature_names,\n",
" eval_dataset=automl_explainer_setup_obj.X_test_transform)\n",
"print(raw_explanations.get_feature_importance_dict())\n",
"from azureml.contrib.interpret.visualize import ExplanationDashboard\n",
"ExplanationDashboard(raw_explanations, automl_explainer_setup_obj.automl_pipeline, automl_explainer_setup_obj.X_test_raw)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Please go to the Azure Portal's best run to see the top features chart.\n",
"\n",
"The informative features make all sorts of intuitive sense. Temperature is a strong driver of heating and cooling demand in NYC. Apart from that, the daily life cycle, expressed by `hour`, and the weekly cycle, expressed by `wday` drives people's energy use habits."
]
}
],
"metadata": {
@@ -661,6 +710,10 @@
"name": "erwright"
}
],
"categories": [
"how-to-use-azureml",
"automated-machine-learning"
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -677,7 +730,14 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
},
"star_tag": [
"featured"
],
"tags": [
""
],
"task": "Forecasting"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -0,0 +1,44 @@
import pandas as pd
import numpy as np
from pandas.tseries.frequencies import to_offset
def align_outputs(y_predicted, X_trans, X_test, y_test, target_column_name,
predicted_column_name='predicted',
horizon_colname='horizon_origin'):
"""
Demonstrates how to get the output aligned to the inputs
using pandas indexes. Helps understand what happened if
the output's shape differs from the input shape, or if
the data got re-sorted by time and grain during forecasting.
Typical causes of misalignment are:
* we predicted some periods that were missing in actuals -> drop from eval
* model was asked to predict past max_horizon -> increase max horizon
* data at start of X_test was needed for lags -> provide previous periods
"""
if (horizon_colname in X_trans):
df_fcst = pd.DataFrame({predicted_column_name: y_predicted,
horizon_colname: X_trans[horizon_colname]})
else:
df_fcst = pd.DataFrame({predicted_column_name: y_predicted})
# y and X outputs are aligned by forecast() function contract
df_fcst.index = X_trans.index
# align original X_test to y_test
X_test_full = X_test.copy()
X_test_full[target_column_name] = y_test
# X_test_full's index does not include origin, so reset for merge
df_fcst.reset_index(inplace=True)
X_test_full = X_test_full.reset_index().drop(columns='index')
together = df_fcst.merge(X_test_full, how='right')
# drop rows where prediction or actuals are nan
# happens because of missing actuals
# or at edges of time due to lags/rolling windows
clean = together[together[[target_column_name,
predicted_column_name]].notnull().all(axis=1)]
return(clean)

View File

@@ -0,0 +1,22 @@
import pandas as pd
import numpy as np
def APE(actual, pred):
"""
Calculate absolute percentage error.
Returns a vector of APE values with same length as actual/pred.
"""
return 100 * np.abs((actual - pred) / actual)
def MAPE(actual, pred):
"""
Calculate mean absolute percentage error.
Remove NA and values where actual is close to zero
"""
not_na = ~(np.isnan(actual) | np.isnan(pred))
not_zero = ~np.isclose(actual, 0.0)
actual_safe = actual[not_na & not_zero]
pred_safe = pred[not_na & not_zero]
return np.mean(APE(actual_safe, pred_safe))

View File

@@ -6,8 +6,24 @@
"source": [
"# Automated Machine Learning\n",
"\n",
"## Forecasting away from training data\n",
"#### Forecasting away from training data\n",
"\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"2. [Setup](#Setup)\n",
"3. [Data](#Data)\n",
"4. [Prepare remote compute and data.](#prepare_remote)\n",
"4. [Create the configuration and train a forecaster](#train)\n",
"5. [Forecasting from the trained model](#forecasting)\n",
"6. [Forecasting away from training data](#forecasting_away)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"This notebook demonstrates the full interface to the `forecast()` function. \n",
"\n",
"The best known and most frequent usage of `forecast` enables forecasting on test sets that immediately follows training data. \n",
@@ -46,12 +62,18 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import pandas as pd\n",
"import numpy as np\n",
"import logging\n",
"import warnings\n",
"\n",
"from azureml.core.dataset import Dataset\n",
"from pandas.tseries.frequencies import to_offset\n",
"from azureml.core.compute import AmlCompute\n",
"from azureml.core.compute import ComputeTarget\n",
"from azureml.core.runconfig import RunConfiguration\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"\n",
"# Squash warning messages for cleaner output in the notebook\n",
"warnings.showwarning = lambda *args, **kwargs: None\n",
@@ -188,7 +210,8 @@
"# plot the example time series\n",
"import matplotlib.pyplot as plt\n",
"whole_data = X_train.copy()\n",
"whole_data['y'] = y_train\n",
"target_label = 'y'\n",
"whole_data[target_label] = y_train\n",
"for g in whole_data.groupby('grain'): \n",
" plt.plot(g[1]['date'].values, g[1]['y'].values, label=g[0])\n",
"plt.legend()\n",
@@ -199,15 +222,79 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create the configuration and train a forecaster\n",
"### Prepare remote compute and data. <a id=\"prepare_remote\"></a>\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 artificial 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": [
"# We need to save thw artificial data and then upload them to default workspace datastore.\n",
"DATA_PATH = \"fc_fn_data\"\n",
"DATA_PATH_X = \"{}/data_train.csv\".format(DATA_PATH)\n",
"if not os.path.isdir('data'):\n",
" os.mkdir('data')\n",
"pd.DataFrame(whole_data).to_csv(\"data/data_train.csv\", index=False)\n",
"# Upload saved data to the default data store.\n",
"ds = ws.get_default_datastore()\n",
"ds.upload(src_dir='./data', target_path=DATA_PATH, overwrite=True, show_progress=True)\n",
"train_data = Dataset.Tabular.from_delimited_files(path=ds.path(DATA_PATH_X))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You will 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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"amlcompute_cluster_name = \"cpu-cluster-8\"\n",
" \n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
"\n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_D2_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 6)\n",
"\n",
" # Create the cluster.\\n\",\n",
" compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, provisioning_config)\n",
"\n",
"print('Checking cluster status...')\n",
"# Can poll for a minimum number of nodes and for a specific timeout.\n",
"# If no min_node_count is provided, it will use the scale settings for the cluster.\n",
"compute_target.wait_for_completion(show_output = True, min_node_count = None, timeout_in_minutes = 20)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create the configuration and train a forecaster <a id=\"train\"></a>\n",
"First generate the configuration, in which we:\n",
"* Set metadata columns: target, time column and grain column names.\n",
"* Ask for 10 iterations through models, last of which will represent the Ensemble of previous ones.\n",
"* Validate our data using cross validation with rolling window method.\n",
"* Set normalized root mean squared error as a metric to select the best model.\n",
"\n",
"* Set early termination to True, so the iterations through the models will stop when no improvements in accuracy score will be made.\n",
"* Set limitations on the length of experiment run to 15 minutes.\n",
"* Finally, we set the task to be forecasting.\n",
"* By default, we apply the lag lead operator and rolling window to the target value i.e. we use the previous values as a predictor for the future ones."
"* We apply the lag lead operator to the target value i.e. we use the previous values as a predictor for the future ones."
]
},
{
@@ -217,7 +304,6 @@
"outputs": [],
"source": [
"lags = [1,2,3]\n",
"rolling_window_length = 0 # don't do rolling windows\n",
"max_horizon = n_test_periods\n",
"time_series_settings = { \n",
" 'time_column_name': TIME_COLUMN_NAME,\n",
@@ -247,25 +333,30 @@
"\n",
"automl_config = AutoMLConfig(task='forecasting',\n",
" debug_log='automl_forecasting_function.log',\n",
" primary_metric='normalized_root_mean_squared_error', \n",
" iterations=10, \n",
" X=X_train,\n",
" y=y_train,\n",
" primary_metric='normalized_root_mean_squared_error',\n",
" experiment_timeout_minutes=15,\n",
" enable_early_stopping=True,\n",
" training_data=train_data,\n",
" compute_target=compute_target,\n",
" n_cross_validations=3,\n",
" verbosity = logging.INFO,\n",
" max_concurrent_iterations=4,\n",
" max_cores_per_iteration=-1,\n",
" label_column_name=target_label,\n",
" **time_series_settings)\n",
"\n",
"local_run = experiment.submit(automl_config, show_output=True)\n",
"remote_run = experiment.submit(automl_config, show_output=False)\n",
"remote_run.wait_for_completion()\n",
"\n",
"# Retrieve the best model to use it further.\n",
"_, fitted_model = local_run.get_output()"
"_, fitted_model = remote_run.get_output()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Forecasting from the trained model"
"## Forecasting from the trained model <a id=\"forecasting\"></a>"
]
},
{
@@ -324,6 +415,31 @@
"xy_nogap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Confidence intervals"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Forecasting model may be used for the prediction of forecasting intervals by running ```forecast_quantiles()```. \n",
"This method accepts the same parameters as forecast()."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"quantiles = fitted_model.forecast_quantiles(X_test, y_query)\n",
"quantiles"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -355,7 +471,7 @@
"source": [
"#### Destination-date forecast: \"just do something\"\n",
"\n",
"In some scenarios, the X_test is not known. The forecast is likely to be weak, becaus eit is missing contemporaneous predictors, which we will need to impute. If you still wish to predict forward under the assumption that the last known values will be carried forward, you can forecast out to \"destination date\". The destination date still needs to fit within the maximum horizon from training."
"In some scenarios, the X_test is not known. The forecast is likely to be weak, becaus it is missing contemporaneous predictors, which we will need to impute. If you still wish to predict forward under the assumption that the last known values will be carried forward, you can forecast out to \"destination date\". The destination date still needs to fit within the maximum horizon from training."
]
},
{
@@ -376,7 +492,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Forecasting away from training data\n",
"## Forecasting away from training data <a id=\"forecasting_away\"></a>\n",
"\n",
"Suppose we trained a model, some time passed, and now we want to apply the model without re-training. If the model \"looks back\" -- uses previous values of the target -- then we somehow need to provide those values to the model.\n",
"\n",
@@ -520,7 +636,7 @@
"outputs": [],
"source": [
"print(X_context.groupby(GRAIN_COLUMN_NAME)[TIME_COLUMN_NAME].agg(['min','max','count']))\n",
"print( X_away.groupby(GRAIN_COLUMN_NAME)[TIME_COLUMN_NAME].agg(['min','max','count']))\n",
"print(X_away.groupby(GRAIN_COLUMN_NAME)[TIME_COLUMN_NAME].agg(['min','max','count']))\n",
"X_context.tail(5)"
]
},
@@ -547,7 +663,7 @@
"print(\"Forecast origin: \" + str(forecast_origin))\n",
" \n",
"# the model uses lags and rolling windows to look back in time\n",
"n_lookback_periods = max(max(lags), rolling_window_length)\n",
"n_lookback_periods = max(lags)\n",
"lookback = pd.DateOffset(hours=n_lookback_periods)\n",
"\n",
"horizon = pd.DateOffset(hours=max_horizon)\n",
@@ -592,6 +708,22 @@
"name": "erwright, nirovins"
}
],
"category": "tutorial",
"compute": [
"remote"
],
"datasets": [
"None"
],
"deployment": [
"None"
],
"exclude_from_index": false,
"framework": [
"Azure ML AutoML"
],
"friendly_name": "Forecasting away from training data",
"index_order": 3,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -608,7 +740,12 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"tags": [
"Forecasting",
"Confidence Intervals"
],
"task": "forecasting"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -1,5 +1,7 @@
name: automl-forecasting-function
dependencies:
- fbprophet==0.5
- py-xgboost<=0.80
- pip:
- azureml-sdk
- azureml-train-automl

View File

@@ -26,6 +26,7 @@
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Compute](#Compute)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Predict](#Predict)\n",
@@ -39,7 +40,7 @@
"## Introduction\n",
"In this example, we use AutoML to train, select, and operationalize a time-series forecasting model for multiple time-series.\n",
"\n",
"Make sure you have executed the [configuration notebook](../../../configuration.ipynb) before running this notebook.\n",
"Make sure you have executed the [configuration notebook](../configuration.ipynb) before running this notebook.\n",
"\n",
"The examples in the follow code samples use the University of Chicago's Dominick's Finer Foods dataset to forecast orange juice sales. Dominick's was a grocery chain in the Chicago metropolitan area."
]
@@ -61,15 +62,10 @@
"import pandas as pd\n",
"import numpy as np\n",
"import logging\n",
"import warnings\n",
"\n",
"# Squash warning messages for cleaner output in the notebook\n",
"warnings.showwarning = lambda *args, **kwargs: None\n",
"\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.train.automl import AutoMLConfig\n",
"from sklearn.metrics import mean_absolute_error, mean_squared_error"
"from azureml.train.automl import AutoMLConfig"
]
},
{
@@ -104,6 +100,54 @@
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Compute\n",
"You will 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",
"#### 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 on the default limits and how to request more quota."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.compute import AmlCompute\n",
"from azureml.core.compute import ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"cpu-cluster-7\"\n",
"\n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
" \n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_D2_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 4)\n",
"\n",
" # Create the cluster.\n",
" compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, provisioning_config)\n",
" \n",
"print('Checking cluster status...')\n",
"# Can poll for a minimum number of nodes and for a specific timeout.\n",
"# If no min_node_count is provided, it will use the scale settings for the cluster.\n",
"compute_target.wait_for_completion(show_output = True, min_node_count = None, timeout_in_minutes = 20)\n",
" \n",
"# For a more detailed view of current AmlCompute status, use get_status()."
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -186,7 +230,61 @@
" df_tail = df_grouped.apply(lambda dfg: dfg.iloc[-n:])\n",
" return df_head, df_tail\n",
"\n",
"X_train, X_test = split_last_n_by_grain(data_subset, n_test_periods)"
"train, test = split_last_n_by_grain(data_subset, n_test_periods)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Upload data to 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 train and test data and create [tabular datasets](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.data.tabulardataset?view=azure-ml-py) for training and testing. 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": [
"train.to_csv (r'./dominicks_OJ_train.csv', index = None, header=True)\n",
"test.to_csv (r'./dominicks_OJ_test.csv', index = None, header=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"datastore = ws.get_default_datastore()\n",
"datastore.upload_files(files = ['./dominicks_OJ_train.csv', './dominicks_OJ_test.csv'], target_path = 'dataset/', overwrite = True,show_progress = True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create dataset for training"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.dataset import Dataset\n",
"train_dataset = Dataset.Tabular.from_delimited_files(path=datastore.path('dataset/dominicks_OJ_train.csv'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"train_dataset.to_pandas_dataframe().tail()"
]
},
{
@@ -202,7 +300,7 @@
"* Create time-based features to assist in learning seasonal patterns\n",
"* Encode categorical variables to numeric quantities\n",
"\n",
"AutoML will currently train a single, regression-type model across **all** time-series in a given training set. This allows the model to generalize across related series.\n",
"In this notebook, AutoML will train a single, regression-type model across **all** time-series in a given training set. This allows the model to generalize across related series. If you're looking for training multiple models for different time-series, please check out the forecasting grouping notebook. \n",
"\n",
"You are almost ready to start an AutoML training job. First, we need to separate the target column from the rest of the DataFrame: "
]
@@ -213,8 +311,7 @@
"metadata": {},
"outputs": [],
"source": [
"target_column_name = 'Quantity'\n",
"y_train = X_train.pop(target_column_name).values"
"target_column_name = 'Quantity'"
]
},
{
@@ -237,13 +334,15 @@
"|-|-|\n",
"|**task**|forecasting|\n",
"|**primary_metric**|This is the metric that you want to optimize.<br> Forecasting supports the following primary metrics <br><i>spearman_correlation</i><br><i>normalized_root_mean_squared_error</i><br><i>r2_score</i><br><i>normalized_mean_absolute_error</i>\n",
"|**iterations**|Number of iterations. In each iteration, Auto ML trains a specific pipeline on the given data|\n",
"|**X**|Training matrix of features as a pandas DataFrame, shape = [n_training_samples, n_features]|\n",
"|**y**|Target values as a numpy.ndarray, shape = [n_training_samples, ]|\n",
"|**experiment_timeout_minutes**|Experimentation timeout in minutes.|\n",
"|**enable_early_stopping**|If early stopping is on, training will stop when the primary metric is no longer improving.|\n",
"|**training_data**|Input dataset, containing both features and label column.|\n",
"|**label_column_name**|The name of the label column.|\n",
"|**compute_target**|The remote compute for training.|\n",
"|**n_cross_validations**|Number of cross-validation folds to use for model/pipeline selection|\n",
"|**enable_voting_ensemble**|Allow AutoML to create a Voting ensemble of the best performing models\n",
"|**enable_stack_ensemble**|Allow AutoML to create a Stack ensemble of the best performing models\n",
"|**debug_log**|Log file path for writing debugging information\n",
"|**enable_voting_ensemble**|Allow AutoML to create a Voting ensemble of the best performing models|\n",
"|**enable_stack_ensemble**|Allow AutoML to create a Stack ensemble of the best performing models|\n",
"|**debug_log**|Log file path for writing debugging information|\n",
"|**time_column_name**|Name of the datetime column in the input data|\n",
"|**grain_column_names**|Name(s) of the columns defining individual series in the input data|\n",
"|**drop_column_names**|Name(s) of columns to drop prior to modeling|\n",
@@ -259,19 +358,21 @@
"time_series_settings = {\n",
" 'time_column_name': time_column_name,\n",
" 'grain_column_names': grain_column_names,\n",
" 'drop_column_names': ['logQuantity'],\n",
" 'drop_column_names': ['logQuantity'], # 'logQuantity' is a leaky feature, so we remove it.\n",
" 'max_horizon': n_test_periods\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task='forecasting',\n",
" debug_log='automl_oj_sales_errors.log',\n",
" primary_metric='normalized_mean_absolute_error',\n",
" iterations=10,\n",
" X=X_train,\n",
" y=y_train,\n",
" experiment_timeout_minutes=15,\n",
" training_data=train_dataset,\n",
" label_column_name=target_column_name,\n",
" compute_target=compute_target,\n",
" enable_early_stopping = True,\n",
" n_cross_validations=3,\n",
" enable_voting_ensemble=False,\n",
" enable_stack_ensemble=False,\n",
" max_concurrent_iterations=4,\n",
" max_cores_per_iteration=-1,\n",
" verbosity=logging.INFO,\n",
" **time_series_settings)"
]
@@ -280,7 +381,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"You can now submit a new training run. For local runs, the execution is synchronous. Depending on the data and number of iterations this operation may take several minutes.\n",
"You can now submit a new training run. Depending on the data and number of iterations this operation may take several minutes.\n",
"Information from each iteration will be printed to the console."
]
},
@@ -290,7 +391,17 @@
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output=True)"
"remote_run = experiment.submit(automl_config, show_output=False)\n",
"remote_run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run.wait_for_completion()"
]
},
{
@@ -307,8 +418,9 @@
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_pipeline = local_run.get_output()\n",
"fitted_pipeline.steps"
"best_run, fitted_model = remote_run.get_output()\n",
"print(fitted_model.steps)\n",
"model_name = best_run.properties['model_name']"
]
},
{
@@ -326,6 +438,7 @@
"metadata": {},
"outputs": [],
"source": [
"X_test = test\n",
"y_test = X_test.pop(target_column_name).values"
]
},
@@ -353,7 +466,7 @@
"metadata": {},
"outputs": [],
"source": [
"# Replace ALL values in y_pred by NaN.\n",
"# Replace ALL values in y by NaN.\n",
"# The forecast origin will be at the beginning of the first forecast period.\n",
"# (Which is the same time as the end of the last training period.)\n",
"y_query = y_test.copy().astype(np.float)\n",
@@ -361,7 +474,7 @@
"# The featurized data, aligned to y, will also be returned.\n",
"# This contains the assumptions that were made in the forecast\n",
"# and helps align the forecast to the original data\n",
"y_pred, X_trans = fitted_pipeline.forecast(X_test, y_query)"
"y_predictions, X_trans = fitted_model.forecast(X_test, y_query)"
]
},
{
@@ -390,39 +503,9 @@
"metadata": {},
"outputs": [],
"source": [
"def align_outputs(y_predicted, X_trans, X_test, y_test, predicted_column_name = 'predicted'):\n",
" \"\"\"\n",
" Demonstrates how to get the output aligned to the inputs\n",
" using pandas indexes. Helps understand what happened if\n",
" the output's shape differs from the input shape, or if\n",
" the data got re-sorted by time and grain during forecasting.\n",
" \n",
" Typical causes of misalignment are:\n",
" * we predicted some periods that were missing in actuals -> drop from eval\n",
" * model was asked to predict past max_horizon -> increase max horizon\n",
" * data at start of X_test was needed for lags -> provide previous periods in y\n",
" \"\"\"\n",
" \n",
" df_fcst = pd.DataFrame({predicted_column_name : y_predicted})\n",
" # y and X outputs are aligned by forecast() function contract\n",
" df_fcst.index = X_trans.index\n",
" \n",
" # align original X_test to y_test \n",
" X_test_full = X_test.copy()\n",
" X_test_full[target_column_name] = y_test\n",
"from forecasting_helper import align_outputs\n",
"\n",
" # X_test_full's index does not include origin, so reset for merge\n",
" df_fcst.reset_index(inplace=True)\n",
" X_test_full = X_test_full.reset_index().drop(columns='index')\n",
" together = df_fcst.merge(X_test_full, how='right')\n",
" \n",
" # drop rows where prediction or actuals are nan \n",
" # happens because of missing actuals \n",
" # or at edges of time due to lags/rolling windows\n",
" clean = together[together[[target_column_name, predicted_column_name]].notnull().all(axis=1)]\n",
" return(clean)\n",
"\n",
"df_all = align_outputs(y_pred, X_trans, X_test, y_test)"
"df_all = align_outputs(y_predictions, X_trans, X_test, y_test, target_column_name)"
]
},
{
@@ -431,38 +514,25 @@
"metadata": {},
"outputs": [],
"source": [
"def MAPE(actual, pred):\n",
" \"\"\"\n",
" Calculate mean absolute percentage error.\n",
" Remove NA and values where actual is close to zero\n",
" \"\"\"\n",
" not_na = ~(np.isnan(actual) | np.isnan(pred))\n",
" not_zero = ~np.isclose(actual, 0.0)\n",
" actual_safe = actual[not_na & not_zero]\n",
" pred_safe = pred[not_na & not_zero]\n",
" APE = 100*np.abs((actual_safe - pred_safe)/actual_safe)\n",
" return np.mean(APE)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"Simple forecasting model\")\n",
"rmse = np.sqrt(mean_squared_error(df_all[target_column_name], df_all['predicted']))\n",
"print(\"[Test Data] \\nRoot Mean squared error: %.2f\" % rmse)\n",
"mae = mean_absolute_error(df_all[target_column_name], df_all['predicted'])\n",
"print('mean_absolute_error score: %.2f' % mae)\n",
"print('MAPE: %.2f' % MAPE(df_all[target_column_name], df_all['predicted']))\n",
"from azureml.automl.core._vendor.automl.client.core.common import metrics\n",
"from matplotlib import pyplot as plt\n",
"from automl.client.core.common import constants\n",
"\n",
"# use automl metrics module\n",
"scores = metrics.compute_metrics_regression(\n",
" df_all['predicted'],\n",
" df_all[target_column_name],\n",
" list(constants.Metric.SCALAR_REGRESSION_SET),\n",
" None, None, None)\n",
"\n",
"print(\"[Test data scores]\\n\")\n",
"for key, value in scores.items(): \n",
" print('{}: {:.3f}'.format(key, value))\n",
" \n",
"# Plot outputs\n",
"import matplotlib.pyplot as plt\n",
"\n",
"%matplotlib inline\n",
"test_pred = plt.scatter(df_all[target_column_name], df_all['predicted'], color='b')\n",
"test_test = plt.scatter(y_test, y_test, color='g')\n",
"test_test = plt.scatter(df_all[target_column_name], df_all[target_column_name], color='g')\n",
"plt.legend((test_pred, test_test), ('prediction', 'truth'), loc='upper left', fontsize=8)\n",
"plt.show()"
]
@@ -489,9 +559,9 @@
"source": [
"description = 'AutoML OJ forecaster'\n",
"tags = None\n",
"model = local_run.register_model(description = description, tags = tags)\n",
"model = remote_run.register_model(model_name = model_name, description = description, tags = tags)\n",
"\n",
"print(local_run.model_id)"
"print(remote_run.model_id)"
]
},
{
@@ -500,7 +570,7 @@
"source": [
"### Develop the scoring script\n",
"\n",
"Serializing and deserializing complex data frames may be tricky. We first develop the `run()` function of the scoring script locally, then write it into a scoring script. It is much easier to debug any quirks of the scoring function without crossing two compute environments. For this exercise, we handle a common quirk of how pandas dataframes serialize time stamp values."
"Serializing and deserializing complex data frames may be tricky. We first develop the ```run()``` function of the scoring script locally, then write it into a scoring script. It is much easier to debug any quirks of the scoring function without crossing two compute environments. For this exercise, we handle a common quirk of how pandas dataframes serialize time stamp values."
]
},
{
@@ -558,7 +628,7 @@
"import json\n",
"\n",
"test_sample = json.dumps({'X': X_test.to_json(), 'y' : y_query.tolist()})\n",
"response = run(test_sample, fitted_pipeline)\n",
"response = run(test_sample, fitted_model)\n",
"\n",
"# unpack the response, dealing with the timestamp serialization again\n",
"res_dict = json.loads(response)\n",
@@ -640,60 +710,12 @@
"metadata": {},
"outputs": [],
"source": [
"# get the model\n",
"from azureml.train.automl.run import AutoMLRun\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"ml_run = AutoMLRun(experiment = experiment, run_id = local_run.id)\n",
"best_iteration = int(str.split(best_run.id,'_')[-1]) # the iteration number is a postfix of the run ID."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# get the best model's dependencies and write them into this file\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"\n",
"conda_env_file_name = 'fcast_env.yml'\n",
"\n",
"dependencies = ml_run.get_run_sdk_dependencies(iteration = best_iteration)\n",
"for p in ['azureml-train-automl', 'azureml-core']:\n",
" print('{}\\t{}'.format(p, dependencies[p]))\n",
"\n",
"myenv = CondaDependencies.create(conda_packages=['numpy>=1.16.0,<=1.16.2','scikit-learn','fbprophet==0.5'], pip_packages=['azureml-defaults','azureml-train-automl'])\n",
"\n",
"myenv.save_to_file('.', conda_env_file_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# this is the script file name we wrote a few cells above\n",
"script_file_name = 'score_fcast.py'\n",
"\n",
"# Substitute the actual version number in the environment file.\n",
"# This is not strictly needed in this notebook because the model should have been generated using the current SDK version.\n",
"# However, we include this in case this code is used on an experiment from a previous SDK version.\n",
"\n",
"with open(conda_env_file_name, 'r') as cefr:\n",
" content = cefr.read()\n",
"\n",
"with open(conda_env_file_name, 'w') as cefw:\n",
" cefw.write(content.replace(azureml.core.VERSION, dependencies['azureml-train-automl']))\n",
"\n",
"# Substitute the actual model id in the script file.\n",
"\n",
"with open(script_file_name, 'r') as cefr:\n",
" content = cefr.read()\n",
"\n",
"with open(script_file_name, 'w') as cefw:\n",
" cefw.write(content.replace('<<modelid>>', local_run.model_id))"
" cefw.write(content.replace('<<modelid>>', remote_run.model_id))"
]
},
{
@@ -714,22 +736,30 @@
"from azureml.core.webservice import Webservice\n",
"from azureml.core.model import Model\n",
"\n",
"inference_config = InferenceConfig(runtime = \"python\", \n",
" entry_script = script_file_name,\n",
" conda_file = conda_env_file_name)\n",
"inference_config = InferenceConfig(environment = best_run.get_environment(), \n",
" entry_script = script_file_name)\n",
"\n",
"aciconfig = AciWebservice.deploy_configuration(cpu_cores = 1, \n",
" memory_gb = 2, \n",
" tags = {'type': \"automl-forecasting\"},\n",
" description = \"Automl forecasting sample service\")\n",
"\n",
"aci_service_name = 'automl-forecast-01'\n",
"aci_service_name = 'automl-oj-forecast-01'\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",
"print(aci_service.state)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"aci_service.get_logs()"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -779,8 +809,8 @@
"metadata": {},
"outputs": [],
"source": [
"serv = Webservice(ws, 'automl-forecast-01')\n",
"# serv.delete() # don't do it accidentally"
"serv = Webservice(ws, 'automl-oj-forecast-01')\n",
"serv.delete() # don't do it accidentally"
]
}
],
@@ -790,6 +820,23 @@
"name": "erwright"
}
],
"category": "tutorial",
"celltoolbar": "Raw Cell Format",
"compute": [
"remote"
],
"datasets": [
"Orange Juice Sales"
],
"deployment": [
"Azure Container Instance"
],
"exclude_from_index": false,
"framework": [
"Azure ML AutoML"
],
"friendly_name": "Forecasting orange juice sales with deployment",
"index_order": 1,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -806,7 +853,8 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"task": "Forecasting"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -1,5 +1,7 @@
name: auto-ml-forecasting-orange-juice-sales
dependencies:
- fbprophet==0.5
- py-xgboost<=0.80
- pip:
- azureml-sdk
- azureml-train-automl

View File

@@ -0,0 +1,98 @@
import pandas as pd
import numpy as np
from pandas.tseries.frequencies import to_offset
def align_outputs(y_predicted, X_trans, X_test, y_test, target_column_name,
predicted_column_name='predicted',
horizon_colname='horizon_origin'):
"""
Demonstrates how to get the output aligned to the inputs
using pandas indexes. Helps understand what happened if
the output's shape differs from the input shape, or if
the data got re-sorted by time and grain during forecasting.
Typical causes of misalignment are:
* we predicted some periods that were missing in actuals -> drop from eval
* model was asked to predict past max_horizon -> increase max horizon
* data at start of X_test was needed for lags -> provide previous periods
"""
if (horizon_colname in X_trans):
df_fcst = pd.DataFrame({predicted_column_name: y_predicted,
horizon_colname: X_trans[horizon_colname]})
else:
df_fcst = pd.DataFrame({predicted_column_name: y_predicted})
# y and X outputs are aligned by forecast() function contract
df_fcst.index = X_trans.index
# align original X_test to y_test
X_test_full = X_test.copy()
X_test_full[target_column_name] = y_test
# X_test_full's index does not include origin, so reset for merge
df_fcst.reset_index(inplace=True)
X_test_full = X_test_full.reset_index().drop(columns='index')
together = df_fcst.merge(X_test_full, how='right')
# drop rows where prediction or actuals are nan
# happens because of missing actuals
# or at edges of time due to lags/rolling windows
clean = together[together[[target_column_name,
predicted_column_name]].notnull().all(axis=1)]
return(clean)
def do_rolling_forecast(fitted_model, X_test, y_test, target_column_name, time_column_name, max_horizon, freq='D'):
"""
Produce forecasts on a rolling origin over the given test set.
Each iteration makes a forecast for the next 'max_horizon' periods
with respect to the current origin, then advances the origin by the
horizon time duration. The prediction context for each forecast is set so
that the forecaster uses the actual target values prior to the current
origin time for constructing lag features.
This function returns a concatenated DataFrame of rolling forecasts.
"""
df_list = []
origin_time = X_test[time_column_name].min()
while origin_time <= X_test[time_column_name].max():
# Set the horizon time - end date of the forecast
horizon_time = origin_time + max_horizon * to_offset(freq)
# Extract test data from an expanding window up-to the horizon
expand_wind = (X_test[time_column_name] < horizon_time)
X_test_expand = X_test[expand_wind]
y_query_expand = np.zeros(len(X_test_expand)).astype(np.float)
y_query_expand.fill(np.NaN)
if origin_time != X_test[time_column_name].min():
# Set the context by including actuals up-to the origin time
test_context_expand_wind = (X_test[time_column_name] < origin_time)
context_expand_wind = (
X_test_expand[time_column_name] < origin_time)
y_query_expand[context_expand_wind] = y_test[
test_context_expand_wind]
# Make a forecast out to the maximum horizon
y_fcst, X_trans = fitted_model.forecast(X_test_expand, y_query_expand)
# Align forecast with test set for dates within the
# current rolling window
trans_tindex = X_trans.index.get_level_values(time_column_name)
trans_roll_wind = (trans_tindex >= origin_time) & (
trans_tindex < horizon_time)
test_roll_wind = expand_wind & (
X_test[time_column_name] >= origin_time)
df_list.append(align_outputs(y_fcst[trans_roll_wind],
X_trans[trans_roll_wind],
X_test[test_roll_wind],
y_test[test_roll_wind],
target_column_name))
# Advance the origin time
origin_time = horizon_time
return pd.concat(df_list, ignore_index=True)

View File

@@ -0,0 +1,22 @@
import pandas as pd
import numpy as np
def APE(actual, pred):
"""
Calculate absolute percentage error.
Returns a vector of APE values with same length as actual/pred.
"""
return 100 * np.abs((actual - pred) / actual)
def MAPE(actual, pred):
"""
Calculate mean absolute percentage error.
Remove NA and values where actual is close to zero
"""
not_na = ~(np.isnan(actual) | np.isnan(pred))
not_zero = ~np.isclose(actual, 0.0)
actual_safe = actual[not_na & not_zero]
pred_safe = pred[not_na & not_zero]
return np.mean(APE(actual_safe, pred_safe))

View File

@@ -0,0 +1,422 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/classification-credit-card-fraud/auto-ml-classification-credit-card-fraud.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Classification of credit card fraudulent transactions with local run **_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Test](#Test)\n",
"1. [Acknowledgements](#Acknowledgements)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"\n",
"In this example we use the associated credit card dataset to showcase how you can use AutoML for a simple classification problem. The goal is to predict if a credit card transaction is considered a fraudulent charge.\n",
"\n",
"This notebook is using the local machine compute to train the model.\n",
"\n",
"If you are using an Azure Machine Learning [Notebook VM](https://docs.microsoft.com/en-us/azure/machine-learning/service/tutorial-1st-experiment-sdk-setup), you are all set. Otherwise, go through the [configuration](../../../configuration.ipynb) notebook first if you haven't already to establish your connection to the AzureML Workspace. \n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an experiment using an existing workspace.\n",
"2. Configure AutoML using `AutoMLConfig`.\n",
"3. Train the model.\n",
"4. Explore the results.\n",
"5. Test the fitted model."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import pandas as pd\n",
"import os\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.dataset import Dataset\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# choose a name for experiment\n",
"experiment_name = 'automl-classification-ccard-local'\n",
"\n",
"experiment=Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load Data\n",
"\n",
"Load the credit card dataset from a csv file containing both training features and labels. The features are inputs to the model, while the training labels represent the expected output of the model. Next, we'll split the data using random_split and extract the training data for the model."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/creditcard.csv\"\n",
"dataset = Dataset.Tabular.from_delimited_files(data)\n",
"training_data, validation_data = dataset.random_split(percentage=0.8, seed=223)\n",
"label_column_name = 'Class'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate a AutoMLConfig object. This defines the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**enable_early_stopping**|Stop the run if the metric score is not showing improvement.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**training_data**|Input dataset, containing both features and label column.|\n",
"|**label_column_name**|The name of the label column.|\n",
"\n",
"**_You can find more information about primary metrics_** [here](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-configure-auto-train#primary-metric)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_settings = {\n",
" \"n_cross_validations\": 3,\n",
" \"primary_metric\": 'average_precision_score_weighted',\n",
" \"preprocess\": True,\n",
" \"experiment_timeout_minutes\": 10, # This is a time limit for testing purposes, remove it for real use cases, this will drastically limit ablity to find the best model possible\n",
" \"verbosity\": logging.INFO,\n",
" \"enable_stack_ensemble\": False\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" training_data = training_data,\n",
" label_column_name = label_column_name,\n",
" **automl_settings\n",
" )"
]
},
{
"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",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output = True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# If you need to retrieve a run that already started, use the following code\n",
"#from azureml.train.automl.run import AutoMLRun\n",
"#local_run = AutoMLRun(experiment = experiment, run_id = '<replace with your run id>')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(local_run).show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Analyze results\n",
"\n",
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method on `automl_classifier` returns the best run and the fitted model for the last invocation. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()\n",
"fitted_model"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Print the properties of the model\n",
"The fitted_model is a python object and you can read the different properties of the object.\n",
"See *Print the properties of the model* section in [this sample notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/classification/auto-ml-classification.ipynb)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Deploy\n",
"\n",
"To deploy the model into a web service endpoint, see _Deploy_ section in [this sample notebook](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/automated-machine-learning/classification-with-deployment/auto-ml-classification-with-deployment.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test the fitted model\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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# convert the test data to dataframe\n",
"X_test_df = validation_data.drop_columns(columns=[label_column_name]).to_pandas_dataframe()\n",
"y_test_df = validation_data.keep_columns(columns=[label_column_name], validate=True).to_pandas_dataframe()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# call the predict functions on the model\n",
"y_pred = fitted_model.predict(X_test_df)\n",
"y_pred"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Calculate metrics for the prediction\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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.metrics import confusion_matrix\n",
"import numpy as np\n",
"import itertools\n",
"\n",
"cf =confusion_matrix(y_test_df.values,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()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Acknowledgements"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This Credit Card fraud Detection dataset is made available under the Open Database License: http://opendatacommons.org/licenses/odbl/1.0/. Any rights in individual contents of the database are licensed under the Database Contents License: http://opendatacommons.org/licenses/dbcl/1.0/ and is available at: https://www.kaggle.com/mlg-ulb/creditcardfraud\n",
"\n",
"\n",
"The dataset has been collected and analysed during a research collaboration of Worldline and the Machine Learning Group (http://mlg.ulb.ac.be) of ULB (Universit\u00c3\u0192\u00c2\u00a9 Libre de Bruxelles) on big data mining and fraud detection. More details on current and past projects on related topics are available on https://www.researchgate.net/project/Fraud-detection-5 and the page of the DefeatFraud project\n",
"Please cite the following works: \n",
"\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00a2\tAndrea Dal Pozzolo, Olivier Caelen, Reid A. Johnson and Gianluca Bontempi. Calibrating Probability with Undersampling for Unbalanced Classification. In Symposium on Computational Intelligence and Data Mining (CIDM), IEEE, 2015\n",
"\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00a2\tDal Pozzolo, Andrea; Caelen, Olivier; Le Borgne, Yann-Ael; Waterschoot, Serge; Bontempi, Gianluca. Learned lessons in credit card fraud detection from a practitioner perspective, Expert systems with applications,41,10,4915-4928,2014, Pergamon\n",
"\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00a2\tDal Pozzolo, Andrea; Boracchi, Giacomo; Caelen, Olivier; Alippi, Cesare; Bontempi, Gianluca. Credit card fraud detection: a realistic modeling and a novel learning strategy, IEEE transactions on neural networks and learning systems,29,8,3784-3797,2018,IEEE\n",
"o\tDal Pozzolo, Andrea Adaptive Machine learning for credit card fraud detection ULB MLG PhD thesis (supervised by G. Bontempi)\n",
"\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00a2\tCarcillo, Fabrizio; Dal Pozzolo, Andrea; Le Borgne, Yann-A\u00c3\u0192\u00c2\u00abl; Caelen, Olivier; Mazzer, Yannis; Bontempi, Gianluca. Scarff: a scalable framework for streaming credit card fraud detection with Spark, Information fusion,41, 182-194,2018,Elsevier\n",
"\u00c3\u00a2\u00e2\u201a\u00ac\u00c2\u00a2\tCarcillo, Fabrizio; Le Borgne, Yann-A\u00c3\u0192\u00c2\u00abl; Caelen, Olivier; Bontempi, Gianluca. Streaming active learning strategies for real-life credit card fraud detection: assessment and visualization, International Journal of Data Science and Analytics, 5,4,285-300,2018,Springer International Publishing"
]
}
],
"metadata": {
"authors": [
{
"name": "tzvikei"
}
],
"category": "tutorial",
"compute": [
"Local"
],
"datasets": [
"creditcard"
],
"deployment": [
"None"
],
"exclude_from_index": true,
"file_extension": ".py",
"framework": [
"None"
],
"friendly_name": "Classification of credit card fraudulent transactions using Automated ML",
"index_order": 5,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
},
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"tags": [
"local_run",
"AutomatedML"
],
"task": "Classification",
"version": "3.6.7"
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,423 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/missing-data-blacklist-early-termination/auto-ml-missing-data-blacklist-early-termination.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Blacklisting Models, Early Termination, and Handling Missing Data**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Test](#Test)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we use the scikit-learn's [digit dataset](http://scikit-learn.org/stable/datasets/index.html#optical-recognition-of-handwritten-digits-dataset) to showcase how you can use AutoML for handling missing values in data. We also provide a stopping metric indicating a target for the primary metrics so that AutoML can terminate the run without necessarly going through all the iterations. Finally, if you want to avoid a certain pipeline, we allow you to specify a blacklist of algorithms that AutoML will ignore for this run.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an `Experiment` in an existing `Workspace`.\n",
"2. Configure AutoML using `AutoMLConfig`.\n",
"3. Train the model.\n",
"4. Explore the results.\n",
"5. Viewing the engineered names for featurized data and featurization summary for all raw features.\n",
"6. Test the best fitted model.\n",
"\n",
"In addition this notebook showcases the following features\n",
"- **Blacklisting** certain pipelines\n",
"- Specifying **target metrics** to indicate stopping criteria\n",
"- Handling **missing data** in the input"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from sklearn import datasets\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# Choose a name for the experiment.\n",
"experiment_name = 'automl-local-missing-data'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"digits = datasets.load_digits()\n",
"X_train = digits.data[10:,:]\n",
"y_train = digits.target[10:]\n",
"\n",
"# Add missing values in 75% of the lines.\n",
"missing_rate = 0.75\n",
"n_missing_samples = int(np.floor(X_train.shape[0] * missing_rate))\n",
"missing_samples = np.hstack((np.zeros(X_train.shape[0] - n_missing_samples, dtype=np.bool), np.ones(n_missing_samples, dtype=np.bool)))\n",
"rng = np.random.RandomState(0)\n",
"rng.shuffle(missing_samples)\n",
"missing_features = rng.randint(0, X_train.shape[1], n_missing_samples)\n",
"X_train[np.where(missing_samples)[0], missing_features] = np.nan"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame(data = X_train)\n",
"df['Label'] = pd.Series(y_train, index=df.index)\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate an `AutoMLConfig` object to specify the settings and data used to run the experiment. This includes setting `experiment_exit_score`, which should cause the run to complete before the `iterations` count is reached.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**preprocess**|Setting this to *True* enables AutoML to perform preprocessing on the input to handle *missing data*, and to perform some common *feature extraction*.|\n",
"|**experiment_exit_score**|*double* value indicating the target for *primary_metric*. <br>Once the target is surpassed the run terminates.|\n",
"|**blacklist_models**|*List* of *strings* indicating machine learning algorithms for AutoML to avoid in this run.<br><br> Allowed values for **Classification**<br><i>LogisticRegression</i><br><i>SGD</i><br><i>MultinomialNaiveBayes</i><br><i>BernoulliNaiveBayes</i><br><i>SVM</i><br><i>LinearSVM</i><br><i>KNN</i><br><i>DecisionTree</i><br><i>RandomForest</i><br><i>ExtremeRandomTrees</i><br><i>LightGBM</i><br><i>GradientBoosting</i><br><i>TensorFlowDNN</i><br><i>TensorFlowLinearClassifier</i><br><br>Allowed values for **Regression**<br><i>ElasticNet</i><br><i>GradientBoosting</i><br><i>DecisionTree</i><br><i>KNN</i><br><i>LassoLars</i><br><i>SGD</i><br><i>RandomForest</i><br><i>ExtremeRandomTrees</i><br><i>LightGBM</i><br><i>TensorFlowLinearRegressor</i><br><i>TensorFlowDNN</i>|\n",
"|**X**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**y**|(sparse) array-like, shape = [n_samples, ], Multi-class targets.|"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" primary_metric = 'AUC_weighted',\n",
" iteration_timeout_minutes = 60,\n",
" iterations = 20,\n",
" preprocess = True,\n",
" experiment_exit_score = 0.9984,\n",
" blacklist_models = ['KNN','LinearSVM'],\n",
" verbosity = logging.INFO,\n",
" X = X_train, \n",
" y = y_train)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output = True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(local_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"#### Retrieve All Child Runs\n",
"You can also use SDK methods to fetch all the child runs and see individual metrics that we log."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"children = list(local_run.get_children())\n",
"metricslist = {}\n",
"for run in children:\n",
" properties = run.get_properties()\n",
" metrics = {k: v for k, v in run.get_metrics().items() if isinstance(v, float)}\n",
" metricslist[int(properties['iteration'])] = metrics\n",
"\n",
"rundata = pd.DataFrame(metricslist).sort_index(1)\n",
"rundata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method returns the best run and the fitted model. The Model includes the pipeline and any pre-processing. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Best Model Based on Any Other Metric\n",
"Show the run and the model which has the smallest `accuracy` value:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# lookup_metric = \"accuracy\"\n",
"# best_run, fitted_model = local_run.get_output(metric = lookup_metric)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Model from a Specific Iteration\n",
"Show the run and the model from the third iteration:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# iteration = 3\n",
"# best_run, fitted_model = local_run.get_output(iteration = iteration)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### View the engineered names for featurized data\n",
"Below we display the engineered feature names generated for the featurized data using the preprocessing featurization."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fitted_model.named_steps['datatransformer'].get_engineered_feature_names()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### View the featurization summary\n",
"Below we display the featurization that was performed on different raw features in the user data. For each raw feature in the user data, the following information is displayed:-\n",
"- Raw feature name\n",
"- Number of engineered features formed out of this raw feature\n",
"- Type detected\n",
"- If feature was dropped\n",
"- List of feature transformations for the raw feature"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get the featurization summary as a list of JSON\n",
"featurization_summary = fitted_model.named_steps['datatransformer'].get_featurization_summary()\n",
"# View the featurization summary as a pandas dataframe\n",
"pd.DataFrame.from_records(featurization_summary)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"digits = datasets.load_digits()\n",
"X_test = digits.data[:10, :]\n",
"y_test = digits.target[:10]\n",
"images = digits.images[:10]\n",
"\n",
"# Randomly select digits and test.\n",
"for index in np.random.choice(len(y_test), 2, replace = False):\n",
" print(index)\n",
" predicted = fitted_model.predict(X_test[index:index + 1])[0]\n",
" label = y_test[index]\n",
" title = \"Label value = %d Predicted value = %d \" % (label, predicted)\n",
" fig = plt.figure(1, figsize=(3,3))\n",
" ax1 = fig.add_axes((0,0,.8,.8))\n",
" ax1.set_title(title)\n",
" plt.imshow(images[index], cmap = plt.cm.gray_r, interpolation = 'nearest')\n",
" plt.show()\n"
]
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,8 +0,0 @@
name: auto-ml-missing-data-blacklist-early-termination
dependencies:
- pip:
- azureml-sdk
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml

View File

@@ -1,593 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/classification-bank-marketing/auto-ml-classification-bank-marketing.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Regression on remote compute using Computer Hardware dataset with model explanations**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Explanations](#Explanations)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"\n",
"In this example we use the Hardware Performance Dataset to showcase how you can use AutoML for a simple regression problem. After training AutoML models for this regression data set, we show how you can compute model explanations on your remote compute using a sample explainer script.\n",
"\n",
"If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, go through the [configuration](../../../configuration.ipynb) notebook first if you haven't already to establish your connection to the AzureML Workspace. \n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an `Experiment` in an existing `Workspace`.\n",
"2. Configure AutoML using `AutoMLConfig`.\n",
"3. Train the model using remote compute.\n",
"4. Explore the results.\n",
"5. Setup remote compute for computing the model explanations for a given AutoML model.\n",
"6. Start an AzureML experiment on your remote compute to compute explanations for an AutoML model.\n",
"7. Download the feature importance for engineered features and visualize the explanations for engineered features. \n",
"8. Download the feature importance for raw features and visualize the explanations for raw features. \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import pandas as pd\n",
"import os\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.dataset import Dataset\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# choose a name for experiment\n",
"experiment_name = 'automl-regression-computer-hardware'\n",
"\n",
"experiment=Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create or Attach existing AmlCompute\n",
"You will need to create a compute target for your AutoML run. In this tutorial, you create AmlCompute as your training compute resource.\n",
"#### 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 on the default limits and how to request more quota."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.compute import AmlCompute\n",
"from azureml.core.compute import ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"automlcl\"\n",
"\n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
" \n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_D2_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 6)\n",
"\n",
" # Create the cluster.\n",
" compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, provisioning_config)\n",
" \n",
"print('Checking cluster status...')\n",
"# Can poll for a minimum number of nodes and for a specific timeout.\n",
"# If no min_node_count is provided, it will use the scale settings for the cluster.\n",
"compute_target.wait_for_completion(show_output = True, min_node_count = None, timeout_in_minutes = 20)\n",
" \n",
"# For a more detailed view of current AmlCompute status, use get_status()."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Conda Dependecies for AutoML training experiment\n",
"\n",
"Create the conda dependencies for running AutoML experiment on remote compute."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.runconfig import RunConfiguration\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"import pkg_resources\n",
"\n",
"# create a new RunConfig object\n",
"conda_run_config = RunConfiguration(framework=\"python\")\n",
"\n",
"# Set compute target to AmlCompute\n",
"conda_run_config.target = compute_target\n",
"conda_run_config.environment.docker.enabled = True\n",
"\n",
"cd = CondaDependencies.create(conda_packages=['numpy','py-xgboost<=0.80'])\n",
"conda_run_config.environment.python.conda_dependencies = cd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setup Training and Test Data for AutoML experiment\n",
"\n",
"Here we create the train and test datasets for hardware performance dataset. We also register the datasets in your workspace using a name so that these datasets may be accessed from the remote compute."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Data source\n",
"data = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/machineData.csv\"\n",
"\n",
"# Create dataset from the url\n",
"dataset = Dataset.Tabular.from_delimited_files(data)\n",
"\n",
"# Split the dataset into train and test datasets\n",
"train_dataset, test_dataset = dataset.random_split(percentage=0.8, seed=223)\n",
"\n",
"# Register the train dataset with your workspace\n",
"train_dataset.register(workspace = ws, name = 'hardware_performance_train_dataset',\n",
" description = 'hardware performance training data',\n",
" create_new_version=True)\n",
"\n",
"# Register the test dataset with your workspace\n",
"test_dataset.register(workspace = ws, name = 'hardware_performance_test_dataset',\n",
" description = 'hardware performance test data',\n",
" create_new_version=True)\n",
"\n",
"# Drop the labeled column from the train dataset\n",
"X_train = train_dataset.drop_columns(columns=['ERP'])\n",
"y_train = train_dataset.keep_columns(columns=['ERP'], validate=True)\n",
"\n",
"# Drop the labeled column from the test dataset\n",
"X_test = test_dataset.drop_columns(columns=['ERP']) \n",
"\n",
"# Display the top rows in the train dataset\n",
"X_train.take(5).to_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate an `AutoMLConfig` object to specify the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**primary_metric**|This is the metric that you want to optimize. Regression supports the following primary metrics: <br><i>spearman_correlation</i><br><i>normalized_root_mean_squared_error</i><br><i>r2_score</i><br><i>normalized_mean_absolute_error</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**X**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**y**|(sparse) array-like, shape = [n_samples, ], targets values.|\n",
"\n",
"**_You can find more information about primary metrics_** [here](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-configure-auto-train#primary-metric)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_settings = {\n",
" \"iteration_timeout_minutes\": 5,\n",
" \"iterations\": 10,\n",
" \"n_cross_validations\": 2,\n",
" \"primary_metric\": 'spearman_correlation',\n",
" \"preprocess\": True,\n",
" \"max_concurrent_iterations\": 1,\n",
" \"verbosity\": logging.INFO,\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task = 'regression',\n",
" debug_log = 'automl_errors_model_exp.log',\n",
" run_configuration=conda_run_config,\n",
" X = X_train,\n",
" y = y_train,\n",
" **automl_settings\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run = experiment.submit(automl_config, show_output = True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(remote_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Explanations\n",
"This section will walk you through the workflow to compute model explanations for an AutoML model on your remote compute.\n",
"\n",
"### Retrieve any AutoML Model for explanations\n",
"\n",
"Below we select the some AutoML pipeline from our iterations. The `get_output` method returns the a AutoML run and the fitted model for the last invocation. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_run, fitted_model = remote_run.get_output(iteration=5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setup model explanation run on the remote compute\n",
"The following section provides details on how to setup an AzureML experiment to run model explanations for an AutoML model on your remote compute."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Sample script used for computing explanations\n",
"View the sample script for computing the model explanations for your AutoML model on remote compute."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open('train_explainer.py', 'r') as cefr:\n",
" print(cefr.read())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Substitute values in your sample script\n",
"The following cell shows how you change the values in the sample script so that you can change the sample script according to your experiment and dataset."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import shutil\n",
"\n",
"# create script folder\n",
"script_folder = './sample_projects/automl-regression-computer-hardware'\n",
"if not os.path.exists(script_folder):\n",
" os.makedirs(script_folder)\n",
"\n",
"# Copy the sample script to script folder.\n",
"shutil.copy('train_explainer.py', script_folder)\n",
"\n",
"# Create the explainer script that will run on the remote compute.\n",
"script_file_name = script_folder + '/train_explainer.py'\n",
"\n",
"# Open the sample script for modification\n",
"with open(script_file_name, 'r') as cefr:\n",
" content = cefr.read()\n",
"\n",
"# Replace the values in train_explainer.py file with the appropriate values\n",
"content = content.replace('<<experimnet_name>>', automl_run.experiment.name) # your experiment name.\n",
"content = content.replace('<<run_id>>', automl_run.id) # Run-id of the AutoML run for which you want to explain the model.\n",
"content = content.replace('<<target_column_name>>', 'ERP') # Your target column name\n",
"content = content.replace('<<task>>', 'regression') # Training task type\n",
"# Name of your training dataset register with your workspace\n",
"content = content.replace('<<train_dataset_name>>', 'hardware_performance_train_dataset') \n",
"# Name of your test dataset register with your workspace\n",
"content = content.replace('<<test_dataset_name>>', 'hardware_performance_test_dataset')\n",
"\n",
"# Write sample file into your script folder.\n",
"with open(script_file_name, 'w') as cefw:\n",
" cefw.write(content)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Create conda configuration for model explanations experiment\n",
"We need `azureml-explain-model`, `azureml-train-automl` and `azureml-core` packages for computing model explanations for your AutoML model on remote compute."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.runconfig import RunConfiguration\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"import pkg_resources\n",
"\n",
"# create a new RunConfig object\n",
"conda_run_config = RunConfiguration(framework=\"python\")\n",
"\n",
"# Set compute target to AmlCompute\n",
"conda_run_config.target = compute_target\n",
"conda_run_config.environment.docker.enabled = True\n",
"azureml_pip_packages = [\n",
" 'azureml-train-automl', 'azureml-core', 'azureml-explain-model'\n",
"]\n",
"\n",
"# specify CondaDependencies obj\n",
"conda_run_config.environment.python.conda_dependencies = CondaDependencies.create(\n",
" conda_packages=['scikit-learn', 'numpy','py-xgboost<=0.80'],\n",
" pip_packages=azureml_pip_packages)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Submit the experiment for model explanations\n",
"Submit the experiment with the above `run_config` and the sample script for computing explanations."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Now submit a run on AmlCompute for model explanations\n",
"from azureml.core.script_run_config import ScriptRunConfig\n",
"\n",
"script_run_config = ScriptRunConfig(source_directory=script_folder,\n",
" script='train_explainer.py',\n",
" run_config=conda_run_config)\n",
"\n",
"run = experiment.submit(script_run_config)\n",
"\n",
"# Show run details\n",
"run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"# Shows output of the run on stdout.\n",
"run.wait_for_completion(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Feature importance and explanation dashboard\n",
"In this section we describe how you can download the explanation results from the explanations experiment and visualize the feature importance for your AutoML model. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Setup for visualizing the model explanation results\n",
"For visualizing the explanation results for the *fitted_model* we need to perform the following steps:-\n",
"1. Featurize test data samples.\n",
"\n",
"The *automl_explainer_setup_obj* contains all the structures from above list. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.train.automl.automl_explain_utilities import AutoMLExplainerSetupClass, automl_setup_model_explanations\n",
"explainer_setup_class = automl_setup_model_explanations(fitted_model, 'regression', X_test=X_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Download engineered feature importance from artifact store\n",
"You can use *ExplanationClient* to download the engineered feature explanations from the artifact store of the *automl_run*. You can also use ExplanationDashboard to view the dash board visualization of the feature importance values of the engineered features."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.explain.model._internal.explanation_client import ExplanationClient\n",
"from azureml.contrib.interpret.visualize import ExplanationDashboard\n",
"client = ExplanationClient.from_run(automl_run)\n",
"engineered_explanations = client.download_model_explanation(raw=False)\n",
"print(engineered_explanations.get_feature_importance_dict())\n",
"ExplanationDashboard(engineered_explanations, explainer_setup_class.automl_estimator, explainer_setup_class.X_test_transform)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Download raw feature importance from artifact store\n",
"You can use *ExplanationClient* to download the raw feature explanations from the artifact store of the *automl_run*. You can also use ExplanationDashboard to view the dash board visualization of the feature importance values of the raw features."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"raw_explanations = client.download_model_explanation(raw=True)\n",
"print(raw_explanations.get_feature_importance_dict())\n",
"ExplanationDashboard(raw_explanations, explainer_setup_class.automl_pipeline, explainer_setup_class.X_test_raw)"
]
}
],
"metadata": {
"authors": [
{
"name": "v-rasav"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,632 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/model-explanation/auto-ml-model-explanation.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Explain classification model, visualize the explanation and operationalize the explainer along with AutoML model**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Explanations](#Explanations)\n",
"1. [Operationailze](#Operationailze)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we use the sklearn's [iris dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_iris.html) to showcase how you can use the AutoML Classifier for a simple classification problem.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you would see\n",
"1. Creating an Experiment in an existing Workspace\n",
"2. Instantiating AutoMLConfig\n",
"3. Training the Model using local compute and explain the model\n",
"4. Visualization model's feature importance in widget\n",
"5. Explore any model's explanation\n",
"6. Operationalize the AutoML model and the explaination model"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created a <b>Workspace</b>. For AutoML you would need to create an <b>Experiment</b>. An <b>Experiment</b> is a named object in a <b>Workspace</b>, which is used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"import pandas as pd\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.train.automl import AutoMLConfig\n",
"from azureml.core.dataset import Dataset\n",
"from azureml.explain.model._internal.explanation_client import ExplanationClient"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# choose a name for experiment\n",
"experiment_name = 'automl-model-explanation'\n",
"\n",
"experiment=Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Training Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"train_data = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/bankmarketing_train.csv\"\n",
"train_dataset = Dataset.Tabular.from_delimited_files(train_data)\n",
"X_train = train_dataset.drop_columns(columns=['y']).to_pandas_dataframe()\n",
"y_train = train_dataset.keep_columns(columns=['y'], validate=True).to_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Test Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"test_data = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/bankmarketing_test.csv\"\n",
"test_dataset = Dataset.Tabular.from_delimited_files(test_data)\n",
"X_test = test_dataset.drop_columns(columns=['y']).to_pandas_dataframe()\n",
"y_test = test_dataset.keep_columns(columns=['y'], validate=True).to_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate a AutoMLConfig object. This defines the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**max_time_sec**|Time limit in minutes for each iterations|\n",
"|**iterations**|Number of iterations. In each iteration Auto ML trains the data with a specific pipeline|\n",
"|**X**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**y**|(sparse) array-like, shape = [n_samples, ], Multi-class targets.|\n",
"|**model_explainability**|Indicate to explain each trained pipeline or not |"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" primary_metric = 'AUC_weighted',\n",
" iteration_timeout_minutes = 200,\n",
" iterations = 10,\n",
" verbosity = logging.INFO,\n",
" preprocess = True,\n",
" X = X_train, \n",
" y = y_train,\n",
" n_cross_validations = 5,\n",
" model_explainability=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can call the submit method on the experiment object and pass the run configuration. For Local runs the execution is synchronous. Depending on the data and number of iterations this can run for while.\n",
"You will see the currently running iterations printing to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Widget for monitoring runs\n",
"\n",
"The widget will sit on \"loading\" until the first iteration completed, then you will see an auto-updating graph and table show up. It refreshed once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"NOTE: The widget displays a link at the bottom. This links to a web-ui to explore the individual run details."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(local_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The *get_output* method on automl_classifier returns the best run and the fitted model for the last *fit* invocation. There are overloads on *get_output* that allow you to retrieve the best run and fitted model for *any* logged metric or a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Best Model 's explanation\n",
"\n",
"Retrieve the explanation from the *best_run* which includes explanations for engineered features and raw features."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Download engineered feature importance from artifact store\n",
"You can use *ExplanationClient* to download the engineered feature explanations from the artifact store of the *best_run*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client = ExplanationClient.from_run(best_run)\n",
"engineered_explanations = client.download_model_explanation(raw=False)\n",
"print(engineered_explanations.get_feature_importance_dict())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Download raw feature importance from artifact store\n",
"You can use *ExplanationClient* to download the raw feature explanations from the artifact store of the *best_run*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client = ExplanationClient.from_run(best_run)\n",
"raw_explanations = client.download_model_explanation(raw=True)\n",
"print(raw_explanations.get_feature_importance_dict())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Explanations\n",
"In this section, we will show how to compute model explanations and visualize the explanations using azureml-explain-model package. Besides retrieving an existing model explanation for an AutoML model, you can also explain your AutoML model with different test data. The following steps will allow you to compute and visualize engineered feature importance and raw feature importance based on your test data. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Retrieve any other AutoML model from training"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_run, fitted_model = local_run.get_output(iteration=0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Setup the model explanations for AutoML models\n",
"The *fitted_model* can generate the following which will be used for getting the engineered and raw feature explanations using *automl_setup_model_explanations*:-\n",
"1. Featurized data from train samples/test samples \n",
"2. Gather engineered and raw feature name lists\n",
"3. Find the classes in your labeled column in classification scenarios\n",
"\n",
"The *automl_explainer_setup_obj* contains all the structures from above list. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.train.automl.automl_explain_utilities import AutoMLExplainerSetupClass, automl_setup_model_explanations\n",
"\n",
"automl_explainer_setup_obj = automl_setup_model_explanations(fitted_model, X=X_train, \n",
" X_test=X_test, y=y_train, \n",
" task='classification')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Initialize the Mimic Explainer for feature importance\n",
"For explaining the AutoML models, use the *MimicWrapper* from *azureml.explain.model* package. The *MimicWrapper* can be initialized with fields in *automl_explainer_setup_obj*, your workspace and a LightGBM model which acts as a surrogate model to explain the AutoML model (*fitted_model* here). The *MimicWrapper* also takes the *automl_run* object where the raw and engineered explanations will be uploaded."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.explain.model.mimic.models.lightgbm_model import LGBMExplainableModel\n",
"from azureml.explain.model.mimic_wrapper import MimicWrapper\n",
"explainer = MimicWrapper(ws, automl_explainer_setup_obj.automl_estimator, LGBMExplainableModel, \n",
" init_dataset=automl_explainer_setup_obj.X_transform, run=automl_run,\n",
" features=automl_explainer_setup_obj.engineered_feature_names, \n",
" feature_maps=[automl_explainer_setup_obj.feature_map],\n",
" classes=automl_explainer_setup_obj.classes)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Use Mimic Explainer for computing and visualizing engineered feature importance\n",
"The *explain()* method in *MimicWrapper* can be called with the transformed test samples to get the feature importance for the generated engineered features. You can also use *ExplanationDashboard* to view the dash board visualization of the feature importance values of the generated engineered features by AutoML featurizers."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"engineered_explanations = explainer.explain(['local', 'global'], eval_dataset=automl_explainer_setup_obj.X_test_transform)\n",
"print(engineered_explanations.get_feature_importance_dict())\n",
"from azureml.contrib.interpret.visualize import ExplanationDashboard\n",
"ExplanationDashboard(engineered_explanations, automl_explainer_setup_obj.automl_estimator, automl_explainer_setup_obj.X_test_transform)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Use Mimic Explainer for computing and visualizing raw feature importance\n",
"The *explain()* method in *MimicWrapper* can be again called with the transformed test samples and setting *get_raw* to *True* to get the feature importance for the raw features. You can also use *ExplanationDashboard* to view the dash board visualization of the feature importance values of the raw features."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"raw_explanations = explainer.explain(['local', 'global'], get_raw=True, \n",
" raw_feature_names=automl_explainer_setup_obj.raw_feature_names,\n",
" eval_dataset=automl_explainer_setup_obj.X_test_transform)\n",
"print(raw_explanations.get_feature_importance_dict())\n",
"from azureml.contrib.interpret.visualize import ExplanationDashboard\n",
"ExplanationDashboard(raw_explanations, automl_explainer_setup_obj.automl_pipeline, automl_explainer_setup_obj.X_test_raw)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Operationailze\n",
"In this section we will show how you can operationalize an AutoML model and the explainer which was used to compute the explanations in the previous section.\n",
"\n",
"#### Register the AutoML model and the scoring explainer\n",
"We use the *TreeScoringExplainer* from *azureml.explain.model* package to create the scoring explainer which will be used to compute the raw and engineered feature importances at the inference time. Note that, we initialize the scoring explainer with the *feature_map* that was computed previously. The *feature_map* will be used by the scoring explainer to return the raw feature importance.\n",
"\n",
"In the cell below, we pickle the scoring explainer and register the AutoML model and the scoring explainer with the Model Management Service."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.explain.model.scoring.scoring_explainer import TreeScoringExplainer, save\n",
"\n",
"# Initialize the ScoringExplainer\n",
"scoring_explainer = TreeScoringExplainer(explainer.explainer, feature_maps=[automl_explainer_setup_obj.feature_map])\n",
"\n",
"# Pickle scoring explainer locally\n",
"save(scoring_explainer, exist_ok=True)\n",
"\n",
"# Register trained automl model present in the 'outputs' folder in the artifacts\n",
"original_model = automl_run.register_model(model_name='automl_model', \n",
" model_path='outputs/model.pkl')\n",
"\n",
"# Register scoring explainer\n",
"automl_run.upload_file('scoring_explainer.pkl', 'scoring_explainer.pkl')\n",
"scoring_explainer_model = automl_run.register_model(model_name='scoring_explainer', model_path='scoring_explainer.pkl')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Create the conda dependencies for setting up the service\n",
"We need to create the conda dependencies comprising of the *azureml-explain-model*, *azureml-train-automl* and *azureml-defaults* packages. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.conda_dependencies import CondaDependencies \n",
"\n",
"azureml_pip_packages = [\n",
" 'azureml-explain-model', 'azureml-train-automl', 'azureml-defaults'\n",
"]\n",
" \n",
"\n",
"# specify CondaDependencies obj\n",
"myenv = CondaDependencies.create(conda_packages=['scikit-learn', 'pandas', 'numpy', 'py-xgboost<=0.80'],\n",
" pip_packages=azureml_pip_packages,\n",
" pin_sdk_version=True)\n",
"\n",
"with open(\"myenv.yml\",\"w\") as f:\n",
" f.write(myenv.serialize_to_string())\n",
"\n",
"with open(\"myenv.yml\",\"r\") as f:\n",
" print(f.read())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### View your scoring file"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open(\"score_local_explain.py\",\"r\") as f:\n",
" print(f.read())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Deploy the service\n",
"In the cell below, we deploy the service using the conda file and the scoring file from the previous steps. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.webservice import Webservice\n",
"from azureml.core.model import InferenceConfig\n",
"from azureml.core.webservice import AciWebservice\n",
"from azureml.core.model import Model\n",
"\n",
"aciconfig = AciWebservice.deploy_configuration(cpu_cores=1, \n",
" memory_gb=1, \n",
" tags={\"data\": \"Bank Marketing\", \n",
" \"method\" : \"local_explanation\"}, \n",
" description='Get local explanations for Bank marketing test data')\n",
"\n",
"inference_config = InferenceConfig(runtime= \"python\", \n",
" entry_script=\"score_local_explain.py\",\n",
" conda_file=\"myenv.yml\")\n",
"\n",
"# Use configs and models generated above\n",
"service = Model.deploy(ws, 'model-scoring', [scoring_explainer_model, original_model], inference_config, aciconfig)\n",
"service.wait_for_deployment(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### View the service logs"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"service.get_logs()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Inference using some test data\n",
"Inference using some test data to see the predicted value from autml model, view the engineered feature importance for the predicted value and raw feature importance for the predicted value."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if service.state == 'Healthy':\n",
" # Serialize the first row of the test data into json\n",
" X_test_json = X_test[:1].to_json(orient='records')\n",
" print(X_test_json)\n",
" # Call the service to get the predictions and the engineered and raw explanations\n",
" output = service.run(X_test_json)\n",
" # Print the predicted value\n",
" print(output['predictions'])\n",
" # Print the engineered feature importances for the predicted value\n",
" print(output['engineered_local_importance_values'])\n",
" # Print the raw feature importances for the predicted value\n",
" print(output['raw_local_importance_values'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Delete the service\n",
"Delete the service once you have finished inferencing."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"service.delete()"
]
}
],
"metadata": {
"authors": [
{
"name": "xif"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,11 +0,0 @@
name: auto-ml-model-explanation
dependencies:
- pip:
- azureml-sdk
- interpret
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml
- azureml-explain-model
- azureml-contrib-interpret

View File

@@ -713,6 +713,22 @@
"name": "v-rasav"
}
],
"category": "tutorial",
"compute": [
"AML Compute"
],
"datasets": [
"Concrete"
],
"deployment": [
"Azure Container Instance"
],
"exclude_from_index": false,
"framework": [
"Azure ML AutoML"
],
"friendly_name": "Regression with deployment using concrete dataset",
"index_order": 1,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -729,7 +745,11 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
}
},
"tags": [
""
],
"task": "Regression"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -0,0 +1,995 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/regression-car-price-model-explaination-and-featurization/auto-ml-regression.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Regression with Aml Compute**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Test](#Test)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we use the Hardware Performance Dataset to showcase how you can use AutoML for a simple regression problem. The Regression goal is to predict the performance of certain combinations of hardware parts.\n",
"After training AutoML models for this regression data set, we show how you can compute model explanations on your remote compute using a sample explainer script.\n",
"\n",
"If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, go through the [configuration](../../../configuration.ipynb) notebook first if you haven't already to establish your connection to the AzureML Workspace. \n",
"\n",
"An Enterprise workspace is required for this notebook. To learn more about creating an Enterprise workspace or upgrading to an Enterprise workspace from the Azure portal, please visit our [Workspace page.](https://docs.microsoft.com/azure/machine-learning/service/concept-workspace#upgrade) \n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an `Experiment` in an existing `Workspace`.\n",
"2. Instantiating AutoMLConfig with FeaturizationConfig for customization\n",
"3. Train the model using remote compute.\n",
"4. Explore the results and featurization transparency options\n",
"5. Setup remote compute for computing the model explanations for a given AutoML model.\n",
"6. Start an AzureML experiment on your remote compute to compute explanations for an AutoML model.\n",
"7. Download the feature importance for engineered features and visualize the explanations for engineered features. \n",
"8. Download the feature importance for raw features and visualize the explanations for raw features. \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"import azureml.dataprep as dprep\n",
"from azureml.automl.core.featurization import FeaturizationConfig\n",
"from azureml.train.automl import AutoMLConfig\n",
"from azureml.core.dataset import Dataset"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# Choose a name for the experiment.\n",
"experiment_name = 'automl-regression-hardware-explain'\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create or Attach existing AmlCompute\n",
"You will need to create a [compute target](https://docs.microsoft.com/azure/machine-learning/service/concept-azure-machine-learning-architecture#compute-target) for your AutoML run. In this tutorial, you create `AmlCompute` as your training compute resource.\n",
"\n",
"**Creation of AmlCompute takes approximately 5 minutes.** If the AmlCompute with that name is already in your workspace this code will skip the creation process.\n",
"\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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.compute import AmlCompute\n",
"from azureml.core.compute import ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"cpu-cluster-5\"\n",
"\n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
"\n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_D2_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 4)\n",
"\n",
" # Create the cluster.\\n\",\n",
" compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, provisioning_config)\n",
"\n",
"print('Checking cluster status...')\n",
"# Can poll for a minimum number of nodes and for a specific timeout.\n",
"# If no min_node_count is provided, it will use the scale settings for the cluster.\n",
"compute_target.wait_for_completion(show_output = True, min_node_count = None, timeout_in_minutes = 20)\n",
"\n",
"# For a more detailed view of current AmlCompute status, use get_status()."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setup Training and Test Data for AutoML experiment\n",
"\n",
"Load the hardware dataset from a csv file containing both training features and labels. The features are inputs to the model, while the training labels represent the expected output of the model. Next, we'll split the data using random_split and extract the training data for the model. We also register the datasets in your workspace using a name so that these datasets may be accessed from the remote compute."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data = 'https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/machineData.csv'\n",
"\n",
"dataset = Dataset.Tabular.from_delimited_files(data)\n",
"\n",
"# Split the dataset into train and test datasets\n",
"train_data, test_data = dataset.random_split(percentage=0.8, seed=223)\n",
"\n",
"\n",
"# Register the train dataset with your workspace\n",
"train_data.register(workspace = ws, name = 'machineData_train_dataset',\n",
" description = 'hardware performance training data',\n",
" create_new_version=True)\n",
"\n",
"# Register the test dataset with your workspace\n",
"test_data.register(workspace = ws, name = 'machineData_test_dataset', description = 'hardware performance test data', create_new_version=True)\n",
"\n",
"label =\"ERP\"\n",
"\n",
"train_data.to_pandas_dataframe().head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate an `AutoMLConfig` object to specify the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification, regression or forecasting|\n",
"|**primary_metric**|This is the metric that you want to optimize. Regression supports the following primary metrics: <br><i>spearman_correlation</i><br><i>normalized_root_mean_squared_error</i><br><i>r2_score</i><br><i>normalized_mean_absolute_error</i>|\n",
"|**experiment_timeout_minutes**| Maximum amount of time in minutes that all iterations combined can take before the experiment terminates.|\n",
"|**enable_early_stopping**| Flag to enble early termination if the score is not improving in the short term.|\n",
"|**featurization**| 'auto' / 'off' / FeaturizationConfig Indicator for whether featurization step should be done automatically or not, or whether customized featurization should be used. Note: If the input data is sparse, featurization cannot be turned on.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**training_data**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**label_column_name**|(sparse) array-like, shape = [n_samples, ], targets values.|"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Customization\n",
"\n",
"This step requires an Enterprise workspace to gain access to this feature. To learn more about creating an Enterprise workspace or upgrading to an Enterprise workspace from the Azure portal, please visit our [Workspace page.](https://docs.microsoft.com/azure/machine-learning/service/concept-workspace#upgrade). \n",
"\n",
"Supported customization includes:\n",
"1. Column purpose update: Override feature type for the specified column.\n",
"2. Transformer parameter update: Update parameters for the specified transformer. Currently supports Imputer and HashOneHotEncoder.\n",
"3. Drop columns: Columns to drop from being featurized.\n",
"4. Block transformers: Allow/Block transformers to be used on featurization process."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create FeaturizationConfig object using API calls"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"featurization_config = FeaturizationConfig()\n",
"featurization_config.blocked_transformers = ['LabelEncoder']\n",
"#featurization_config.drop_columns = ['ERP', 'MMIN']\n",
"featurization_config.add_column_purpose('MYCT', 'Numeric')\n",
"featurization_config.add_column_purpose('VendorName', 'CategoricalHash')\n",
"#default strategy mean, add transformer param for for 3 columns\n",
"featurization_config.add_transformer_params('Imputer', ['CACH'], {\"strategy\": \"median\"})\n",
"featurization_config.add_transformer_params('Imputer', ['CHMIN'], {\"strategy\": \"median\"})\n",
"featurization_config.add_transformer_params('Imputer', ['PRP'], {\"strategy\": \"most_frequent\"})\n",
"#featurization_config.add_transformer_params('HashOneHotEncoder', [], {\"number_of_bits\": 3})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_settings = {\n",
" \"enable_early_stopping\": True, \n",
" \"experiment_timeout_minutes\" : 10,\n",
" \"max_concurrent_iterations\": 4,\n",
" \"max_cores_per_iteration\": -1,\n",
" \"n_cross_validations\": 5,\n",
" \"primary_metric\": 'normalized_root_mean_squared_error',\n",
" \"verbosity\": logging.INFO\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task = 'regression',\n",
" debug_log = 'automl_errors.log',\n",
" compute_target=compute_target,\n",
" featurization=featurization_config,\n",
" training_data = train_data,\n",
" label_column_name = label,\n",
" **automl_settings\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run = experiment.submit(automl_config, show_output = False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Run the following cell to access previous runs. Uncomment the cell below and update the run_id."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#from azureml.train.automl.run import AutoMLRun\n",
"#experiment_name = 'automl-regression-hardware'\n",
"#experiment = Experiment(ws, experiment_name)\n",
"#remote_run = AutoMLRun(experiment=experiment, run_id='<run_ID_goes_here')\n",
"#remote_run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run.wait_for_completion()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = remote_run.get_output()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run_customized, fitted_model_customized = remote_run.get_output()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Transparency\n",
"\n",
"View updated featurization summary"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"custom_featurizer = fitted_model_customized.named_steps['datatransformer']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"custom_featurizer.get_featurization_summary()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"is_user_friendly=False allows for more detailed summary for transforms being applied"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"custom_featurizer.get_featurization_summary(is_user_friendly=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"custom_featurizer.get_stats_feature_type_summary()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(remote_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Explanations\n",
"This step requires an Enterprise workspace to gain access to this feature. To learn more about creating an Enterprise workspace or upgrading to an Enterprise workspace from the Azure portal, please visit our [Workspace page.](https://docs.microsoft.com/azure/machine-learning/service/concept-workspace#upgrade). \n",
"This section will walk you through the workflow to compute model explanations for an AutoML model on your remote compute.\n",
"\n",
"### Retrieve any AutoML Model for explanations\n",
"\n",
"Below we select the some AutoML pipeline from our iterations. The `get_output` method returns the a AutoML run and the fitted model for the last invocation. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_run, fitted_model = remote_run.get_output(metric='r2_score')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setup model explanation run on the remote compute\n",
"The following section provides details on how to setup an AzureML experiment to run model explanations for an AutoML model on your remote compute."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Sample script used for computing explanations\n",
"View the sample script for computing the model explanations for your AutoML model on remote compute."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open('train_explainer.py', 'r') as cefr:\n",
" print(cefr.read())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Substitute values in your sample script\n",
"The following cell shows how you change the values in the sample script so that you can change the sample script according to your experiment and dataset."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import shutil\n",
"import os\n",
"\n",
"# create script folder\n",
"script_folder = './sample_projects/automl-regression-hardware'\n",
"if not os.path.exists(script_folder):\n",
" os.makedirs(script_folder)\n",
"\n",
"# Copy the sample script to script folder.\n",
"shutil.copy('train_explainer.py', script_folder)\n",
"\n",
"# Create the explainer script that will run on the remote compute.\n",
"script_file_name = script_folder + '/train_explainer.py'\n",
"\n",
"# Open the sample script for modification\n",
"with open(script_file_name, 'r') as cefr:\n",
" content = cefr.read()\n",
"\n",
"# Replace the values in train_explainer.py file with the appropriate values\n",
"content = content.replace('<<experimnet_name>>', automl_run.experiment.name) # your experiment name.\n",
"content = content.replace('<<run_id>>', automl_run.id) # Run-id of the AutoML run for which you want to explain the model.\n",
"content = content.replace('<<target_column_name>>', 'ERP') # Your target column name\n",
"content = content.replace('<<task>>', 'regression') # Training task type\n",
"# Name of your training dataset register with your workspace\n",
"content = content.replace('<<train_dataset_name>>', 'machineData_train_dataset') \n",
"# Name of your test dataset register with your workspace\n",
"content = content.replace('<<test_dataset_name>>', 'machineData_test_dataset')\n",
"\n",
"# Write sample file into your script folder.\n",
"with open(script_file_name, 'w') as cefw:\n",
" cefw.write(content)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Create conda configuration for model explanations experiment\n",
"We need `azureml-explain-model`, `azureml-train-automl` and `azureml-core` packages for computing model explanations for your AutoML model on remote compute."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.runconfig import RunConfiguration\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"import pkg_resources\n",
"\n",
"# create a new RunConfig object\n",
"conda_run_config = RunConfiguration(framework=\"python\")\n",
"\n",
"# Set compute target to AmlCompute\n",
"conda_run_config.target = compute_target\n",
"conda_run_config.environment.docker.enabled = True\n",
"azureml_pip_packages = [\n",
" 'azureml-train-automl', 'azureml-core', 'azureml-explain-model'\n",
"]\n",
"\n",
"# specify CondaDependencies obj\n",
"conda_run_config.environment.python.conda_dependencies = CondaDependencies.create(\n",
" conda_packages=['scikit-learn', 'numpy','py-xgboost<=0.80'],\n",
" pip_packages=azureml_pip_packages)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Submit the experiment for model explanations\n",
"Submit the experiment with the above `run_config` and the sample script for computing explanations."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Now submit a run on AmlCompute for model explanations\n",
"from azureml.core.script_run_config import ScriptRunConfig\n",
"\n",
"script_run_config = ScriptRunConfig(source_directory=script_folder,\n",
" script='train_explainer.py',\n",
" run_config=conda_run_config)\n",
"\n",
"run = experiment.submit(script_run_config)\n",
"\n",
"# Show run details\n",
"run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"# Shows output of the run on stdout.\n",
"run.wait_for_completion(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Feature importance and explanation dashboard\n",
"In this section we describe how you can download the explanation results from the explanations experiment and visualize the feature importance for your AutoML model. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Setup for visualizing the model explanation results\n",
"For visualizing the explanation results for the *fitted_model* we need to perform the following steps:-\n",
"1. Featurize test data samples.\n",
"\n",
"The *automl_explainer_setup_obj* contains all the structures from above list. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"X_test = test_data.drop_columns([label]).to_pandas_dataframe()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.train.automl.automl_explain_utilities import AutoMLExplainerSetupClass, automl_setup_model_explanations\n",
"explainer_setup_class = automl_setup_model_explanations(fitted_model, 'regression', X_test=X_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Download engineered feature importance from artifact store\n",
"You can use *ExplanationClient* to download the engineered feature explanations from the artifact store of the *automl_run*. You can also use ExplanationDashboard to view the dash board visualization of the feature importance values of the engineered features."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.explain.model._internal.explanation_client import ExplanationClient\n",
"from azureml.contrib.interpret.visualize import ExplanationDashboard\n",
"client = ExplanationClient.from_run(automl_run)\n",
"engineered_explanations = client.download_model_explanation(raw=False)\n",
"print(engineered_explanations.get_feature_importance_dict())\n",
"ExplanationDashboard(engineered_explanations, explainer_setup_class.automl_estimator, explainer_setup_class.X_test_transform)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Download raw feature importance from artifact store\n",
"You can use *ExplanationClient* to download the raw feature explanations from the artifact store of the *automl_run*. You can also use ExplanationDashboard to view the dash board visualization of the feature importance values of the raw features."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"raw_explanations = client.download_model_explanation(raw=True)\n",
"print(raw_explanations.get_feature_importance_dict())\n",
"ExplanationDashboard(raw_explanations, explainer_setup_class.automl_pipeline, explainer_setup_class.X_test_raw)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Operationailze\n",
"In this section we will show how you can operationalize an AutoML model and the explainer which was used to compute the explanations in the previous section.\n",
"\n",
"### Register the AutoML model and the scoring explainer\n",
"We use the *TreeScoringExplainer* from *azureml.explain.model* package to create the scoring explainer which will be used to compute the raw and engineered feature importances at the inference time. \n",
"In the cell below, we register the AutoML model and the scoring explainer with the Model Management Service."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Register trained automl model present in the 'outputs' folder in the artifacts\n",
"original_model = automl_run.register_model(model_name='automl_model', \n",
" model_path='outputs/model.pkl')\n",
"scoring_explainer_model = automl_run.register_model(model_name='scoring_explainer',\n",
" model_path='outputs/scoring_explainer.pkl')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create the conda dependencies for setting up the service\n",
"We need to create the conda dependencies comprising of the *azureml-explain-model*, *azureml-train-automl* and *azureml-defaults* packages. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.conda_dependencies import CondaDependencies \n",
"\n",
"azureml_pip_packages = [\n",
" 'azureml-explain-model', 'azureml-train-automl', 'azureml-defaults'\n",
"]\n",
" \n",
"\n",
"# specify CondaDependencies obj\n",
"myenv = CondaDependencies.create(conda_packages=['scikit-learn', 'pandas', 'numpy', 'py-xgboost<=0.80'],\n",
" pip_packages=azureml_pip_packages,\n",
" pin_sdk_version=True)\n",
"\n",
"with open(\"myenv.yml\",\"w\") as f:\n",
" f.write(myenv.serialize_to_string())\n",
"\n",
"with open(\"myenv.yml\",\"r\") as f:\n",
" print(f.read())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### View your scoring file"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open(\"score_explain.py\",\"r\") as f:\n",
" print(f.read())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Deploy the service\n",
"In the cell below, we deploy the service using the conda file and the scoring file from the previous steps. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.webservice import Webservice\n",
"from azureml.core.model import InferenceConfig\n",
"from azureml.core.webservice import AciWebservice\n",
"from azureml.core.model import Model\n",
"\n",
"aciconfig = AciWebservice.deploy_configuration(cpu_cores=1, \n",
" memory_gb=1, \n",
" tags={\"data\": \"Machine Data\", \n",
" \"method\" : \"local_explanation\"}, \n",
" description='Get local explanations for Machine test data')\n",
"\n",
"inference_config = InferenceConfig(runtime= \"python\", \n",
" entry_script=\"score_explain.py\",\n",
" conda_file=\"myenv.yml\")\n",
"\n",
"# Use configs and models generated above\n",
"service = Model.deploy(ws, 'model-scoring', [scoring_explainer_model, original_model], inference_config, aciconfig)\n",
"service.wait_for_deployment(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### View the service logs"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"service.get_logs()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Inference using some test data\n",
"Inference using some test data to see the predicted value from autml model, view the engineered feature importance for the predicted value and raw feature importance for the predicted value."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if service.state == 'Healthy':\n",
" # Serialize the first row of the test data into json\n",
" X_test_json = X_test[:1].to_json(orient='records')\n",
" print(X_test_json)\n",
" # Call the service to get the predictions and the engineered and raw explanations\n",
" output = service.run(X_test_json)\n",
" # Print the predicted value\n",
" print(output['predictions'])\n",
" # Print the engineered feature importances for the predicted value\n",
" print(output['engineered_local_importance_values'])\n",
" # Print the raw feature importances for the predicted value\n",
" print(output['raw_local_importance_values'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Delete the service\n",
"Delete the service once you have finished inferencing."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"service.delete()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# preview the first 3 rows of the dataset\n",
"\n",
"test_data = test_data.to_pandas_dataframe()\n",
"y_test = test_data['ERP'].fillna(0)\n",
"test_data = test_data.drop('ERP', 1)\n",
"test_data = test_data.fillna(0)\n",
"\n",
"\n",
"train_data = train_data.to_pandas_dataframe()\n",
"y_train = train_data['ERP'].fillna(0)\n",
"train_data = train_data.drop('ERP', 1)\n",
"train_data = train_data.fillna(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"y_pred_train = fitted_model.predict(train_data)\n",
"y_residual_train = y_train - y_pred_train\n",
"\n",
"y_pred_test = fitted_model.predict(test_data)\n",
"y_residual_test = y_test - y_pred_test"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"from sklearn.metrics import mean_squared_error, r2_score\n",
"\n",
"# Set up a multi-plot chart.\n",
"f, (a0, a1) = plt.subplots(1, 2, gridspec_kw = {'width_ratios':[1, 1], 'wspace':0, 'hspace': 0})\n",
"f.suptitle('Regression Residual Values', fontsize = 18)\n",
"f.set_figheight(6)\n",
"f.set_figwidth(16)\n",
"\n",
"# Plot residual values of training set.\n",
"a0.axis([0, 360, -100, 100])\n",
"a0.plot(y_residual_train, 'bo', alpha = 0.5)\n",
"a0.plot([-10,360],[0,0], 'r-', lw = 3)\n",
"a0.text(16,170,'RMSE = {0:.2f}'.format(np.sqrt(mean_squared_error(y_train, y_pred_train))), fontsize = 12)\n",
"a0.text(16,140,'R2 score = {0:.2f}'.format(r2_score(y_train, y_pred_train)),fontsize = 12)\n",
"a0.set_xlabel('Training samples', fontsize = 12)\n",
"a0.set_ylabel('Residual Values', fontsize = 12)\n",
"\n",
"# Plot residual values of test set.\n",
"a1.axis([0, 90, -100, 100])\n",
"a1.plot(y_residual_test, 'bo', alpha = 0.5)\n",
"a1.plot([-10,360],[0,0], 'r-', lw = 3)\n",
"a1.text(5,170,'RMSE = {0:.2f}'.format(np.sqrt(mean_squared_error(y_test, y_pred_test))), fontsize = 12)\n",
"a1.text(5,140,'R2 score = {0:.2f}'.format(r2_score(y_test, y_pred_test)),fontsize = 12)\n",
"a1.set_xlabel('Test samples', fontsize = 12)\n",
"a1.set_yticklabels([])\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"test_pred = plt.scatter(y_test, y_pred_test, color='')\n",
"test_test = plt.scatter(y_test, y_test, color='g')\n",
"plt.legend((test_pred, test_test), ('prediction', 'truth'), loc='upper left', fontsize=8)\n",
"plt.show()"
]
}
],
"metadata": {
"authors": [
{
"name": "anumamah"
}
],
"categories": [
"how-to-use-azureml",
"automated-machine-learning"
],
"category": "tutorial",
"compute": [
"AML"
],
"datasets": [
"MachineData"
],
"deployment": [
"ACI"
],
"exclude_from_index": false,
"framework": [
"None"
],
"friendly_name": "Automated ML run with featurization and model explainability.",
"index_order": 5,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
},
"tags": [
"featurization",
"explainability",
"remote_run",
"AutomatedML"
],
"task": "Regression"
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,8 +1,10 @@
name: auto-ml-model-explanations-remote-compute
name: auto-ml-regression-hardware-performance-explanation-and-featurization
dependencies:
- pip:
- azureml-sdk
- interpret
- azureml-defaults
- azureml-explain-model
- azureml-train-automl
- azureml-widgets
- matplotlib

View File

@@ -31,7 +31,7 @@ def run(raw_data):
predictions = automl_model.predict(data)
# Setup for inferencing explanations
automl_explainer_setup_obj = automl_setup_model_explanations(automl_model,
X_test=data, task='classification')
X_test=data, task='regression')
# Retrieve model explanations for engineered explanations
engineered_local_importance_values = scoring_explainer.explain(automl_explainer_setup_obj.X_test_transform)
# Retrieve model explanations for raw explanations

View File

@@ -10,6 +10,7 @@ from azureml.train.automl.automl_explain_utilities import AutoMLExplainerSetupCl
from azureml.explain.model.mimic.models.lightgbm_model import LGBMExplainableModel
from azureml.explain.model.mimic_wrapper import MimicWrapper
from automl.client.core.common.constants import MODEL_PATH
from azureml.explain.model.scoring.scoring_explainer import TreeScoringExplainer, save
OUTPUT_DIR = './outputs/'
@@ -62,3 +63,13 @@ raw_explanations = explainer.explain(['local', 'global'], get_raw=True,
eval_dataset=automl_explainer_setup_obj.X_test_transform)
print("Engineered and raw explanations computed successfully")
# Initialize the ScoringExplainer
scoring_explainer = TreeScoringExplainer(explainer.explainer, feature_maps=[automl_explainer_setup_obj.feature_map])
# Pickle scoring explainer locally
save(scoring_explainer, exist_ok=True)
# Upload the scoring explainer to the automl run
automl_run.upload_file('outputs/scoring_explainer.pkl', 'scoring_explainer.pkl')

View File

@@ -715,6 +715,22 @@
"name": "v-rasav"
}
],
"category": "tutorial",
"compute": [
"AML Compute"
],
"datasets": [
"Concrete"
],
"deployment": [
"Azure Container Instance"
],
"exclude_from_index": false,
"framework": [
"Azure ML AutoML"
],
"friendly_name": "Regression with deployment using hardware performance dataset",
"index_order": 1,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -731,7 +747,14 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
}
},
"star_tag": [
"featured"
],
"tags": [
""
],
"task": "Regression"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -21,7 +21,7 @@
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Regression with Local Compute**_\n",
"_**Regression with Aml Compute**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
@@ -29,7 +29,8 @@
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Test](#Test)\n"
"1. [Test](#Test)\n",
"\n"
]
},
{
@@ -37,9 +38,9 @@
"metadata": {},
"source": [
"## Introduction\n",
"In this example we use the scikit-learn's [diabetes dataset](http://scikit-learn.org/stable/datasets/index.html#diabetes-dataset) to showcase how you can use AutoML for a simple regression problem.\n",
"In this example we use the Hardware Performance Dataset to showcase how you can use AutoML for a simple regression problem. The Regression goal is to predict the performance of certain combinations of hardware parts.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, go through the [configuration](../../../configuration.ipynb) notebook first if you haven't already to establish your connection to the AzureML Workspace. \n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an `Experiment` in an existing `Workspace`.\n",
@@ -55,7 +56,7 @@
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
"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."
]
},
{
@@ -69,10 +70,12 @@
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
" \n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.dataset import Dataset\n",
"from azureml.train.automl import AutoMLConfig"
]
},
@@ -85,17 +88,17 @@
"ws = Workspace.from_config()\n",
"\n",
"# Choose a name for the experiment.\n",
"experiment_name = 'automl-local-regression'\n",
"experiment_name = 'automl-regression'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Workspace'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"output['Run History Name'] = experiment_name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
@@ -105,8 +108,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"This uses scikit-learn's [load_diabetes](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_diabetes.html) method."
"### Using AmlCompute\n",
"You will need to create a [compute target](https://docs.microsoft.com/azure/machine-learning/service/concept-azure-machine-learning-architecture#compute-target) for your AutoML run. In this tutorial, you use `AmlCompute` as your training compute resource."
]
},
{
@@ -115,15 +118,52 @@
"metadata": {},
"outputs": [],
"source": [
"# Load the diabetes dataset, a well-known built-in small dataset that comes with scikit-learn.\n",
"from sklearn.datasets import load_diabetes\n",
"from sklearn.model_selection import train_test_split\n",
"from azureml.core.compute import ComputeTarget, AmlCompute\n",
"from azureml.core.compute_target import ComputeTargetException\n",
"\n",
"X, y = load_diabetes(return_X_y = True)\n",
"# Choose a name for your CPU cluster\n",
"cpu_cluster_name = \"cpu-cluster-2\"\n",
"\n",
"columns = ['age', 'gender', 'bmi', 'bp', 's1', 's2', 's3', 's4', 's5', 's6']\n",
"# Verify that cluster does not exist already\n",
"try:\n",
" compute_target = ComputeTarget(workspace=ws, name=cpu_cluster_name)\n",
" print('Found existing cluster, use it.')\n",
"except ComputeTargetException:\n",
" compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2',\n",
" max_nodes=4)\n",
" compute_target = ComputeTarget.create(ws, cpu_cluster_name, compute_config)\n",
"\n",
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)"
"compute_target.wait_for_completion(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load Data\n",
"Load the hardware dataset from a csv file containing both training features and labels. The features are inputs to the model, while the training labels represent the expected output of the model. Next, we'll split the data using random_split and extract the training data for the model. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data = \"https://automlsamplenotebookdata.blob.core.windows.net/automl-sample-notebook-data/machineData.csv\"\n",
"dataset = Dataset.Tabular.from_delimited_files(data)\n",
"\n",
"# Split the dataset into train and test datasets\n",
"train_data, test_data = dataset.random_split(percentage=0.8, seed=223)\n",
"\n",
"label = \"ERP\"\n"
]
},
{
@@ -136,13 +176,13 @@
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**task**|classification, regression or forecasting|\n",
"|**primary_metric**|This is the metric that you want to optimize. Regression supports the following primary metrics: <br><i>spearman_correlation</i><br><i>normalized_root_mean_squared_error</i><br><i>r2_score</i><br><i>normalized_mean_absolute_error</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**X**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**y**|(sparse) array-like, shape = [n_samples, ], targets values.|"
"|**training_data**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**label_column_name**|(sparse) array-like, shape = [n_samples, ], targets values.|\n",
"\n",
"**_You can find more information about primary metrics_** [here](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-configure-auto-train#primary-metric)"
]
},
{
@@ -151,23 +191,30 @@
"metadata": {},
"outputs": [],
"source": [
"automl_settings = {\n",
" \"n_cross_validations\": 3,\n",
" \"primary_metric\": 'r2_score',\n",
" \"preprocess\": True,\n",
" \"enable_early_stopping\": True, \n",
" \"experiment_timeout_minutes\": 20, #for real scenarios we reccommend a timeout of at least one hour \n",
" \"max_concurrent_iterations\": 4,\n",
" \"max_cores_per_iteration\": -1,\n",
" \"verbosity\": logging.INFO,\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task = 'regression',\n",
" iteration_timeout_minutes = 10,\n",
" iterations = 10,\n",
" primary_metric = 'spearman_correlation',\n",
" n_cross_validations = 5,\n",
" debug_log = 'automl.log',\n",
" verbosity = logging.INFO,\n",
" X = X_train, \n",
" y = y_train)"
" compute_target = compute_target,\n",
" training_data = train_data,\n",
" label_column_name = label,\n",
" **automl_settings\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
"Call the `submit` method on the experiment object and pass the run configuration. Execution of remote runs is asynchronous. Depending on the data and the number of iterations this can run for a while."
]
},
{
@@ -176,7 +223,7 @@
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output = True)"
"remote_run = experiment.submit(automl_config, show_output = False)"
]
},
{
@@ -185,7 +232,18 @@
"metadata": {},
"outputs": [],
"source": [
"local_run"
"# If you need to retrieve a run that already started, use the following code\n",
"#from azureml.train.automl.run import AutoMLRun\n",
"#remote_run = AutoMLRun(experiment = experiment, run_id = '<replace with your run id>')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run"
]
},
{
@@ -213,16 +271,7 @@
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(local_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"#### Retrieve All Child Runs\n",
"You can also use SDK methods to fetch all the child runs and see individual metrics that we log."
"RunDetails(remote_run).show() "
]
},
{
@@ -231,15 +280,7 @@
"metadata": {},
"outputs": [],
"source": [
"children = list(local_run.get_children())\n",
"metricslist = {}\n",
"for run in children:\n",
" properties = run.get_properties()\n",
" metrics = {k: v for k, v in run.get_metrics().items() if isinstance(v, float)}\n",
" metricslist[int(properties['iteration'])] = metrics\n",
"\n",
"rundata = pd.DataFrame(metricslist).sort_index(1)\n",
"rundata"
"remote_run.wait_for_completion()"
]
},
{
@@ -257,7 +298,7 @@
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()\n",
"best_run, fitted_model = remote_run.get_output()\n",
"print(best_run)\n",
"print(fitted_model)"
]
@@ -277,7 +318,7 @@
"outputs": [],
"source": [
"lookup_metric = \"root_mean_squared_error\"\n",
"best_run, fitted_model = local_run.get_output(metric = lookup_metric)\n",
"best_run, fitted_model = remote_run.get_output(metric = lookup_metric)\n",
"print(best_run)\n",
"print(fitted_model)"
]
@@ -297,7 +338,7 @@
"outputs": [],
"source": [
"iteration = 3\n",
"third_run, third_model = local_run.get_output(iteration = iteration)\n",
"third_run, third_model = remote_run.get_output(iteration = iteration)\n",
"print(third_run)\n",
"print(third_model)"
]
@@ -310,10 +351,23 @@
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Predict on training and test set, and calculate residual values."
"# preview the first 3 rows of the dataset\n",
"\n",
"test_data = test_data.to_pandas_dataframe()\n",
"y_test = test_data['ERP'].fillna(0)\n",
"test_data = test_data.drop('ERP', 1)\n",
"test_data = test_data.fillna(0)\n",
"\n",
"\n",
"train_data = train_data.to_pandas_dataframe()\n",
"y_train = train_data['ERP'].fillna(0)\n",
"train_data = train_data.drop('ERP', 1)\n",
"train_data = train_data.fillna(0)\n"
]
},
{
@@ -322,10 +376,10 @@
"metadata": {},
"outputs": [],
"source": [
"y_pred_train = fitted_model.predict(X_train)\n",
"y_pred_train = fitted_model.predict(train_data)\n",
"y_residual_train = y_train - y_pred_train\n",
"\n",
"y_pred_test = fitted_model.predict(X_test)\n",
"y_pred_test = fitted_model.predict(test_data)\n",
"y_residual_test = y_test - y_pred_test"
]
},
@@ -345,41 +399,57 @@
"f.set_figwidth(16)\n",
"\n",
"# Plot residual values of training set.\n",
"a0.axis([0, 360, -200, 200])\n",
"a0.axis([0, 360, -100, 100])\n",
"a0.plot(y_residual_train, 'bo', alpha = 0.5)\n",
"a0.plot([-10,360],[0,0], 'r-', lw = 3)\n",
"a0.text(16,170,'RMSE = {0:.2f}'.format(np.sqrt(mean_squared_error(y_train, y_pred_train))), fontsize = 12)\n",
"a0.text(16,140,'R2 score = {0:.2f}'.format(r2_score(y_train, y_pred_train)), fontsize = 12)\n",
"a0.text(16,140,'R2 score = {0:.2f}'.format(r2_score(y_train, y_pred_train)),fontsize = 12)\n",
"a0.set_xlabel('Training samples', fontsize = 12)\n",
"a0.set_ylabel('Residual Values', fontsize = 12)\n",
"\n",
"# Plot a histogram.\n",
"a0.hist(y_residual_train, orientation = 'horizontal', color = 'b', bins = 10, histtype = 'step')\n",
"a0.hist(y_residual_train, orientation = 'horizontal', color = 'b', alpha = 0.2, bins = 10)\n",
"\n",
"# Plot residual values of test set.\n",
"a1.axis([0, 90, -200, 200])\n",
"a1.axis([0, 90, -100, 100])\n",
"a1.plot(y_residual_test, 'bo', alpha = 0.5)\n",
"a1.plot([-10,360],[0,0], 'r-', lw = 3)\n",
"a1.text(5,170,'RMSE = {0:.2f}'.format(np.sqrt(mean_squared_error(y_test, y_pred_test))), fontsize = 12)\n",
"a1.text(5,140,'R2 score = {0:.2f}'.format(r2_score(y_test, y_pred_test)), fontsize = 12)\n",
"a1.text(5,140,'R2 score = {0:.2f}'.format(r2_score(y_test, y_pred_test)),fontsize = 12)\n",
"a1.set_xlabel('Test samples', fontsize = 12)\n",
"a1.set_yticklabels([])\n",
"\n",
"# Plot a histogram.\n",
"a1.hist(y_residual_test, orientation = 'horizontal', color = 'b', bins = 10, histtype = 'step')\n",
"a1.hist(y_residual_test, orientation = 'horizontal', color = 'b', alpha = 0.2, bins = 10)\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"test_pred = plt.scatter(y_test, y_pred_test, color='')\n",
"test_test = plt.scatter(y_test, y_test, color='g')\n",
"plt.legend((test_pred, test_test), ('prediction', 'truth'), loc='upper left', fontsize=8)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"authors": [
{
"name": "savitam"
"name": "rakellam"
}
],
"categories": [
"how-to-use-azureml",
"automated-machine-learning"
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -395,7 +465,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
"version": "3.6.2"
}
},
"nbformat": 4,

View File

@@ -1,542 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/remote-amlcompute/auto-ml-remote-amlcompute.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Remote Execution using AmlCompute**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we use the scikit-learn's [iris dataset](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_iris.html) to showcase how you can use AutoML for a simple classification problem.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you would see\n",
"1. Create an `Experiment` in an existing `Workspace`.\n",
"2. Create or Attach existing AmlCompute to a workspace.\n",
"3. Configure AutoML using `AutoMLConfig`.\n",
"4. Train the model using AmlCompute with ONNX compatible config on.\n",
"5. Explore the results and save the ONNX model.\n",
"6. Inference with the ONNX model.\n",
"\n",
"In addition this notebook showcases the following features\n",
"- **Parallel** executions for iterations\n",
"- **Asynchronous** tracking of progress\n",
"- **Cancellation** of individual iterations or the entire run\n",
"- Retrieving models for any iteration or logged metric\n",
"- Specifying AutoML settings as `**kwargs`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"import os\n",
"\n",
"import pandas as pd\n",
"from sklearn import datasets\n",
"from sklearn.model_selection import train_test_split\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.dataset import Dataset\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# Choose an experiment name.\n",
"experiment_name = 'automl-remote-amlcompute-with-onnx'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create or Attach existing AmlCompute\n",
"You will need to create a [compute target](https://docs.microsoft.com/azure/machine-learning/service/concept-azure-machine-learning-architecture#compute-target) for your AutoML run. In this tutorial, you create `AmlCompute` as your training compute resource.\n",
"\n",
"**Creation of AmlCompute takes approximately 5 minutes.** If the AmlCompute with that name is already in your workspace this code will skip the creation process.\n",
"\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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.compute import AmlCompute\n",
"from azureml.core.compute import ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"automlc2\"\n",
"\n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
"\n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_D2_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 6)\n",
"\n",
" # Create the cluster.\\n\",\n",
" compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, provisioning_config)\n",
"\n",
"print('Checking cluster status...')\n",
"# Can poll for a minimum number of nodes and for a specific timeout.\n",
"# If no min_node_count is provided, it will use the scale settings for the cluster.\n",
"compute_target.wait_for_completion(show_output = True, min_node_count = None, timeout_in_minutes = 20)\n",
"\n",
"# For a more detailed view of current AmlCompute status, use get_status()."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"For remote executions, you need to make the data accessible from the remote compute.\n",
"This can be done by uploading the data to DataStore.\n",
"In this example, we upload scikit-learn's [load_iris](https://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_iris.html) data."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"iris = datasets.load_iris()\n",
"\n",
"X_train, X_test, y_train, y_test = train_test_split(iris.data, \n",
" iris.target, \n",
" test_size=0.2, \n",
" random_state=0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Ensure the x_train and x_test are pandas DataFrame."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Convert the X_train and X_test to pandas DataFrame and set column names,\n",
"# This is needed for initializing the input variable names of ONNX model, \n",
"# and the prediction with the ONNX model using the inference helper.\n",
"X_train = pd.DataFrame(X_train, columns=['c1', 'c2', 'c3', 'c4'])\n",
"X_test = pd.DataFrame(X_test, columns=['c1', 'c2', 'c3', 'c4'])\n",
"y_train = pd.DataFrame(y_train, columns=['label'])\n",
"\n",
"if not os.path.isdir('data'):\n",
" os.mkdir('data')\n",
"\n",
"X_train.to_csv(\"data/X_train.csv\", index=False)\n",
"y_train.to_csv(\"data/y_train.csv\", index=False)\n",
"\n",
"ds = ws.get_default_datastore()\n",
"ds.upload(src_dir='./data', target_path='irisdata', overwrite=True, show_progress=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.runconfig import RunConfiguration\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"import pkg_resources\n",
"\n",
"# create a new RunConfig object\n",
"conda_run_config = RunConfiguration(framework=\"python\")\n",
"\n",
"# Set compute target to AmlCompute\n",
"conda_run_config.target = compute_target\n",
"conda_run_config.environment.docker.enabled = True\n",
"\n",
"cd = CondaDependencies.create(conda_packages=['numpy','py-xgboost<=0.80'])\n",
"conda_run_config.environment.python.conda_dependencies = cd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Creating a TabularDataset\n",
"\n",
"Defined X and y as `TabularDataset`s, which are passed to automated machine learning in the AutoMLConfig."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"X = Dataset.Tabular.from_delimited_files(path=ds.path('irisdata/X_train.csv'))\n",
"y = Dataset.Tabular.from_delimited_files(path=ds.path('irisdata/y_train.csv'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"You can specify `automl_settings` as `**kwargs` as well. \n",
"\n",
"**Note:** Set the parameter enable_onnx_compatible_models=True, if you also want to generate the ONNX compatible models. Please note, the forecasting task and TensorFlow models are not ONNX compatible yet.\n",
"\n",
"**Note:** When using AmlCompute, you can't pass Numpy arrays directly to the fit method.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**max_concurrent_iterations**|Maximum number of iterations that would be executed in parallel. This should be less than the number of nodes in the AmlCompute cluster.|\n",
"|**enable_onnx_compatible_models**|Enable the ONNX compatible models in the experiment.|"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Set the preprocess=True, currently the InferenceHelper only supports this mode."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_settings = {\n",
" \"iteration_timeout_minutes\": 10,\n",
" \"iterations\": 10,\n",
" \"n_cross_validations\": 5,\n",
" \"primary_metric\": 'AUC_weighted',\n",
" \"preprocess\": True,\n",
" \"max_concurrent_iterations\": 5,\n",
" \"verbosity\": logging.INFO\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" run_configuration=conda_run_config,\n",
" X = X,\n",
" y = y,\n",
" enable_onnx_compatible_models=True, # This will generate ONNX compatible models.\n",
" **automl_settings\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. For remote runs the execution is asynchronous, so you will see the iterations get populated as they complete. You can interact with the widgets and models even when the experiment is running to retrieve the best model up to that point. Once you are satisfied with the model, you can cancel a particular iteration or the whole run.\n",
"In this example, we specify `show_output = False` to suppress console output while the run is in progress."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run = experiment.submit(automl_config, show_output = False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results\n",
"\n",
"#### Loading executed runs\n",
"In case you need to load a previously executed run, enable the cell below and replace the `run_id` value."
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"remote_run = AutoMLRun(experiment = experiment, run_id = 'AutoML_5db13491-c92a-4f1d-b622-8ab8d973a058')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"You can click on a pipeline to see run properties and output logs. Logs are also available on the DSVM under `/tmp/azureml_run/{iterationid}/azureml-logs`\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(remote_run).show() "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Wait until the run finishes.\n",
"remote_run.wait_for_completion(show_output = True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Cancelling Runs\n",
"\n",
"You can cancel ongoing remote runs using the `cancel` and `cancel_iteration` functions."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Cancel the ongoing experiment and stop scheduling new iterations.\n",
"# remote_run.cancel()\n",
"\n",
"# Cancel iteration 1 and move onto iteration 2.\n",
"# remote_run.cancel_iteration(1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best ONNX Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method returns the best run and the fitted model. The Model includes the pipeline and any pre-processing. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*.\n",
"\n",
"Set the parameter return_onnx_model=True to retrieve the best ONNX model, instead of the Python model."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, onnx_mdl = remote_run.get_output(return_onnx_model=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Save the best ONNX model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.automl.core.onnx_convert import OnnxConverter\n",
"onnx_fl_path = \"./best_model.onnx\"\n",
"OnnxConverter.save_onnx_model(onnx_mdl, onnx_fl_path)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Predict with the ONNX model, using onnxruntime package"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import json\n",
"from azureml.automl.core.onnx_convert import OnnxConvertConstants\n",
"from azureml.train.automl import constants\n",
"\n",
"if sys.version_info < OnnxConvertConstants.OnnxIncompatiblePythonVersion:\n",
" python_version_compatible = True\n",
"else:\n",
" python_version_compatible = False\n",
"\n",
"try:\n",
" import onnxruntime\n",
" from azureml.automl.core.onnx_convert import OnnxInferenceHelper \n",
" onnxrt_present = True\n",
"except ImportError:\n",
" onnxrt_present = False\n",
"\n",
"def get_onnx_res(run):\n",
" res_path = 'onnx_resource.json'\n",
" run.download_file(name=constants.MODEL_RESOURCE_PATH_ONNX, output_file_path=res_path)\n",
" with open(res_path) as f:\n",
" return json.load(f)\n",
"\n",
"if onnxrt_present and python_version_compatible: \n",
" mdl_bytes = onnx_mdl.SerializeToString()\n",
" onnx_res = get_onnx_res(best_run)\n",
"\n",
" onnxrt_helper = OnnxInferenceHelper(mdl_bytes, onnx_res)\n",
" pred_onnx, pred_prob_onnx = onnxrt_helper.predict(X_test)\n",
"\n",
" print(pred_onnx)\n",
" print(pred_prob_onnx)\n",
"else:\n",
" if not python_version_compatible:\n",
" print('Please use Python version 3.6 or 3.7 to run the inference helper.') \n",
" if not onnxrt_present:\n",
" print('Please install the onnxruntime package to do the prediction with ONNX model.')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,543 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/remote-amlcompute/auto-ml-remote-amlcompute.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Remote Execution using AmlCompute**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Test](#Test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we use the scikit-learn's [digit dataset](http://scikit-learn.org/stable/datasets/index.html#optical-recognition-of-handwritten-digits-dataset) to showcase how you can use AutoML for a simple classification problem.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you would see\n",
"1. Create an `Experiment` in an existing `Workspace`.\n",
"2. Create or Attach existing AmlCompute to a workspace.\n",
"3. Configure AutoML using `AutoMLConfig`.\n",
"4. Train the model using AmlCompute\n",
"5. Explore the results.\n",
"6. Test the best fitted model.\n",
"\n",
"In addition this notebook showcases the following features\n",
"- **Parallel** executions for iterations\n",
"- **Asynchronous** tracking of progress\n",
"- **Cancellation** of individual iterations or the entire run\n",
"- Retrieving models for any iteration or logged metric\n",
"- Specifying AutoML settings as `**kwargs`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"import os\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from sklearn import datasets\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.core.dataset import Dataset\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# Choose an experiment name.\n",
"experiment_name = 'automl-remote-amlcompute'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create or Attach existing AmlCompute\n",
"You will need to create a [compute target](https://docs.microsoft.com/azure/machine-learning/service/concept-azure-machine-learning-architecture#compute-target) for your AutoML run. In this tutorial, you create `AmlCompute` as your training compute resource.\n",
"\n",
"**Creation of AmlCompute takes approximately 5 minutes.** If the AmlCompute with that name is already in your workspace this code will skip the creation process.\n",
"\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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.compute import AmlCompute\n",
"from azureml.core.compute import ComputeTarget\n",
"\n",
"# Choose a name for your cluster.\n",
"amlcompute_cluster_name = \"automlc2\"\n",
"\n",
"found = False\n",
"# Check if this compute target already exists in the workspace.\n",
"cts = ws.compute_targets\n",
"if amlcompute_cluster_name in cts and cts[amlcompute_cluster_name].type == 'AmlCompute':\n",
" found = True\n",
" print('Found existing compute target.')\n",
" compute_target = cts[amlcompute_cluster_name]\n",
"\n",
"if not found:\n",
" print('Creating a new compute target...')\n",
" provisioning_config = AmlCompute.provisioning_configuration(vm_size = \"STANDARD_D2_V2\", # for GPU, use \"STANDARD_NC6\"\n",
" #vm_priority = 'lowpriority', # optional\n",
" max_nodes = 6)\n",
"\n",
" # Create the cluster.\\n\",\n",
" compute_target = ComputeTarget.create(ws, amlcompute_cluster_name, provisioning_config)\n",
"\n",
"print('Checking cluster status...')\n",
"# Can poll for a minimum number of nodes and for a specific timeout.\n",
"# If no min_node_count is provided, it will use the scale settings for the cluster.\n",
"compute_target.wait_for_completion(show_output = True, min_node_count = None, timeout_in_minutes = 20)\n",
"\n",
"# For a more detailed view of current AmlCompute status, use get_status()."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"For remote executions, you need to make the data accessible from the remote compute.\n",
"This can be done by uploading the data to DataStore.\n",
"In this example, we upload scikit-learn's [load_digits](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html) data."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data_train = datasets.load_digits()\n",
"\n",
"if not os.path.isdir('data'):\n",
" os.mkdir('data')\n",
"\n",
"pd.DataFrame(data_train.data[100:,:]).to_csv(\"data/X_train.csv\", index=False)\n",
"pd.DataFrame(data_train.target[100:]).to_csv(\"data/y_train.csv\", index=False)\n",
"\n",
"ds = ws.get_default_datastore()\n",
"ds.upload(src_dir='./data', target_path='digitsdata', overwrite=True, show_progress=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.runconfig import RunConfiguration\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"import pkg_resources\n",
"\n",
"# create a new RunConfig object\n",
"conda_run_config = RunConfiguration(framework=\"python\")\n",
"\n",
"# Set compute target to AmlCompute\n",
"conda_run_config.target = compute_target\n",
"conda_run_config.environment.docker.enabled = True\n",
"\n",
"cd = CondaDependencies.create(conda_packages=['numpy','py-xgboost<=0.80'])\n",
"conda_run_config.environment.python.conda_dependencies = cd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Creating TabularDataset\n",
"\n",
"Defined X and y as `TabularDataset`s, which are passed to Automated ML in the AutoMLConfig. `from_delimited_files` by default sets the `infer_column_types` to true, which will infer the columns type automatically. If you do wish to manually set the column types, you can set the `set_column_types` argument to manually set the type of each columns."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"X = Dataset.Tabular.from_delimited_files(path=ds.path('digitsdata/X_train.csv'))\n",
"y = Dataset.Tabular.from_delimited_files(path=ds.path('digitsdata/y_train.csv'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"You can specify `automl_settings` as `**kwargs` as well.\n",
"\n",
"**Note:** When using AmlCompute, you can't pass Numpy arrays directly to the fit method.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**n_cross_validations**|Number of cross validation splits.|\n",
"|**max_concurrent_iterations**|Maximum number of iterations that would be executed in parallel. This should be less than the number of nodes in the AmlCompute cluster.|"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_settings = {\n",
" \"iteration_timeout_minutes\": 10,\n",
" \"iterations\": 10,\n",
" \"n_cross_validations\": 5,\n",
" \"primary_metric\": 'AUC_weighted',\n",
" \"preprocess\": False,\n",
" \"max_concurrent_iterations\": 5,\n",
" \"verbosity\": logging.INFO\n",
"}\n",
"\n",
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" run_configuration=conda_run_config,\n",
" X = X,\n",
" y = y,\n",
" **automl_settings\n",
" )\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. For remote runs the execution is asynchronous, so you will see the iterations get populated as they complete. You can interact with the widgets and models even when the experiment is running to retrieve the best model up to that point. Once you are satisfied with the model, you can cancel a particular iteration or the whole run.\n",
"In this example, we specify `show_output = False` to suppress console output while the run is in progress."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run = experiment.submit(automl_config, show_output = False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results\n",
"\n",
"#### Loading executed runs\n",
"In case you need to load a previously executed run, enable the cell below and replace the `run_id` value."
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"remote_run = AutoMLRun(experiment = experiment, run_id = 'AutoML_5db13491-c92a-4f1d-b622-8ab8d973a058')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"You can click on a pipeline to see run properties and output logs. Logs are also available on the DSVM under `/tmp/azureml_run/{iterationid}/azureml-logs`\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"remote_run"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(remote_run).show() "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Wait until the run finishes.\n",
"remote_run.wait_for_completion(show_output = True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"#### Retrieve All Child Runs\n",
"You can also use SDK methods to fetch all the child runs and see individual metrics that we log."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"children = list(remote_run.get_children())\n",
"metricslist = {}\n",
"for run in children:\n",
" properties = run.get_properties()\n",
" metrics = {k: v for k, v in run.get_metrics().items() if isinstance(v, float)}\n",
" metricslist[int(properties['iteration'])] = metrics\n",
"\n",
"rundata = pd.DataFrame(metricslist).sort_index(1)\n",
"rundata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Cancelling Runs\n",
"\n",
"You can cancel ongoing remote runs using the `cancel` and `cancel_iteration` functions."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Cancel the ongoing experiment and stop scheduling new iterations.\n",
"# remote_run.cancel()\n",
"\n",
"# Cancel iteration 1 and move onto iteration 2.\n",
"# remote_run.cancel_iteration(1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method returns the best run and the fitted model. The Model includes the pipeline and any pre-processing. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = remote_run.get_output()\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Best Model Based on Any Other Metric\n",
"Show the run and the model which has the smallest `log_loss` value:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lookup_metric = \"log_loss\"\n",
"best_run, fitted_model = remote_run.get_output(metric = lookup_metric)\n",
"print(best_run)\n",
"print(fitted_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Model from a Specific Iteration\n",
"Show the run and the model from the third iteration:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"iteration = 3\n",
"third_run, third_model = remote_run.get_output(iteration=iteration)\n",
"print(third_run)\n",
"print(third_model)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test\n",
"\n",
"#### Load Test Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"digits = datasets.load_digits()\n",
"X_test = digits.data[:10, :]\n",
"y_test = digits.target[:10]\n",
"images = digits.images[:10]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Testing Our Best Fitted Model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Randomly select digits and test.\n",
"for index in np.random.choice(len(y_test), 2, replace = False):\n",
" print(index)\n",
" predicted = fitted_model.predict(X_test[index:index + 1])[0]\n",
" label = y_test[index]\n",
" title = \"Label value = %d Predicted value = %d \" % (label, predicted)\n",
" fig = plt.figure(1, figsize=(3,3))\n",
" ax1 = fig.add_axes((0,0,.8,.8))\n",
" ax1.set_title(title)\n",
" plt.imshow(images[index], cmap = plt.cm.gray_r, interpolation = 'nearest')\n",
" plt.show()"
]
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,11 +0,0 @@
name: auto-ml-remote-amlcompute
dependencies:
- pip:
- azureml-sdk
- interpret
- azureml-defaults
- azureml-explain-model
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml

View File

@@ -1,242 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/sample-weight/auto-ml-sample-weight.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Sample Weight**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Train](#Train)\n",
"1. [Test](#Test)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we use the scikit-learn's [digit dataset](http://scikit-learn.org/stable/datasets/index.html#optical-recognition-of-handwritten-digits-dataset) to showcase how you can use sample weight with AutoML. Sample weight is used where some sample values are more important than others.\n",
"\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you will learn how to configure AutoML to use `sample_weight` and you will see the difference sample weight makes to the test results."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from sklearn import datasets\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# Choose names for the regular and the sample weight experiments.\n",
"experiment_name = 'non_sample_weight_experiment'\n",
"sample_weight_experiment_name = 'sample_weight_experiment'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"sample_weight_experiment=Experiment(ws, sample_weight_experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate two `AutoMLConfig` objects. One will be used with `sample_weight` and one without."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"digits = datasets.load_digits()\n",
"X_train = digits.data[100:,:]\n",
"y_train = digits.target[100:]\n",
"\n",
"# The example makes the sample weight 0.9 for the digit 4 and 0.1 for all other digits.\n",
"# This makes the model more likely to classify as 4 if the image it not clear.\n",
"sample_weight = np.array([(0.9 if x == 4 else 0.01) for x in y_train])\n",
"\n",
"automl_classifier = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" primary_metric = 'AUC_weighted',\n",
" iteration_timeout_minutes = 60,\n",
" iterations = 10,\n",
" n_cross_validations = 2,\n",
" verbosity = logging.INFO,\n",
" X = X_train, \n",
" y = y_train)\n",
"\n",
"automl_sample_weight = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" primary_metric = 'AUC_weighted',\n",
" iteration_timeout_minutes = 60,\n",
" iterations = 10,\n",
" n_cross_validations = 2,\n",
" verbosity = logging.INFO,\n",
" X = X_train, \n",
" y = y_train,\n",
" sample_weight = sample_weight)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment objects and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_classifier, show_output = True)\n",
"sample_weight_run = sample_weight_experiment.submit(automl_sample_weight, show_output = True)\n",
"\n",
"best_run, fitted_model = local_run.get_output()\n",
"best_run_sample_weight, fitted_model_sample_weight = sample_weight_run.get_output()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test\n",
"\n",
"#### Load Test Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"digits = datasets.load_digits()\n",
"X_test = digits.data[:100, :]\n",
"y_test = digits.target[:100]\n",
"images = digits.images[:100]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Compare the Models\n",
"The prediction from the sample weight model is more likely to correctly predict 4's. However, it is also more likely to predict 4 for some images that are not labelled as 4."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Randomly select digits and test.\n",
"for index in range(0,len(y_test)):\n",
" predicted = fitted_model.predict(X_test[index:index + 1])[0]\n",
" predicted_sample_weight = fitted_model_sample_weight.predict(X_test[index:index + 1])[0]\n",
" label = y_test[index]\n",
" if predicted == 4 or predicted_sample_weight == 4 or label == 4:\n",
" title = \"Label value = %d Predicted value = %d Prediced with sample weight = %d\" % (label, predicted, predicted_sample_weight)\n",
" fig = plt.figure(1, figsize=(3,3))\n",
" ax1 = fig.add_axes((0,0,.8,.8))\n",
" ax1.set_title(title)\n",
" plt.imshow(images[index], cmap = plt.cm.gray_r, interpolation = 'nearest')\n",
" plt.show()"
]
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,8 +0,0 @@
name: auto-ml-sample-weight
dependencies:
- pip:
- azureml-sdk
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml

View File

@@ -1,382 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/sparse-data-train-test-split/auto-ml-sparse-data-train-test-split.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Train Test Split and Handling Sparse Data**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"1. [Results](#Results)\n",
"1. [Test](#Test)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"In this example we use the scikit-learn's [20newsgroup](http://scikit-learn.org/stable/modules/generated/sklearn.datasets.fetch_20newsgroups.html) to showcase how you can use AutoML for handling sparse data and how to specify custom cross validations splits.\n",
"Make sure you have executed the [configuration](../../../configuration.ipynb) before running this notebook.\n",
"\n",
"In this notebook you will learn how to:\n",
"1. Create an `Experiment` in an existing `Workspace`.\n",
"2. Configure AutoML using `AutoMLConfig`.\n",
"4. Train the model.\n",
"5. Explore the results.\n",
"6. Test the best fitted model.\n",
"\n",
"In addition this notebook showcases the following features\n",
"- Explicit train test splits \n",
"- Handling **sparse data** in the input"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"import pandas as pd\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.train.automl import AutoMLConfig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# choose a name for the experiment\n",
"experiment_name = 'sparse-data-train-test-split'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"outputDf = pd.DataFrame(data = output, index = [''])\n",
"outputDf.T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.datasets import fetch_20newsgroups\n",
"from sklearn.feature_extraction.text import HashingVectorizer\n",
"from sklearn.model_selection import train_test_split\n",
"\n",
"remove = ('headers', 'footers', 'quotes')\n",
"categories = [\n",
" 'alt.atheism',\n",
" 'talk.religion.misc',\n",
" 'comp.graphics',\n",
" 'sci.space',\n",
"]\n",
"data_train = fetch_20newsgroups(subset = 'train', categories = categories,\n",
" shuffle = True, random_state = 42,\n",
" remove = remove)\n",
"\n",
"X_train, X_valid, y_train, y_valid = train_test_split(data_train.data, data_train.target, test_size = 0.33, random_state = 42)\n",
"\n",
"\n",
"vectorizer = HashingVectorizer(stop_words = 'english', alternate_sign = False,\n",
" n_features = 2**16)\n",
"X_train = vectorizer.transform(X_train)\n",
"X_valid = vectorizer.transform(X_valid)\n",
"\n",
"summary_df = pd.DataFrame(index = ['No of Samples', 'No of Features'])\n",
"summary_df['Train Set'] = [X_train.shape[0], X_train.shape[1]]\n",
"summary_df['Validation Set'] = [X_valid.shape[0], X_valid.shape[1]]\n",
"summary_df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate an `AutoMLConfig` object to specify the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**task**|classification or regression|\n",
"|**primary_metric**|This is the metric that you want to optimize. Classification supports the following primary metrics: <br><i>accuracy</i><br><i>AUC_weighted</i><br><i>average_precision_score_weighted</i><br><i>norm_macro_recall</i><br><i>precision_score_weighted</i>|\n",
"|**iteration_timeout_minutes**|Time limit in minutes for each iteration.|\n",
"|**iterations**|Number of iterations. In each iteration AutoML trains a specific pipeline with the data.|\n",
"|**preprocess**|Setting this to *True* enables AutoML to perform preprocessing on the input to handle *missing data*, and to perform some common *feature extraction*.<br>**Note:** If input data is sparse, you cannot use *True*.|\n",
"|**X**|(sparse) array-like, shape = [n_samples, n_features]|\n",
"|**y**|(sparse) array-like, shape = [n_samples, ], Multi-class targets.|\n",
"|**X_valid**|(sparse) array-like, shape = [n_samples, n_features] for the custom validation set.|\n",
"|**y_valid**|(sparse) array-like, shape = [n_samples, ], Multi-class targets.|"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" primary_metric = 'AUC_weighted',\n",
" iteration_timeout_minutes = 60,\n",
" iterations = 5,\n",
" preprocess = False,\n",
" verbosity = logging.INFO,\n",
" X = X_train, \n",
" y = y_train,\n",
" X_valid = X_valid, \n",
" y_valid = y_valid)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Widget for Monitoring Runs\n",
"\n",
"The widget will first report a \"loading\" status while running the first iteration. After completing the first iteration, an auto-updating graph and table will be shown. The widget will refresh once per minute, so you should see the graph update as child runs complete.\n",
"\n",
"**Note:** The widget displays a link at the bottom. Use this link to open a web interface to explore the individual run details."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.widgets import RunDetails\n",
"RunDetails(local_run).show() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"#### Retrieve All Child Runs\n",
"You can also use SDK methods to fetch all the child runs and see individual metrics that we log."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"children = list(local_run.get_children())\n",
"metricslist = {}\n",
"for run in children:\n",
" properties = run.get_properties()\n",
" metrics = {k: v for k, v in run.get_metrics().items() if isinstance(v, float)}\n",
" metricslist[int(properties['iteration'])] = metrics\n",
" \n",
"rundata = pd.DataFrame(metricslist).sort_index(1)\n",
"rundata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Retrieve the Best Model\n",
"\n",
"Below we select the best pipeline from our iterations. The `get_output` method returns the best run and the fitted model. The Model includes the pipeline and any pre-processing. Overloads on `get_output` allow you to retrieve the best run and fitted model for *any* logged metric or for a particular *iteration*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"best_run, fitted_model = local_run.get_output()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Best Model Based on Any Other Metric\n",
"Show the run and the model which has the smallest `accuracy` value:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# lookup_metric = \"accuracy\"\n",
"# best_run, fitted_model = local_run.get_output(metric = lookup_metric)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Model from a Specific Iteration\n",
"Show the run and the model from the third iteration:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# iteration = 3\n",
"# best_run, fitted_model = local_run.get_output(iteration = iteration)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Load test data.\n",
"from pandas_ml import ConfusionMatrix\n",
"\n",
"data_test = fetch_20newsgroups(subset = 'test', categories = categories,\n",
" shuffle = True, random_state = 42,\n",
" remove = remove)\n",
"\n",
"X_test = vectorizer.transform(data_test.data)\n",
"y_test = data_test.target\n",
"\n",
"# Test our best pipeline.\n",
"\n",
"y_pred = fitted_model.predict(X_test)\n",
"y_pred_strings = [data_test.target_names[i] for i in y_pred]\n",
"y_test_strings = [data_test.target_names[i] for i in y_test]\n",
"\n",
"cm = ConfusionMatrix(y_test_strings, y_pred_strings)\n",
"print(cm)\n",
"cm.plot()"
]
}
],
"metadata": {
"authors": [
{
"name": "savitam"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,8 +0,0 @@
name: auto-ml-sparse-data-train-test-split
dependencies:
- pip:
- azureml-sdk
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml

View File

@@ -126,6 +126,22 @@
"name": "jeffshep"
}
],
"category": "tutorial",
"compute": [
"Local"
],
"datasets": [
"NYC Energy"
],
"deployment": [
"None"
],
"exclude_from_index": false,
"framework": [
"Azure ML AutoML"
],
"friendly_name": "Forecasting with automated ML SQL integration",
"index_order": 1,
"kernelspec": {
"display_name": "Python 3.6",
"language": "sql",
@@ -134,7 +150,11 @@
"language_info": {
"name": "sql",
"version": ""
}
},
"tags": [
""
],
"task": "Forecasting"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -546,6 +546,22 @@
"name": "jeffshep"
}
],
"category": "tutorial",
"compute": [
"None"
],
"datasets": [
"None"
],
"deployment": [
"None"
],
"exclude_from_index": false,
"framework": [
"Azure ML AutoML"
],
"friendly_name": "Setup automated ML SQL integration",
"index_order": 1,
"kernelspec": {
"display_name": "Python 3.6",
"language": "sql",
@@ -554,7 +570,11 @@
"language_info": {
"name": "sql",
"version": ""
}
},
"tags": [
""
],
"task": "None"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -1,198 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/automated-machine-learning/subsampling/auto-ml-subsampling-local.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automated Machine Learning\n",
"_**Classification with Local Compute**_\n",
"\n",
"## Contents\n",
"1. [Introduction](#Introduction)\n",
"1. [Setup](#Setup)\n",
"1. [Data](#Data)\n",
"1. [Train](#Train)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Introduction\n",
"\n",
"In this example we will explore AutoML's subsampling feature. This is useful for training on large datasets to speed up the convergence.\n",
"\n",
"The setup is quiet similar to a normal classification, with the exception of the `enable_subsampling` option. Keep in mind that even with the `enable_subsampling` flag set, subsampling will only be run for large datasets (>= 50k rows) and large (>= 85) or no iteration restrictions.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"As part of the setup you have already created an Azure ML `Workspace` object. For AutoML you will need to create an `Experiment` object, which is a named object in a `Workspace` used to run experiments."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"import azureml.core\n",
"from azureml.core.experiment import Experiment\n",
"from azureml.core.workspace import Workspace\n",
"from azureml.train.automl import AutoMLConfig\n",
"from azureml.train.automl.run import AutoMLRun"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ws = Workspace.from_config()\n",
"\n",
"# Choose a name for the experiment.\n",
"experiment_name = 'automl-subsampling'\n",
"\n",
"experiment = Experiment(ws, experiment_name)\n",
"\n",
"output = {}\n",
"output['SDK version'] = azureml.core.VERSION\n",
"output['Subscription ID'] = ws.subscription_id\n",
"output['Workspace Name'] = ws.name\n",
"output['Resource Group'] = ws.resource_group\n",
"output['Location'] = ws.location\n",
"output['Experiment Name'] = experiment.name\n",
"pd.set_option('display.max_colwidth', -1)\n",
"pd.DataFrame(data = output, index = ['']).T"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"\n",
"We will create a simple dataset using the numpy sin function just for this example. We need just over 50k rows."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"base = np.arange(60000)\n",
"cos = np.cos(base)\n",
"y = np.round(np.sin(base)).astype('int')\n",
"\n",
"# Exclude the first 100 rows from training so that they can be used for test.\n",
"X_train = np.hstack((base.reshape(-1, 1), cos.reshape(-1, 1)))\n",
"y_train = y"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train\n",
"\n",
"Instantiate an `AutoMLConfig` object to specify the settings and data used to run the experiment.\n",
"\n",
"|Property|Description|\n",
"|-|-|\n",
"|**enable_subsampling**|This enables subsampling as an option. However it does not guarantee subsampling will be used. It also depends on how large the dataset is and how many iterations it's expected to run at a minimum.|\n",
"|**iterations**|Number of iterations. Subsampling requires a lot of iterations at smaller percent so in order for subsampling to be used we need to set iterations to be a high number.|\n",
"|**experiment_timeout_minutes**|The experiment timeout, it's set to 5 right now to shorten the demo but it should probably be higher if we want to finish all the iterations.|\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"automl_config = AutoMLConfig(task = 'classification',\n",
" debug_log = 'automl_errors.log',\n",
" primary_metric = 'accuracy',\n",
" iterations = 85,\n",
" experiment_timeout_minutes = 5,\n",
" n_cross_validations = 2,\n",
" verbosity = logging.INFO,\n",
" X = X_train, \n",
" y = y_train,\n",
" enable_subsampling=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Call the `submit` method on the experiment object and pass the run configuration. Execution of local runs is synchronous. Depending on the data and the number of iterations this can run for a while.\n",
"In this example, we specify `show_output = True` to print currently running iterations to the console."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_run = experiment.submit(automl_config, show_output = True)"
]
}
],
"metadata": {
"authors": [
{
"name": "rogehe"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -1,8 +0,0 @@
name: auto-ml-subsampling-local
dependencies:
- pip:
- azureml-sdk
- azureml-train-automl
- azureml-widgets
- matplotlib
- pandas_ml

View File

@@ -106,6 +106,7 @@
"def init():\n",
" # One-time initialization of PySpark and predictive model\n",
" import pyspark\n",
" import os\n",
" from azureml.core.model import Model\n",
" from pyspark.ml import PipelineModel\n",
" \n",
@@ -114,7 +115,10 @@
" \n",
" spark = pyspark.sql.SparkSession.builder.appName(\"ADB and AML notebook by Parashar\").getOrCreate()\n",
" model_name = \"{model_name}\" #interpolated\n",
" model_path = Model.get_model_path(model_name)\n",
" # AZUREML_MODEL_DIR is an environment variable created during deployment.\n",
" # It is the path to the model folder (./azureml-models/$MODEL_NAME/$VERSION)\n",
" # For multiple models, it points to the folder containing all deployed models (./azureml-models)\n",
" model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), model_name)\n",
" trainedModel = PipelineModel.load(model_path)\n",
" \n",
"def run(input_json):\n",
@@ -283,7 +287,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
"version": "3.6.8"
},
"name": "deploy-to-aci-04",
"notebookId": 3836944406456376

View File

@@ -37,7 +37,7 @@
"\n",
"**azureml-sdk with automated ml**\n",
"* Source: Upload Python Egg or PyPi\n",
"* PyPi Name: `azureml-sdk[automl_databricks]`\n",
"* PyPi Name: `azureml-sdk[automl]`\n",
"* Select Install Library"
]
},

View File

@@ -17,7 +17,7 @@
"\n",
"**install azureml-sdk with Automated ML**\n",
"* Source: Upload Python Egg or PyPi\n",
"* PyPi Name: `azureml-sdk[automl_databricks]`\n",
"* PyPi Name: `azureml-sdk[automl]`\n",
"* Select Install Library"
]
},

View File

@@ -0,0 +1,14 @@
# Model Deployment with Azure ML service
You can use Azure Machine Learning to package, debug, validate and deploy inference containers to a variety of compute targets. This process is known as "MLOps" (ML operationalization).
For more information please check out this article: https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-deploy-and-where
## Get Started
To begin, you will need an ML workspace.
For more information please check out this article: https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-manage-workspace
## Deploy to the cloud
You can deploy to the cloud using the Azure ML CLI or the Azure ML SDK.
- CLI example: https://aka.ms/azmlcli
- Notebook example: [model-register-and-deploy](./model-register-and-deploy.ipynb).
![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/deployment/deploy-multi-model/README.png)

View File

@@ -0,0 +1,371 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) Microsoft Corporation. All rights reserved.\n",
"\n",
"Licensed under the MIT License."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![Impressions](https://PixelServer20190423114238.azurewebsites.net/api/impressions/MachineLearningNotebooks/how-to-use-azureml/deployment/deploy-multi-model/multi-model-register-and-deploy.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Deploy Multiple Models as Webservice\n",
"\n",
"This example shows how to deploy a Webservice with multiple models in step-by-step fashion:\n",
"\n",
" 1. Register Models\n",
" 2. Deploy Models as Webservice"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Prerequisites\n",
"If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, make sure you go through the [configuration](../../../configuration.ipynb) Notebook first if you haven't."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Check core SDK version number\n",
"import azureml.core\n",
"\n",
"print(\"SDK version:\", azureml.core.VERSION)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Initialize Workspace\n",
"\n",
"Initialize a workspace object from persisted configuration."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"create workspace"
]
},
"outputs": [],
"source": [
"from azureml.core import Workspace\n",
"\n",
"ws = Workspace.from_config()\n",
"print(ws.name, ws.resource_group, ws.location, ws.subscription_id, sep='\\n')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Register Models"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this example, we will be using and registering two models. \n",
"\n",
"You wil need to have a `first_model.pkl` file and `second_model.pkl` file in the current directory. The below call registers the files as Models with the names `my_first_model` and `my_second_model` in the workspace."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"register model from file"
]
},
"outputs": [],
"source": [
"from azureml.core.model import Model\n",
"\n",
"my_model_1 = Model.register(model_path=\"first_model.pkl\",\n",
" model_name=\"my_first_model\",\n",
" workspace=ws)\n",
"\n",
"my_model_2 = Model.register(model_path=\"second_model.pkl\",\n",
" model_name=\"my_second_model\",\n",
" workspace=ws)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Write the Entry Script\n",
"Write the script that will be used to predict on your models"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Model.get_model_path()\n",
"\n",
"To get the paths of your models, use `Model.get_model_path(model_name, version=None, _workspace=None)` method. This method will find the path to a model using the name of the model registered under the workspace.\n",
"\n",
"In this example, we do not use the optional arguments `version` and `_workspace`.\n",
"\n",
"#### Using environment variable AZUREML_MODEL_DIR\n",
"\n",
"In other [examples](../deploy-to-cloud/score.py) with a single model deployment, we use the environment variable `AZUREML_MODEL_DIR` and model file name to get the model path. \n",
"\n",
"For single model deployments, this environment variable is the path to the model folder (`./azureml-models/$MODEL_NAME/$VERSION`). When we deploy multiple models, the environment variable is set to the folder containing all models (./azureml-models).\n",
"\n",
"If you're using multiple models and you know the versions of the models you deploy, you can use this method to get the model path:\n",
"\n",
"```python\n",
"# Construct the model path using the registered model name, version, and model file name\n",
"model_1_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'my_first_model', '1', 'first_model.pkl')\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%writefile score.py\n",
"import pickle\n",
"import json\n",
"import numpy as np\n",
"from sklearn.externals import joblib\n",
"from sklearn.linear_model import Ridge\n",
"from azureml.core.model import Model\n",
"\n",
"def init():\n",
" global model_1, model_2\n",
" # note here \"my_first_model\" is the name of the model registered under the workspace\n",
" # this call should return the path to the model.pkl file on the local disk.\n",
" model_1_path = Model.get_model_path(model_name='my_first_model')\n",
" model_2_path = Model.get_model_path(model_name='my_second_model')\n",
" \n",
" # deserialize the model files back into a sklearn model\n",
" model_1 = joblib.load(model_1_path)\n",
" model_2 = joblib.load(model_2_path)\n",
"\n",
"# note you can pass in multiple rows for scoring\n",
"def run(raw_data):\n",
" try:\n",
" data = json.loads(raw_data)['data']\n",
" data = np.array(data)\n",
" \n",
" # Call predict() on each model\n",
" result_1 = model_1.predict(data)\n",
" result_2 = model_2.predict(data)\n",
"\n",
" # you can return any data type as long as it is JSON-serializable\n",
" return {\"prediction1\": result_1.tolist(), \"prediction2\": result_2.tolist()}\n",
" except Exception as e:\n",
" result = str(e)\n",
" return result"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create Environment"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can now create and/or use an Environment object when deploying a Webservice. The Environment can have been previously registered with your Workspace, or it will be registered with it as a part of the Webservice deployment. Only Environments that were created using azureml-defaults version 1.0.48 or later will work with this new handling however.\n",
"\n",
"More information can be found in our [using environments notebook](../training/using-environments/using-environments.ipynb)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Environment\n",
"\n",
"env = Environment.from_conda_specification(name='deploytocloudenv', file_path='myenv.yml')\n",
"\n",
"# This is optional at this point\n",
"# env.register(workspace=ws)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create Inference Configuration\n",
"\n",
"There is now support for a source directory, you can upload an entire folder from your local machine as dependencies for the Webservice.\n",
"Note: in that case, your entry_script, conda_file, and extra_docker_file_steps paths are relative paths to the source_directory path.\n",
"\n",
"Sample code for using a source directory:\n",
"\n",
"```python\n",
"inference_config = InferenceConfig(source_directory=\"C:/abc\",\n",
" runtime= \"python\", \n",
" entry_script=\"x/y/score.py\",\n",
" conda_file=\"env/myenv.yml\", \n",
" extra_docker_file_steps=\"helloworld.txt\")\n",
"```\n",
"\n",
" - source_directory = holds source path as string, this entire folder gets added in image so its really easy to access any files within this folder or subfolder\n",
" - runtime = Which runtime to use for the image. Current supported runtimes are 'spark-py' and 'python\n",
" - entry_script = contains logic specific to initializing your model and running predictions\n",
" - conda_file = manages conda and python package dependencies.\n",
" - extra_docker_file_steps = optional: any extra steps you want to inject into docker file"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"create image"
]
},
"outputs": [],
"source": [
"from azureml.core.model import InferenceConfig\n",
"\n",
"inference_config = InferenceConfig(entry_script=\"score.py\", environment=env)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Deploy Model as Webservice on Azure Container Instance\n",
"\n",
"Note that the service creation can take few minutes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"azuremlexception-remarks-sample"
]
},
"outputs": [],
"source": [
"from azureml.core.webservice import AciWebservice, Webservice\n",
"from azureml.exceptions import WebserviceException\n",
"\n",
"deployment_config = AciWebservice.deploy_configuration(cpu_cores=1, memory_gb=1)\n",
"aci_service_name = 'aciservice1'\n",
"\n",
"try:\n",
" # if you want to get existing service below is the command\n",
" # since aci name needs to be unique in subscription deleting existing aci if any\n",
" # we use aci_service_name to create azure aci\n",
" service = Webservice(ws, name=aci_service_name)\n",
" if service:\n",
" service.delete()\n",
"except WebserviceException as e:\n",
" print()\n",
"\n",
"service = Model.deploy(ws, aci_service_name, [my_model_1, my_model_2], inference_config, deployment_config)\n",
"\n",
"service.wait_for_deployment(True)\n",
"print(service.state)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Test web service"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"test_sample = json.dumps({'data': [\n",
" [1,2,3,4,5,6,7,8,9,10], \n",
" [10,9,8,7,6,5,4,3,2,1]\n",
"]})\n",
"\n",
"test_sample_encoded = bytes(test_sample, encoding='utf8')\n",
"prediction = service.run(input_data=test_sample_encoded)\n",
"print(prediction)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Delete ACI to clean up"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"deploy service",
"aci"
]
},
"outputs": [],
"source": [
"service.delete()"
]
}
],
"metadata": {
"authors": [
{
"name": "jenns"
}
],
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
"name": "python36"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@@ -0,0 +1,4 @@
name: multi-model-register-and-deploy
dependencies:
- pip:
- azureml-sdk

View File

@@ -0,0 +1,442 @@
3.807590643342410180e-02,5.068011873981870252e-02,6.169620651868849837e-02,2.187235499495579841e-02,-4.422349842444640161e-02,-3.482076283769860309e-02,-4.340084565202689815e-02,-2.592261998182820038e-03,1.990842087631829876e-02,-1.764612515980519894e-02
-1.882016527791040067e-03,-4.464163650698899782e-02,-5.147406123880610140e-02,-2.632783471735180084e-02,-8.448724111216979540e-03,-1.916333974822199970e-02,7.441156407875940126e-02,-3.949338287409189657e-02,-6.832974362442149896e-02,-9.220404962683000083e-02
8.529890629667830071e-02,5.068011873981870252e-02,4.445121333659410312e-02,-5.670610554934250001e-03,-4.559945128264750180e-02,-3.419446591411950259e-02,-3.235593223976569732e-02,-2.592261998182820038e-03,2.863770518940129874e-03,-2.593033898947460017e-02
-8.906293935226029801e-02,-4.464163650698899782e-02,-1.159501450521270051e-02,-3.665644679856060184e-02,1.219056876180000040e-02,2.499059336410210108e-02,-3.603757004385269719e-02,3.430885887772629900e-02,2.269202256674450122e-02,-9.361911330135799444e-03
5.383060374248070309e-03,-4.464163650698899782e-02,-3.638469220447349689e-02,2.187235499495579841e-02,3.934851612593179802e-03,1.559613951041610019e-02,8.142083605192099172e-03,-2.592261998182820038e-03,-3.199144494135589684e-02,-4.664087356364819692e-02
-9.269547780327989928e-02,-4.464163650698899782e-02,-4.069594049999709917e-02,-1.944209332987930153e-02,-6.899064987206669775e-02,-7.928784441181220555e-02,4.127682384197570165e-02,-7.639450375000099436e-02,-4.118038518800790082e-02,-9.634615654166470144e-02
-4.547247794002570037e-02,5.068011873981870252e-02,-4.716281294328249912e-02,-1.599922263614299983e-02,-4.009563984984299695e-02,-2.480001206043359885e-02,7.788079970179680352e-04,-3.949338287409189657e-02,-6.291294991625119570e-02,-3.835665973397880263e-02
6.350367559056099842e-02,5.068011873981870252e-02,-1.894705840284650021e-03,6.662967401352719310e-02,9.061988167926439408e-02,1.089143811236970016e-01,2.286863482154040048e-02,1.770335448356720118e-02,-3.581672810154919867e-02,3.064409414368320182e-03
4.170844488444359899e-02,5.068011873981870252e-02,6.169620651868849837e-02,-4.009931749229690007e-02,-1.395253554402150001e-02,6.201685656730160021e-03,-2.867429443567860031e-02,-2.592261998182820038e-03,-1.495647502491130078e-02,1.134862324403770016e-02
-7.090024709716259699e-02,-4.464163650698899782e-02,3.906215296718960200e-02,-3.321357610482440076e-02,-1.257658268582039982e-02,-3.450761437590899733e-02,-2.499265663159149983e-02,-2.592261998182820038e-03,6.773632611028609918e-02,-1.350401824497050006e-02
-9.632801625429950054e-02,-4.464163650698899782e-02,-8.380842345523309422e-02,8.100872220010799790e-03,-1.033894713270950005e-01,-9.056118903623530669e-02,-1.394774321933030074e-02,-7.639450375000099436e-02,-6.291294991625119570e-02,-3.421455281914410201e-02
2.717829108036539862e-02,5.068011873981870252e-02,1.750591148957160101e-02,-3.321357610482440076e-02,-7.072771253015849857e-03,4.597154030400080194e-02,-6.549067247654929980e-02,7.120997975363539678e-02,-9.643322289178400675e-02,-5.906719430815229877e-02
1.628067572730669890e-02,-4.464163650698899782e-02,-2.884000768730720157e-02,-9.113481248670509197e-03,-4.320865536613589623e-03,-9.768885894535990141e-03,4.495846164606279866e-02,-3.949338287409189657e-02,-3.075120986455629965e-02,-4.249876664881350324e-02
5.383060374248070309e-03,5.068011873981870252e-02,-1.894705840284650021e-03,8.100872220010799790e-03,-4.320865536613589623e-03,-1.571870666853709964e-02,-2.902829807069099918e-03,-2.592261998182820038e-03,3.839324821169769891e-02,-1.350401824497050006e-02
4.534098333546320025e-02,-4.464163650698899782e-02,-2.560657146566450160e-02,-1.255635194240680048e-02,1.769438019460449832e-02,-6.128357906048329537e-05,8.177483968693349814e-02,-3.949338287409189657e-02,-3.199144494135589684e-02,-7.563562196749110123e-02
-5.273755484206479882e-02,5.068011873981870252e-02,-1.806188694849819934e-02,8.040115678847230274e-02,8.924392882106320368e-02,1.076617872765389949e-01,-3.971920784793980114e-02,1.081111006295440019e-01,3.605579008983190309e-02,-4.249876664881350324e-02
-5.514554978810590376e-03,-4.464163650698899782e-02,4.229558918883229851e-02,4.941532054484590319e-02,2.457414448561009990e-02,-2.386056667506489953e-02,7.441156407875940126e-02,-3.949338287409189657e-02,5.227999979678119719e-02,2.791705090337660150e-02
7.076875249260000666e-02,5.068011873981870252e-02,1.211685112016709989e-02,5.630106193231849965e-02,3.420581449301800248e-02,4.941617338368559792e-02,-3.971920784793980114e-02,3.430885887772629900e-02,2.736770754260900093e-02,-1.077697500466389974e-03
-3.820740103798660192e-02,-4.464163650698899782e-02,-1.051720243133190055e-02,-3.665644679856060184e-02,-3.734373413344069942e-02,-1.947648821001150138e-02,-2.867429443567860031e-02,-2.592261998182820038e-03,-1.811826730789670159e-02,-1.764612515980519894e-02
-2.730978568492789874e-02,-4.464163650698899782e-02,-1.806188694849819934e-02,-4.009931749229690007e-02,-2.944912678412469915e-03,-1.133462820348369975e-02,3.759518603788870178e-02,-3.949338287409189657e-02,-8.944018957797799166e-03,-5.492508739331759815e-02
-4.910501639104519755e-02,-4.464163650698899782e-02,-5.686312160821060252e-02,-4.354218818603310115e-02,-4.559945128264750180e-02,-4.327577130601600180e-02,7.788079970179680352e-04,-3.949338287409189657e-02,-1.190068480150809939e-02,1.549073015887240078e-02
-8.543040090124079389e-02,5.068011873981870252e-02,-2.237313524402180162e-02,1.215130832538269907e-03,-3.734373413344069942e-02,-2.636575436938120090e-02,1.550535921336619952e-02,-3.949338287409189657e-02,-7.212845460195599356e-02,-1.764612515980519894e-02
-8.543040090124079389e-02,-4.464163650698899782e-02,-4.050329988046450294e-03,-9.113481248670509197e-03,-2.944912678412469915e-03,7.767427965677820186e-03,2.286863482154040048e-02,-3.949338287409189657e-02,-6.117659509433449883e-02,-1.350401824497050006e-02
4.534098333546320025e-02,5.068011873981870252e-02,6.061839444480759953e-02,3.105334362634819961e-02,2.870200306021350109e-02,-4.734670130927989828e-02,-5.444575906428809897e-02,7.120997975363539678e-02,1.335989800130079896e-01,1.356118306890790048e-01
-6.363517019512339445e-02,-4.464163650698899782e-02,3.582871674554689856e-02,-2.288496402361559975e-02,-3.046396984243510131e-02,-1.885019128643240088e-02,-6.584467611156170040e-03,-2.592261998182820038e-03,-2.595242443518940012e-02,-5.492508739331759815e-02
-6.726770864614299572e-02,5.068011873981870252e-02,-1.267282657909369996e-02,-4.009931749229690007e-02,-1.532848840222260020e-02,4.635943347782499856e-03,-5.812739686837520292e-02,3.430885887772629900e-02,1.919903307856710151e-02,-3.421455281914410201e-02
-1.072256316073579990e-01,-4.464163650698899782e-02,-7.734155101194770121e-02,-2.632783471735180084e-02,-8.962994274508359616e-02,-9.619786134844690584e-02,2.655027262562750096e-02,-7.639450375000099436e-02,-4.257210492279420166e-02,-5.219804415301099697e-03
-2.367724723390840155e-02,-4.464163650698899782e-02,5.954058237092670069e-02,-4.009931749229690007e-02,-4.284754556624519733e-02,-4.358891976780549654e-02,1.182372140927919965e-02,-3.949338287409189657e-02,-1.599826775813870117e-02,4.034337164788070335e-02
5.260606023750229870e-02,-4.464163650698899782e-02,-2.129532317014089932e-02,-7.452802442965950069e-02,-4.009563984984299695e-02,-3.763909899380440266e-02,-6.584467611156170040e-03,-3.949338287409189657e-02,-6.092541861022970299e-04,-5.492508739331759815e-02
6.713621404158050254e-02,5.068011873981870252e-02,-6.205954135808240159e-03,6.318680331979099896e-02,-4.284754556624519733e-02,-9.588471288665739722e-02,5.232173725423699961e-02,-7.639450375000099436e-02,5.942380044479410317e-02,5.276969239238479825e-02
-6.000263174410389727e-02,-4.464163650698899782e-02,4.445121333659410312e-02,-1.944209332987930153e-02,-9.824676969418109224e-03,-7.576846662009279788e-03,2.286863482154040048e-02,-3.949338287409189657e-02,-2.712864555432650121e-02,-9.361911330135799444e-03
-2.367724723390840155e-02,-4.464163650698899782e-02,-6.548561819925780014e-02,-8.141376581713200000e-02,-3.871968699164179961e-02,-5.360967054507050078e-02,5.968501286241110343e-02,-7.639450375000099436e-02,-3.712834601047360072e-02,-4.249876664881350324e-02
3.444336798240450054e-02,5.068011873981870252e-02,1.252871188776620015e-01,2.875809638242839833e-02,-5.385516843185429725e-02,-1.290037051243130006e-02,-1.023070505174200062e-01,1.081111006295440019e-01,2.714857279071319972e-04,2.791705090337660150e-02
3.081082953138499989e-02,-4.464163650698899782e-02,-5.039624916492520257e-02,-2.227739861197989939e-03,-4.422349842444640161e-02,-8.993489211265630334e-02,1.185912177278039964e-01,-7.639450375000099436e-02,-1.811826730789670159e-02,3.064409414368320182e-03
1.628067572730669890e-02,-4.464163650698899782e-02,-6.332999405149600247e-02,-5.731367096097819691e-02,-5.798302700645770191e-02,-4.891244361822749687e-02,8.142083605192099172e-03,-3.949338287409189657e-02,-5.947269741072230137e-02,-6.735140813782170000e-02
4.897352178648269744e-02,5.068011873981870252e-02,-3.099563183506899924e-02,-4.928030602040309877e-02,4.934129593323050011e-02,-4.132213582324419619e-03,1.333177689441520097e-01,-5.351580880693729975e-02,2.131084656824479978e-02,1.963283707370720027e-02
1.264813727628719998e-02,-4.464163650698899782e-02,2.289497185897609866e-02,5.285819123858220142e-02,8.062710187196569719e-03,-2.855779360190789998e-02,3.759518603788870178e-02,-3.949338287409189657e-02,5.472400334817909689e-02,-2.593033898947460017e-02
-9.147093429830140468e-03,-4.464163650698899782e-02,1.103903904628619932e-02,-5.731367096097819691e-02,-2.496015840963049931e-02,-4.296262284422640298e-02,3.023191042971450082e-02,-3.949338287409189657e-02,1.703713241477999851e-02,-5.219804415301099697e-03
-1.882016527791040067e-03,5.068011873981870252e-02,7.139651518361660176e-02,9.761551025715360652e-02,8.786797596286209655e-02,7.540749571221680436e-02,-2.131101882750449997e-02,7.120997975363539678e-02,7.142403278057639360e-02,2.377494398854190089e-02
-1.882016527791040067e-03,5.068011873981870252e-02,1.427247526792889930e-02,-7.452802442965950069e-02,2.558898754392050119e-03,6.201685656730160021e-03,-1.394774321933030074e-02,-2.592261998182820038e-03,1.919903307856710151e-02,3.064409414368320182e-03
5.383060374248070309e-03,5.068011873981870252e-02,-8.361578283570040432e-03,2.187235499495579841e-02,5.484510736603499803e-02,7.321545647968999426e-02,-2.499265663159149983e-02,3.430885887772629900e-02,1.255315281338930007e-02,9.419076154073199869e-02
-9.996055470531900466e-02,-4.464163650698899782e-02,-6.764124234701959781e-02,-1.089567313670219972e-01,-7.449446130487119566e-02,-7.271172671423199729e-02,1.550535921336619952e-02,-3.949338287409189657e-02,-4.986846773523059828e-02,-9.361911330135799444e-03
-6.000263174410389727e-02,5.068011873981870252e-02,-1.051720243133190055e-02,-1.485159908304049987e-02,-4.972730985725089953e-02,-2.354741821327540133e-02,-5.812739686837520292e-02,1.585829843977170153e-02,-9.918957363154769225e-03,-3.421455281914410201e-02
1.991321417832630017e-02,-4.464163650698899782e-02,-2.345094731790270046e-02,-7.108515373592319553e-02,2.044628591100669870e-02,-1.008203435632550049e-02,1.185912177278039964e-01,-7.639450375000099436e-02,-4.257210492279420166e-02,7.348022696655839847e-02
4.534098333546320025e-02,5.068011873981870252e-02,6.816307896197400240e-02,8.100872220010799790e-03,-1.670444126042380101e-02,4.635943347782499856e-03,-7.653558588881050062e-02,7.120997975363539678e-02,3.243322577960189995e-02,-1.764612515980519894e-02
2.717829108036539862e-02,5.068011873981870252e-02,-3.530688013059259805e-02,3.220096707616459941e-02,-1.120062982761920074e-02,1.504458729887179960e-03,-1.026610541524320026e-02,-2.592261998182820038e-03,-1.495647502491130078e-02,-5.078298047848289754e-02
-5.637009329308430294e-02,-4.464163650698899782e-02,-1.159501450521270051e-02,-3.321357610482440076e-02,-4.697540414084860200e-02,-4.765984977106939996e-02,4.460445801105040325e-03,-3.949338287409189657e-02,-7.979397554541639223e-03,-8.806194271199530021e-02
-7.816532399920170238e-02,-4.464163650698899782e-02,-7.303030271642410587e-02,-5.731367096097819691e-02,-8.412613131227909824e-02,-7.427746902317970690e-02,-2.499265663159149983e-02,-3.949338287409189657e-02,-1.811826730789670159e-02,-8.391983579716059960e-02
6.713621404158050254e-02,5.068011873981870252e-02,-4.177375257387799801e-02,1.154374291374709975e-02,2.558898754392050119e-03,5.888537194940629722e-03,4.127682384197570165e-02,-3.949338287409189657e-02,-5.947269741072230137e-02,-2.178823207463989955e-02
-4.183993948900609910e-02,5.068011873981870252e-02,1.427247526792889930e-02,-5.670610554934250001e-03,-1.257658268582039982e-02,6.201685656730160021e-03,-7.285394808472339667e-02,7.120997975363539678e-02,3.546193866076970125e-02,-1.350401824497050006e-02
3.444336798240450054e-02,-4.464163650698899782e-02,-7.283766209689159811e-03,1.498661360748330083e-02,-4.422349842444640161e-02,-3.732595053201490098e-02,-2.902829807069099918e-03,-3.949338287409189657e-02,-2.139368094035999993e-02,7.206516329203029904e-03
5.987113713954139715e-02,5.068011873981870252e-02,1.642809941569069870e-02,2.875809638242839833e-02,-4.147159270804409714e-02,-2.918409052548700047e-02,-2.867429443567860031e-02,-2.592261998182820038e-03,-2.396681493414269844e-03,-2.178823207463989955e-02
-5.273755484206479882e-02,-4.464163650698899782e-02,-9.439390357450949676e-03,-5.670610554934250001e-03,3.970962592582259754e-02,4.471894645684260094e-02,2.655027262562750096e-02,-2.592261998182820038e-03,-1.811826730789670159e-02,-1.350401824497050006e-02
-9.147093429830140468e-03,-4.464163650698899782e-02,-1.590626280073640167e-02,7.007254470726349826e-02,1.219056876180000040e-02,2.217225720799630151e-02,1.550535921336619952e-02,-2.592261998182820038e-03,-3.324878724762579674e-02,4.862758547755009764e-02
-4.910501639104519755e-02,-4.464163650698899782e-02,2.505059600673789980e-02,8.100872220010799790e-03,2.044628591100669870e-02,1.778817874294279927e-02,5.232173725423699961e-02,-3.949338287409189657e-02,-4.118038518800790082e-02,7.206516329203029904e-03
-4.183993948900609910e-02,-4.464163650698899782e-02,-4.931843709104429679e-02,-3.665644679856060184e-02,-7.072771253015849857e-03,-2.260797282790679916e-02,8.545647749102060209e-02,-3.949338287409189657e-02,-6.648814822283539983e-02,7.206516329203029904e-03
-4.183993948900609910e-02,-4.464163650698899782e-02,4.121777711495139968e-02,-2.632783471735180084e-02,-3.183992270063620150e-02,-3.043668437264510085e-02,-3.603757004385269719e-02,2.942906133203560069e-03,3.365681290238470291e-02,-1.764612515980519894e-02
-2.730978568492789874e-02,-4.464163650698899782e-02,-6.332999405149600247e-02,-5.042792957350569760e-02,-8.962994274508359616e-02,-1.043397213549750041e-01,5.232173725423699961e-02,-7.639450375000099436e-02,-5.615757309500619965e-02,-6.735140813782170000e-02
4.170844488444359899e-02,-4.464163650698899782e-02,-6.440780612537699845e-02,3.564383776990089764e-02,1.219056876180000040e-02,-5.799374901012400302e-02,1.811790603972839864e-01,-7.639450375000099436e-02,-6.092541861022970299e-04,-5.078298047848289754e-02
6.350367559056099842e-02,5.068011873981870252e-02,-2.560657146566450160e-02,1.154374291374709975e-02,6.447677737344290061e-02,4.847672799831700269e-02,3.023191042971450082e-02,-2.592261998182820038e-03,3.839324821169769891e-02,1.963283707370720027e-02
-7.090024709716259699e-02,-4.464163650698899782e-02,-4.050329988046450294e-03,-4.009931749229690007e-02,-6.623874415566440021e-02,-7.866154748823310505e-02,5.232173725423699961e-02,-7.639450375000099436e-02,-5.140053526058249722e-02,-3.421455281914410201e-02
-4.183993948900609910e-02,5.068011873981870252e-02,4.572166603000769880e-03,-5.387080026724189868e-02,-4.422349842444640161e-02,-2.730519975474979960e-02,-8.021722369289760457e-02,7.120997975363539678e-02,3.664579779339879884e-02,1.963283707370720027e-02
-2.730978568492789874e-02,5.068011873981870252e-02,-7.283766209689159811e-03,-4.009931749229690007e-02,-1.120062982761920074e-02,-1.383981589779990050e-02,5.968501286241110343e-02,-3.949338287409189657e-02,-8.238148325810279449e-02,-2.593033898947460017e-02
-3.457486258696700065e-02,-4.464163650698899782e-02,-3.746250427835440266e-02,-6.075654165471439799e-02,2.044628591100669870e-02,4.346635260968449710e-02,-1.394774321933030074e-02,-2.592261998182820038e-03,-3.075120986455629965e-02,-7.149351505265640061e-02
6.713621404158050254e-02,5.068011873981870252e-02,-2.560657146566450160e-02,-4.009931749229690007e-02,-6.348683843926219983e-02,-5.987263978086120042e-02,-2.902829807069099918e-03,-3.949338287409189657e-02,-1.919704761394450121e-02,1.134862324403770016e-02
-4.547247794002570037e-02,5.068011873981870252e-02,-2.452875939178359929e-02,5.974393262605470073e-02,5.310804470794310353e-03,1.496984258683710031e-02,-5.444575906428809897e-02,7.120997975363539678e-02,4.234489544960749752e-02,1.549073015887240078e-02
-9.147093429830140468e-03,5.068011873981870252e-02,-1.806188694849819934e-02,-3.321357610482440076e-02,-2.083229983502719873e-02,1.215150643073130074e-02,-7.285394808472339667e-02,7.120997975363539678e-02,2.714857279071319972e-04,1.963283707370720027e-02
4.170844488444359899e-02,5.068011873981870252e-02,-1.482845072685549936e-02,-1.714684618924559867e-02,-5.696818394814720174e-03,8.393724889256879915e-03,-1.394774321933030074e-02,-1.854239580664649974e-03,-1.190068480150809939e-02,3.064409414368320182e-03
3.807590643342410180e-02,5.068011873981870252e-02,-2.991781976118810041e-02,-4.009931749229690007e-02,-3.321587555883730170e-02,-2.417371513685449835e-02,-1.026610541524320026e-02,-2.592261998182820038e-03,-1.290794225416879923e-02,3.064409414368320182e-03
1.628067572730669890e-02,-4.464163650698899782e-02,-4.608500086940160029e-02,-5.670610554934250001e-03,-7.587041416307230279e-02,-6.143838208980879900e-02,-1.394774321933030074e-02,-3.949338287409189657e-02,-5.140053526058249722e-02,1.963283707370720027e-02
-1.882016527791040067e-03,-4.464163650698899782e-02,-6.979686649478139548e-02,-1.255635194240680048e-02,-1.930069620102049918e-04,-9.142588970956939953e-03,7.072992627467229731e-02,-3.949338287409189657e-02,-6.291294991625119570e-02,4.034337164788070335e-02
-1.882016527791040067e-03,-4.464163650698899782e-02,3.367309259778510089e-02,1.251584758070440062e-01,2.457414448561009990e-02,2.624318721126020146e-02,-1.026610541524320026e-02,-2.592261998182820038e-03,2.671425763351279944e-02,6.105390622205419948e-02
6.350367559056099842e-02,5.068011873981870252e-02,-4.050329988046450294e-03,-1.255635194240680048e-02,1.030034574030749966e-01,4.878987646010649742e-02,5.600337505832399948e-02,-2.592261998182820038e-03,8.449528221240310000e-02,-1.764612515980519894e-02
1.264813727628719998e-02,5.068011873981870252e-02,-2.021751109626000048e-02,-2.227739861197989939e-03,3.833367306762140020e-02,5.317395492515999966e-02,-6.584467611156170040e-03,3.430885887772629900e-02,-5.145307980263110273e-03,-9.361911330135799444e-03
1.264813727628719998e-02,5.068011873981870252e-02,2.416542455238970041e-03,5.630106193231849965e-02,2.732605020201240090e-02,1.716188181936379939e-02,4.127682384197570165e-02,-3.949338287409189657e-02,3.711738233435969789e-03,7.348022696655839847e-02
-9.147093429830140468e-03,5.068011873981870252e-02,-3.099563183506899924e-02,-2.632783471735180084e-02,-1.120062982761920074e-02,-1.000728964429089965e-03,-2.131101882750449997e-02,-2.592261998182820038e-03,6.209315616505399656e-03,2.791705090337660150e-02
-3.094232413594750000e-02,5.068011873981870252e-02,2.828403222838059977e-02,7.007254470726349826e-02,-1.267806699165139883e-01,-1.068449090492910036e-01,-5.444575906428809897e-02,-4.798064067555100204e-02,-3.075120986455629965e-02,1.549073015887240078e-02
-9.632801625429950054e-02,-4.464163650698899782e-02,-3.638469220447349689e-02,-7.452802442965950069e-02,-3.871968699164179961e-02,-2.761834821653930128e-02,1.550535921336619952e-02,-3.949338287409189657e-02,-7.408887149153539631e-02,-1.077697500466389974e-03
5.383060374248070309e-03,-4.464163650698899782e-02,-5.794093368209150136e-02,-2.288496402361559975e-02,-6.761469701386560449e-02,-6.832764824917850199e-02,-5.444575906428809897e-02,-2.592261998182820038e-03,4.289568789252869857e-02,-8.391983579716059960e-02
-1.035930931563389945e-01,-4.464163650698899782e-02,-3.746250427835440266e-02,-2.632783471735180084e-02,2.558898754392050119e-03,1.998021797546959896e-02,1.182372140927919965e-02,-2.592261998182820038e-03,-6.832974362442149896e-02,-2.593033898947460017e-02
7.076875249260000666e-02,-4.464163650698899782e-02,1.211685112016709989e-02,4.252957915737339695e-02,7.135654166444850566e-02,5.348710338694950134e-02,5.232173725423699961e-02,-2.592261998182820038e-03,2.539313491544940155e-02,-5.219804415301099697e-03
1.264813727628719998e-02,5.068011873981870252e-02,-2.237313524402180162e-02,-2.977070541108809906e-02,1.081461590359879960e-02,2.843522644378690054e-02,-2.131101882750449997e-02,3.430885887772629900e-02,-6.080248196314420352e-03,-1.077697500466389974e-03
-1.641217033186929963e-02,-4.464163650698899782e-02,-3.530688013059259805e-02,-2.632783471735180084e-02,3.282986163481690228e-02,1.716188181936379939e-02,1.001830287073690040e-01,-3.949338287409189657e-02,-7.020931272868760620e-02,-7.977772888232589898e-02
-3.820740103798660192e-02,-4.464163650698899782e-02,9.961226972405269262e-03,-4.698505887976939938e-02,-5.935897986465880211e-02,-5.298337362149149743e-02,-1.026610541524320026e-02,-3.949338287409189657e-02,-1.599826775813870117e-02,-4.249876664881350324e-02
1.750521923228520000e-03,-4.464163650698899782e-02,-3.961812842611620034e-02,-1.009233664264470032e-01,-2.908801698423390050e-02,-3.012353591085559917e-02,4.495846164606279866e-02,-5.019470792810550031e-02,-6.832974362442149896e-02,-1.294830118603420011e-01
4.534098333546320025e-02,-4.464163650698899782e-02,7.139651518361660176e-02,1.215130832538269907e-03,-9.824676969418109224e-03,-1.000728964429089965e-03,1.550535921336619952e-02,-3.949338287409189657e-02,-4.118038518800790082e-02,-7.149351505265640061e-02
-7.090024709716259699e-02,5.068011873981870252e-02,-7.518592686418590354e-02,-4.009931749229690007e-02,-5.110326271545199972e-02,-1.509240974495799914e-02,-3.971920784793980114e-02,-2.592261998182820038e-03,-9.643322289178400675e-02,-3.421455281914410201e-02
4.534098333546320025e-02,-4.464163650698899782e-02,-6.205954135808240159e-03,1.154374291374709975e-02,6.310082451524179348e-02,1.622243643399520069e-02,9.650139090328180291e-02,-3.949338287409189657e-02,4.289568789252869857e-02,-3.835665973397880263e-02
-5.273755484206479882e-02,5.068011873981870252e-02,-4.069594049999709917e-02,-6.764228304218700139e-02,-3.183992270063620150e-02,-3.701280207022530216e-02,3.759518603788870178e-02,-3.949338287409189657e-02,-3.452371533034950118e-02,6.933812005172369786e-02
-4.547247794002570037e-02,-4.464163650698899782e-02,-4.824062501716339796e-02,-1.944209332987930153e-02,-1.930069620102049918e-04,-1.603185513032660131e-02,6.704828847058519337e-02,-3.949338287409189657e-02,-2.479118743246069845e-02,1.963283707370720027e-02
1.264813727628719998e-02,-4.464163650698899782e-02,-2.560657146566450160e-02,-4.009931749229690007e-02,-3.046396984243510131e-02,-4.515466207675319921e-02,7.809320188284639419e-02,-7.639450375000099436e-02,-7.212845460195599356e-02,1.134862324403770016e-02
4.534098333546320025e-02,-4.464163650698899782e-02,5.199589785376040191e-02,-5.387080026724189868e-02,6.310082451524179348e-02,6.476044801137270657e-02,-1.026610541524320026e-02,3.430885887772629900e-02,3.723201120896890010e-02,1.963283707370720027e-02
-2.004470878288880029e-02,-4.464163650698899782e-02,4.572166603000769880e-03,9.761551025715360652e-02,5.310804470794310353e-03,-2.072908205716959829e-02,6.336665066649820044e-02,-3.949338287409189657e-02,1.255315281338930007e-02,1.134862324403770016e-02
-4.910501639104519755e-02,-4.464163650698899782e-02,-6.440780612537699845e-02,-1.020709899795499975e-01,-2.944912678412469915e-03,-1.540555820674759969e-02,6.336665066649820044e-02,-4.724261825803279663e-02,-3.324878724762579674e-02,-5.492508739331759815e-02
-7.816532399920170238e-02,-4.464163650698899782e-02,-1.698407487461730050e-02,-1.255635194240680048e-02,-1.930069620102049918e-04,-1.352666743601040056e-02,7.072992627467229731e-02,-3.949338287409189657e-02,-4.118038518800790082e-02,-9.220404962683000083e-02
-7.090024709716259699e-02,-4.464163650698899782e-02,-5.794093368209150136e-02,-8.141376581713200000e-02,-4.559945128264750180e-02,-2.887094206369749880e-02,-4.340084565202689815e-02,-2.592261998182820038e-03,1.143797379512540100e-03,-5.219804415301099697e-03
5.623859868852180283e-02,5.068011873981870252e-02,9.961226972405269262e-03,4.941532054484590319e-02,-4.320865536613589623e-03,-1.227407358885230018e-02,-4.340084565202689815e-02,3.430885887772629900e-02,6.078775415074400001e-02,3.205915781821130212e-02
-2.730978568492789874e-02,-4.464163650698899782e-02,8.864150836571099701e-02,-2.518021116424929914e-02,2.182223876920789951e-02,4.252690722431590187e-02,-3.235593223976569732e-02,3.430885887772629900e-02,2.863770518940129874e-03,7.762233388139309909e-02
1.750521923228520000e-03,5.068011873981870252e-02,-5.128142061927360405e-03,-1.255635194240680048e-02,-1.532848840222260020e-02,-1.383981589779990050e-02,8.142083605192099172e-03,-3.949338287409189657e-02,-6.080248196314420352e-03,-6.735140813782170000e-02
-1.882016527791040067e-03,-4.464163650698899782e-02,-6.440780612537699845e-02,1.154374291374709975e-02,2.732605020201240090e-02,3.751653183568340322e-02,-1.394774321933030074e-02,3.430885887772629900e-02,1.178390038357590014e-02,-5.492508739331759815e-02
1.628067572730669890e-02,-4.464163650698899782e-02,1.750591148957160101e-02,-2.288496402361559975e-02,6.034891879883950289e-02,4.440579799505309927e-02,3.023191042971450082e-02,-2.592261998182820038e-03,3.723201120896890010e-02,-1.077697500466389974e-03
1.628067572730669890e-02,5.068011873981870252e-02,-4.500718879552070145e-02,6.318680331979099896e-02,1.081461590359879960e-02,-3.744320408500199904e-04,6.336665066649820044e-02,-3.949338287409189657e-02,-3.075120986455629965e-02,3.620126473304600273e-02
-9.269547780327989928e-02,-4.464163650698899782e-02,2.828403222838059977e-02,-1.599922263614299983e-02,3.695772020942030001e-02,2.499059336410210108e-02,5.600337505832399948e-02,-3.949338287409189657e-02,-5.145307980263110273e-03,-1.077697500466389974e-03
5.987113713954139715e-02,5.068011873981870252e-02,4.121777711495139968e-02,1.154374291374709975e-02,4.108557878402369773e-02,7.071026878537380045e-02,-3.603757004385269719e-02,3.430885887772629900e-02,-1.090443584737709956e-02,-3.007244590430930078e-02
-2.730978568492789874e-02,-4.464163650698899782e-02,6.492964274033119487e-02,-2.227739861197989939e-03,-2.496015840963049931e-02,-1.728444897748479883e-02,2.286863482154040048e-02,-3.949338287409189657e-02,-6.117659509433449883e-02,-6.320930122298699938e-02
2.354575262934580082e-02,5.068011873981870252e-02,-3.207344390894990155e-02,-4.009931749229690007e-02,-3.183992270063620150e-02,-2.166852744253820046e-02,-1.394774321933030074e-02,-2.592261998182820038e-03,-1.090443584737709956e-02,1.963283707370720027e-02
-9.632801625429950054e-02,-4.464163650698899782e-02,-7.626373893806680238e-02,-4.354218818603310115e-02,-4.559945128264750180e-02,-3.482076283769860309e-02,8.142083605192099172e-03,-3.949338287409189657e-02,-5.947269741072230137e-02,-8.391983579716059960e-02
2.717829108036539862e-02,-4.464163650698899782e-02,4.984027370599859730e-02,-5.501842382034440038e-02,-2.944912678412469915e-03,4.064801645357869753e-02,-5.812739686837520292e-02,5.275941931568080279e-02,-5.295879323920039961e-02,-5.219804415301099697e-03
1.991321417832630017e-02,5.068011873981870252e-02,4.552902541047500196e-02,2.990571983224480160e-02,-6.211088558106100249e-02,-5.580170977759729700e-02,-7.285394808472339667e-02,2.692863470254440103e-02,4.560080841412490066e-02,4.034337164788070335e-02
3.807590643342410180e-02,5.068011873981870252e-02,-9.439390357450949676e-03,2.362754385640800005e-03,1.182945896190920002e-03,3.751653183568340322e-02,-5.444575906428809897e-02,5.017634085436720182e-02,-2.595242443518940012e-02,1.066170822852360034e-01
4.170844488444359899e-02,5.068011873981870252e-02,-3.207344390894990155e-02,-2.288496402361559975e-02,-4.972730985725089953e-02,-4.014428668812060341e-02,3.023191042971450082e-02,-3.949338287409189657e-02,-1.260973855604090033e-01,1.549073015887240078e-02
1.991321417832630017e-02,-4.464163650698899782e-02,4.572166603000769880e-03,-2.632783471735180084e-02,2.319819162740899970e-02,1.027261565999409987e-02,6.704828847058519337e-02,-3.949338287409189657e-02,-2.364455757213410059e-02,-4.664087356364819692e-02
-8.543040090124079389e-02,-4.464163650698899782e-02,2.073934771121430098e-02,-2.632783471735180084e-02,5.310804470794310353e-03,1.966706951368000014e-02,-2.902829807069099918e-03,-2.592261998182820038e-03,-2.364455757213410059e-02,3.064409414368320182e-03
1.991321417832630017e-02,5.068011873981870252e-02,1.427247526792889930e-02,6.318680331979099896e-02,1.494247447820220079e-02,2.029336643725910064e-02,-4.708248345611389801e-02,3.430885887772629900e-02,4.666077235681449775e-02,9.004865462589720093e-02
2.354575262934580082e-02,-4.464163650698899782e-02,1.101977498433290015e-01,6.318680331979099896e-02,1.356652162000110060e-02,-3.294187206696139875e-02,-2.499265663159149983e-02,2.065544415363990138e-02,9.924022573398999514e-02,2.377494398854190089e-02
-3.094232413594750000e-02,5.068011873981870252e-02,1.338730381358059929e-03,-5.670610554934250001e-03,6.447677737344290061e-02,4.941617338368559792e-02,-4.708248345611389801e-02,1.081111006295440019e-01,8.379676636552239877e-02,3.064409414368320182e-03
4.897352178648269744e-02,5.068011873981870252e-02,5.846277029704580186e-02,7.007254470726349826e-02,1.356652162000110060e-02,2.060651489904859884e-02,-2.131101882750449997e-02,3.430885887772629900e-02,2.200405045615050001e-02,2.791705090337660150e-02
5.987113713954139715e-02,-4.464163650698899782e-02,-2.129532317014089932e-02,8.728689817594480205e-02,4.521343735862710239e-02,3.156671106168230240e-02,-4.708248345611389801e-02,7.120997975363539678e-02,7.912108138965789905e-02,1.356118306890790048e-01
-5.637009329308430294e-02,5.068011873981870252e-02,-1.051720243133190055e-02,2.531522568869210010e-02,2.319819162740899970e-02,4.002171952999959703e-02,-3.971920784793980114e-02,3.430885887772629900e-02,2.061233072136409855e-02,5.691179930721949887e-02
1.628067572730669890e-02,-4.464163650698899782e-02,-4.716281294328249912e-02,-2.227739861197989939e-03,-1.945634697682600139e-02,-4.296262284422640298e-02,3.391354823380159783e-02,-3.949338287409189657e-02,2.736770754260900093e-02,2.791705090337660150e-02
-4.910501639104519755e-02,-4.464163650698899782e-02,4.572166603000769880e-03,1.154374291374709975e-02,-3.734373413344069942e-02,-1.853704282464289921e-02,-1.762938102341739949e-02,-2.592261998182820038e-03,-3.980959436433750137e-02,-2.178823207463989955e-02
6.350367559056099842e-02,-4.464163650698899782e-02,1.750591148957160101e-02,2.187235499495579841e-02,8.062710187196569719e-03,2.154596028441720101e-02,-3.603757004385269719e-02,3.430885887772629900e-02,1.990842087631829876e-02,1.134862324403770016e-02
4.897352178648269744e-02,5.068011873981870252e-02,8.109682384854470516e-02,2.187235499495579841e-02,4.383748450042589812e-02,6.413415108779360607e-02,-5.444575906428809897e-02,7.120997975363539678e-02,3.243322577960189995e-02,4.862758547755009764e-02
5.383060374248070309e-03,5.068011873981870252e-02,3.475090467166599972e-02,-1.080116308095460057e-03,1.525377602983150060e-01,1.987879896572929961e-01,-6.180903467246220279e-02,1.852344432601940039e-01,1.556684454070180086e-02,7.348022696655839847e-02
-5.514554978810590376e-03,-4.464163650698899782e-02,2.397278393285700096e-02,8.100872220010799790e-03,-3.459182841703849903e-02,-3.889169284096249957e-02,2.286863482154040048e-02,-3.949338287409189657e-02,-1.599826775813870117e-02,-1.350401824497050006e-02
-5.514554978810590376e-03,5.068011873981870252e-02,-8.361578283570040432e-03,-2.227739861197989939e-03,-3.321587555883730170e-02,-6.363042132233559522e-02,-3.603757004385269719e-02,-2.592261998182820038e-03,8.058546423866649877e-02,7.206516329203029904e-03
-8.906293935226029801e-02,-4.464163650698899782e-02,-6.117436990373419786e-02,-2.632783471735180084e-02,-5.523112129005539744e-02,-5.454911593043910295e-02,4.127682384197570165e-02,-7.639450375000099436e-02,-9.393564550871469354e-02,-5.492508739331759815e-02
3.444336798240450054e-02,5.068011873981870252e-02,-1.894705840284650021e-03,-1.255635194240680048e-02,3.833367306762140020e-02,1.371724873967889932e-02,7.809320188284639419e-02,-3.949338287409189657e-02,4.551890466127779880e-03,-9.634615654166470144e-02
-5.273755484206479882e-02,-4.464163650698899782e-02,-6.225218197761509670e-02,-2.632783471735180084e-02,-5.696818394814720174e-03,-5.071658967693000106e-03,3.023191042971450082e-02,-3.949338287409189657e-02,-3.075120986455629965e-02,-7.149351505265640061e-02
9.015598825267629943e-03,-4.464163650698899782e-02,1.642809941569069870e-02,4.658001526274530187e-03,9.438663045397699403e-03,1.058576412178359981e-02,-2.867429443567860031e-02,3.430885887772629900e-02,3.896836603088559697e-02,1.190434030297399942e-01
-6.363517019512339445e-02,5.068011873981870252e-02,9.618619288287730273e-02,1.045012516446259948e-01,-2.944912678412469915e-03,-4.758510505903469807e-03,-6.584467611156170040e-03,-2.592261998182820038e-03,2.269202256674450122e-02,7.348022696655839847e-02
-9.632801625429950054e-02,-4.464163650698899782e-02,-6.979686649478139548e-02,-6.764228304218700139e-02,-1.945634697682600139e-02,-1.070833127990459925e-02,1.550535921336619952e-02,-3.949338287409189657e-02,-4.687948284421659950e-02,-7.977772888232589898e-02
1.628067572730669890e-02,5.068011873981870252e-02,-2.129532317014089932e-02,-9.113481248670509197e-03,3.420581449301800248e-02,4.785043107473799934e-02,7.788079970179680352e-04,-2.592261998182820038e-03,-1.290794225416879923e-02,2.377494398854190089e-02
-4.183993948900609910e-02,5.068011873981870252e-02,-5.362968538656789907e-02,-4.009931749229690007e-02,-8.412613131227909824e-02,-7.177228132886340206e-02,-2.902829807069099918e-03,-3.949338287409189657e-02,-7.212845460195599356e-02,-3.007244590430930078e-02
-7.453278554818210111e-02,-4.464163650698899782e-02,4.337340126271319735e-02,-3.321357610482440076e-02,1.219056876180000040e-02,2.518648827290310109e-04,6.336665066649820044e-02,-3.949338287409189657e-02,-2.712864555432650121e-02,-4.664087356364819692e-02
-5.514554978810590376e-03,-4.464163650698899782e-02,5.630714614928399725e-02,-3.665644679856060184e-02,-4.835135699904979933e-02,-4.296262284422640298e-02,-7.285394808472339667e-02,3.799897096531720114e-02,5.078151336297320045e-02,5.691179930721949887e-02
-9.269547780327989928e-02,-4.464163650698899782e-02,-8.165279930747129655e-02,-5.731367096097819691e-02,-6.073493272285990230e-02,-6.801449978738899338e-02,4.864009945014990260e-02,-7.639450375000099436e-02,-6.648814822283539983e-02,-2.178823207463989955e-02
5.383060374248070309e-03,-4.464163650698899782e-02,4.984027370599859730e-02,9.761551025715360652e-02,-1.532848840222260020e-02,-1.634500359211620013e-02,-6.584467611156170040e-03,-2.592261998182820038e-03,1.703713241477999851e-02,-1.350401824497050006e-02
3.444336798240450054e-02,5.068011873981870252e-02,1.112755619172099975e-01,7.695828609473599757e-02,-3.183992270063620150e-02,-3.388131745233000092e-02,-2.131101882750449997e-02,-2.592261998182820038e-03,2.801650652326400162e-02,7.348022696655839847e-02
2.354575262934580082e-02,-4.464163650698899782e-02,6.169620651868849837e-02,5.285819123858220142e-02,-3.459182841703849903e-02,-4.891244361822749687e-02,-2.867429443567860031e-02,-2.592261998182820038e-03,5.472400334817909689e-02,-5.219804415301099697e-03
4.170844488444359899e-02,5.068011873981870252e-02,1.427247526792889930e-02,4.252957915737339695e-02,-3.046396984243510131e-02,-1.313877426218630021e-03,-4.340084565202689815e-02,-2.592261998182820038e-03,-3.324878724762579674e-02,1.549073015887240078e-02
-2.730978568492789874e-02,-4.464163650698899782e-02,4.768464955823679963e-02,-4.698505887976939938e-02,3.420581449301800248e-02,5.724488492842390308e-02,-8.021722369289760457e-02,1.302517731550900115e-01,4.506616833626150148e-02,1.314697237742440128e-01
4.170844488444359899e-02,5.068011873981870252e-02,1.211685112016709989e-02,3.908670846363720280e-02,5.484510736603499803e-02,4.440579799505309927e-02,4.460445801105040325e-03,-2.592261998182820038e-03,4.560080841412490066e-02,-1.077697500466389974e-03
-3.094232413594750000e-02,-4.464163650698899782e-02,5.649978676881649634e-03,-9.113481248670509197e-03,1.907033305280559851e-02,6.827982580309210209e-03,7.441156407875940126e-02,-3.949338287409189657e-02,-4.118038518800790082e-02,-4.249876664881350324e-02
3.081082953138499989e-02,5.068011873981870252e-02,4.660683748435590079e-02,-1.599922263614299983e-02,2.044628591100669870e-02,5.066876723084379891e-02,-5.812739686837520292e-02,7.120997975363539678e-02,6.209315616505399656e-03,7.206516329203029904e-03
-4.183993948900609910e-02,-4.464163650698899782e-02,1.285205550993039902e-01,6.318680331979099896e-02,-3.321587555883730170e-02,-3.262872360517189707e-02,1.182372140927919965e-02,-3.949338287409189657e-02,-1.599826775813870117e-02,-5.078298047848289754e-02
-3.094232413594750000e-02,5.068011873981870252e-02,5.954058237092670069e-02,1.215130832538269907e-03,1.219056876180000040e-02,3.156671106168230240e-02,-4.340084565202689815e-02,3.430885887772629900e-02,1.482271084126630077e-02,7.206516329203029904e-03
-5.637009329308430294e-02,-4.464163650698899782e-02,9.295275666123460623e-02,-1.944209332987930153e-02,1.494247447820220079e-02,2.342485105515439842e-02,-2.867429443567860031e-02,2.545258986750810123e-02,2.605608963368469949e-02,4.034337164788070335e-02
-6.000263174410389727e-02,5.068011873981870252e-02,1.535028734180979987e-02,-1.944209332987930153e-02,3.695772020942030001e-02,4.816357953652750101e-02,1.918699701745330000e-02,-2.592261998182820038e-03,-3.075120986455629965e-02,-1.077697500466389974e-03
-4.910501639104519755e-02,5.068011873981870252e-02,-5.128142061927360405e-03,-4.698505887976939938e-02,-2.083229983502719873e-02,-2.041593359538010008e-02,-6.917231028063640375e-02,7.120997975363539678e-02,6.123790751970099866e-02,-3.835665973397880263e-02
2.354575262934580082e-02,-4.464163650698899782e-02,7.031870310973570293e-02,2.531522568869210010e-02,-3.459182841703849903e-02,-1.446611282137899926e-02,-3.235593223976569732e-02,-2.592261998182820038e-03,-1.919704761394450121e-02,-9.361911330135799444e-03
1.750521923228520000e-03,-4.464163650698899782e-02,-4.050329988046450294e-03,-5.670610554934250001e-03,-8.448724111216979540e-03,-2.386056667506489953e-02,5.232173725423699961e-02,-3.949338287409189657e-02,-8.944018957797799166e-03,-1.350401824497050006e-02
-3.457486258696700065e-02,5.068011873981870252e-02,-8.168937664037369826e-04,7.007254470726349826e-02,3.970962592582259754e-02,6.695248724389940564e-02,-6.549067247654929980e-02,1.081111006295440019e-01,2.671425763351279944e-02,7.348022696655839847e-02
4.170844488444359899e-02,5.068011873981870252e-02,-4.392937672163980262e-02,6.318680331979099896e-02,-4.320865536613589623e-03,1.622243643399520069e-02,-1.394774321933030074e-02,-2.592261998182820038e-03,-3.452371533034950118e-02,1.134862324403770016e-02
6.713621404158050254e-02,5.068011873981870252e-02,2.073934771121430098e-02,-5.670610554934250001e-03,2.044628591100669870e-02,2.624318721126020146e-02,-2.902829807069099918e-03,-2.592261998182820038e-03,8.640282933063080789e-03,3.064409414368320182e-03
-2.730978568492789874e-02,5.068011873981870252e-02,6.061839444480759953e-02,4.941532054484590319e-02,8.511607024645979902e-02,8.636769187485039689e-02,-2.902829807069099918e-03,3.430885887772629900e-02,3.781447882634390162e-02,4.862758547755009764e-02
-1.641217033186929963e-02,-4.464163650698899782e-02,-1.051720243133190055e-02,1.215130832538269907e-03,-3.734373413344069942e-02,-3.576020822306719832e-02,1.182372140927919965e-02,-3.949338287409189657e-02,-2.139368094035999993e-02,-3.421455281914410201e-02
-1.882016527791040067e-03,5.068011873981870252e-02,-3.315125598283080038e-02,-1.829446977677679984e-02,3.145390877661580209e-02,4.284005568610550069e-02,-1.394774321933030074e-02,1.991742173612169944e-02,1.022564240495780000e-02,2.791705090337660150e-02
-1.277963188084970010e-02,-4.464163650698899782e-02,-6.548561819925780014e-02,-6.993753018282070077e-02,1.182945896190920002e-03,1.684873335757430118e-02,-2.902829807069099918e-03,-7.020396503291909812e-03,-3.075120986455629965e-02,-5.078298047848289754e-02
-5.514554978810590376e-03,-4.464163650698899782e-02,4.337340126271319735e-02,8.728689817594480205e-02,1.356652162000110060e-02,7.141131042098750048e-03,-1.394774321933030074e-02,-2.592261998182820038e-03,4.234489544960749752e-02,-1.764612515980519894e-02
-9.147093429830140468e-03,-4.464163650698899782e-02,-6.225218197761509670e-02,-7.452802442965950069e-02,-2.358420555142939912e-02,-1.321351897422090062e-02,4.460445801105040325e-03,-3.949338287409189657e-02,-3.581672810154919867e-02,-4.664087356364819692e-02
-4.547247794002570037e-02,5.068011873981870252e-02,6.385183066645029604e-02,7.007254470726349826e-02,1.332744202834990066e-01,1.314610703725430096e-01,-3.971920784793980114e-02,1.081111006295440019e-01,7.573758845754760549e-02,8.590654771106250032e-02
-5.273755484206479882e-02,-4.464163650698899782e-02,3.043965637614240091e-02,-7.452802442965950069e-02,-2.358420555142939912e-02,-1.133462820348369975e-02,-2.902829807069099918e-03,-2.592261998182820038e-03,-3.075120986455629965e-02,-1.077697500466389974e-03
1.628067572730669890e-02,5.068011873981870252e-02,7.247432725749750060e-02,7.695828609473599757e-02,-8.448724111216979540e-03,5.575388733151089883e-03,-6.584467611156170040e-03,-2.592261998182820038e-03,-2.364455757213410059e-02,6.105390622205419948e-02
4.534098333546320025e-02,-4.464163650698899782e-02,-1.913969902237900103e-02,2.187235499495579841e-02,2.732605020201240090e-02,-1.352666743601040056e-02,1.001830287073690040e-01,-3.949338287409189657e-02,1.776347786711730131e-02,-1.350401824497050006e-02
-4.183993948900609910e-02,-4.464163650698899782e-02,-6.656343027313869898e-02,-4.698505887976939938e-02,-3.734373413344069942e-02,-4.327577130601600180e-02,4.864009945014990260e-02,-3.949338287409189657e-02,-5.615757309500619965e-02,-1.350401824497050006e-02
-5.637009329308430294e-02,5.068011873981870252e-02,-6.009655782985329903e-02,-3.665644679856060184e-02,-8.825398988688250290e-02,-7.083283594349480683e-02,-1.394774321933030074e-02,-3.949338287409189657e-02,-7.814091066906959926e-02,-1.046303703713340055e-01
7.076875249260000666e-02,-4.464163650698899782e-02,6.924089103585480409e-02,3.793908501382069892e-02,2.182223876920789951e-02,1.504458729887179960e-03,-3.603757004385269719e-02,3.910600459159439823e-02,7.763278919555950675e-02,1.066170822852360034e-01
1.750521923228520000e-03,5.068011873981870252e-02,5.954058237092670069e-02,-2.227739861197989939e-03,6.172487165704060308e-02,6.319470570242499696e-02,-5.812739686837520292e-02,1.081111006295440019e-01,6.898221163630259556e-02,1.273276168594099922e-01
-1.882016527791040067e-03,-4.464163650698899782e-02,-2.668438353954540043e-02,4.941532054484590319e-02,5.897296594063840269e-02,-1.603185513032660131e-02,-4.708248345611389801e-02,7.120997975363539678e-02,1.335989800130079896e-01,1.963283707370720027e-02
2.354575262934580082e-02,5.068011873981870252e-02,-2.021751109626000048e-02,-3.665644679856060184e-02,-1.395253554402150001e-02,-1.509240974495799914e-02,5.968501286241110343e-02,-3.949338287409189657e-02,-9.643322289178400675e-02,-1.764612515980519894e-02
-2.004470878288880029e-02,-4.464163650698899782e-02,-4.608500086940160029e-02,-9.862811928581330378e-02,-7.587041416307230279e-02,-5.987263978086120042e-02,-1.762938102341739949e-02,-3.949338287409189657e-02,-5.140053526058249722e-02,-4.664087356364819692e-02
4.170844488444359899e-02,5.068011873981870252e-02,7.139651518361660176e-02,8.100872220010799790e-03,3.833367306762140020e-02,1.590928797220559840e-02,-1.762938102341739949e-02,3.430885887772629900e-02,7.341007804911610368e-02,8.590654771106250032e-02
-6.363517019512339445e-02,5.068011873981870252e-02,-7.949717515970949888e-02,-5.670610554934250001e-03,-7.174255558846899528e-02,-6.644875747844139480e-02,-1.026610541524320026e-02,-3.949338287409189657e-02,-1.811826730789670159e-02,-5.492508739331759815e-02
1.628067572730669890e-02,5.068011873981870252e-02,9.961226972405269262e-03,-4.354218818603310115e-02,-9.650970703608929835e-02,-9.463211903949929338e-02,-3.971920784793980114e-02,-3.949338287409189657e-02,1.703713241477999851e-02,7.206516329203029904e-03
6.713621404158050254e-02,-4.464163650698899782e-02,-3.854031635223530150e-02,-2.632783471735180084e-02,-3.183992270063620150e-02,-2.636575436938120090e-02,8.142083605192099172e-03,-3.949338287409189657e-02,-2.712864555432650121e-02,3.064409414368320182e-03
4.534098333546320025e-02,5.068011873981870252e-02,1.966153563733339868e-02,3.908670846363720280e-02,2.044628591100669870e-02,2.593003874947069978e-02,8.142083605192099172e-03,-2.592261998182820038e-03,-3.303712578676999863e-03,1.963283707370720027e-02
4.897352178648269744e-02,-4.464163650698899782e-02,2.720622015449970094e-02,-2.518021116424929914e-02,2.319819162740899970e-02,1.841447566652189977e-02,-6.180903467246220279e-02,8.006624876385350087e-02,7.222365081991240221e-02,3.205915781821130212e-02
4.170844488444359899e-02,-4.464163650698899782e-02,-8.361578283570040432e-03,-2.632783471735180084e-02,2.457414448561009990e-02,1.622243643399520069e-02,7.072992627467229731e-02,-3.949338287409189657e-02,-4.836172480289190057e-02,-3.007244590430930078e-02
-2.367724723390840155e-02,-4.464163650698899782e-02,-1.590626280073640167e-02,-1.255635194240680048e-02,2.044628591100669870e-02,4.127431337715779802e-02,-4.340084565202689815e-02,3.430885887772629900e-02,1.407245251576850001e-02,-9.361911330135799444e-03
-3.820740103798660192e-02,5.068011873981870252e-02,4.572166603000769880e-03,3.564383776990089764e-02,-1.120062982761920074e-02,5.888537194940629722e-03,-4.708248345611389801e-02,3.430885887772629900e-02,1.630495279994180133e-02,-1.077697500466389974e-03
4.897352178648269744e-02,-4.464163650698899782e-02,-4.285156464775889684e-02,-5.387080026724189868e-02,4.521343735862710239e-02,5.004247030726469841e-02,3.391354823380159783e-02,-2.592261998182820038e-03,-2.595242443518940012e-02,-6.320930122298699938e-02
4.534098333546320025e-02,5.068011873981870252e-02,5.649978676881649634e-03,5.630106193231849965e-02,6.447677737344290061e-02,8.918602803095619647e-02,-3.971920784793980114e-02,7.120997975363539678e-02,1.556684454070180086e-02,-9.361911330135799444e-03
4.534098333546320025e-02,5.068011873981870252e-02,-3.530688013059259805e-02,6.318680331979099896e-02,-4.320865536613589623e-03,-1.627025888008149911e-03,-1.026610541524320026e-02,-2.592261998182820038e-03,1.556684454070180086e-02,5.691179930721949887e-02
1.628067572730669890e-02,-4.464163650698899782e-02,2.397278393285700096e-02,-2.288496402361559975e-02,-2.496015840963049931e-02,-2.605260590759169922e-02,-3.235593223976569732e-02,-2.592261998182820038e-03,3.723201120896890010e-02,3.205915781821130212e-02
-7.453278554818210111e-02,5.068011873981870252e-02,-1.806188694849819934e-02,8.100872220010799790e-03,-1.945634697682600139e-02,-2.480001206043359885e-02,-6.549067247654929980e-02,3.430885887772629900e-02,6.731721791468489591e-02,-1.764612515980519894e-02
-8.179786245022120650e-02,5.068011873981870252e-02,4.229558918883229851e-02,-1.944209332987930153e-02,3.970962592582259754e-02,5.755803339021339782e-02,-6.917231028063640375e-02,1.081111006295440019e-01,4.718616788601970313e-02,-3.835665973397880263e-02
-6.726770864614299572e-02,-4.464163650698899782e-02,-5.470749746044879791e-02,-2.632783471735180084e-02,-7.587041416307230279e-02,-8.210618056791800512e-02,4.864009945014990260e-02,-7.639450375000099436e-02,-8.682899321629239386e-02,-1.046303703713340055e-01
5.383060374248070309e-03,-4.464163650698899782e-02,-2.972517914165530208e-03,4.941532054484590319e-02,7.410844738085080319e-02,7.071026878537380045e-02,4.495846164606279866e-02,-2.592261998182820038e-03,-1.498586820292070049e-03,-9.361911330135799444e-03
-1.882016527791040067e-03,-4.464163650698899782e-02,-6.656343027313869898e-02,1.215130832538269907e-03,-2.944912678412469915e-03,3.070201038834840124e-03,1.182372140927919965e-02,-2.592261998182820038e-03,-2.028874775162960165e-02,-2.593033898947460017e-02
9.015598825267629943e-03,-4.464163650698899782e-02,-1.267282657909369996e-02,2.875809638242839833e-02,-1.808039411862490120e-02,-5.071658967693000106e-03,-4.708248345611389801e-02,3.430885887772629900e-02,2.337484127982079885e-02,-5.219804415301099697e-03
-5.514554978810590376e-03,5.068011873981870252e-02,-4.177375257387799801e-02,-4.354218818603310115e-02,-7.999827273767569358e-02,-7.615635979391689736e-02,-3.235593223976569732e-02,-3.949338287409189657e-02,1.022564240495780000e-02,-9.361911330135799444e-03
5.623859868852180283e-02,5.068011873981870252e-02,-3.099563183506899924e-02,8.100872220010799790e-03,1.907033305280559851e-02,2.123281182262769934e-02,3.391354823380159783e-02,-3.949338287409189657e-02,-2.952762274177360077e-02,-5.906719430815229877e-02
9.015598825267629943e-03,5.068011873981870252e-02,-5.128142061927360405e-03,-6.419941234845069622e-02,6.998058880624739853e-02,8.386250418053420308e-02,-3.971920784793980114e-02,7.120997975363539678e-02,3.953987807202419963e-02,1.963283707370720027e-02
-6.726770864614299572e-02,-4.464163650698899782e-02,-5.901874575597240019e-02,3.220096707616459941e-02,-5.110326271545199972e-02,-4.953874054180659736e-02,-1.026610541524320026e-02,-3.949338287409189657e-02,2.007840549823790115e-03,2.377494398854190089e-02
2.717829108036539862e-02,5.068011873981870252e-02,2.505059600673789980e-02,1.498661360748330083e-02,2.595009734381130070e-02,4.847672799831700269e-02,-3.971920784793980114e-02,3.430885887772629900e-02,7.837142301823850701e-03,2.377494398854190089e-02
-2.367724723390840155e-02,-4.464163650698899782e-02,-4.608500086940160029e-02,-3.321357610482440076e-02,3.282986163481690228e-02,3.626393798852529937e-02,3.759518603788870178e-02,-2.592261998182820038e-03,-3.324878724762579674e-02,1.134862324403770016e-02
4.897352178648269744e-02,5.068011873981870252e-02,3.494354529119849794e-03,7.007254470726349826e-02,-8.448724111216979540e-03,1.340410027788939938e-02,-5.444575906428809897e-02,3.430885887772629900e-02,1.331596790892770020e-02,3.620126473304600273e-02
-5.273755484206479882e-02,-4.464163650698899782e-02,5.415152200152219958e-02,-2.632783471735180084e-02,-5.523112129005539744e-02,-3.388131745233000092e-02,-1.394774321933030074e-02,-3.949338287409189657e-02,-7.408887149153539631e-02,-5.906719430815229877e-02
4.170844488444359899e-02,-4.464163650698899782e-02,-4.500718879552070145e-02,3.449621432008449784e-02,4.383748450042589812e-02,-1.571870666853709964e-02,3.759518603788870178e-02,-1.440062067847370023e-02,8.989869327767099905e-02,7.206516329203029904e-03
5.623859868852180283e-02,-4.464163650698899782e-02,-5.794093368209150136e-02,-7.965857695567990157e-03,5.209320164963270050e-02,4.910302492189610318e-02,5.600337505832399948e-02,-2.141183364489639834e-02,-2.832024254799870092e-02,4.448547856271539702e-02
-3.457486258696700065e-02,5.068011873981870252e-02,-5.578530953432969675e-02,-1.599922263614299983e-02,-9.824676969418109224e-03,-7.889995123798789270e-03,3.759518603788870178e-02,-3.949338287409189657e-02,-5.295879323920039961e-02,2.791705090337660150e-02
8.166636784565869944e-02,5.068011873981870252e-02,1.338730381358059929e-03,3.564383776990089764e-02,1.263946559924939983e-01,9.106491880169340081e-02,1.918699701745330000e-02,3.430885887772629900e-02,8.449528221240310000e-02,-3.007244590430930078e-02
-1.882016527791040067e-03,5.068011873981870252e-02,3.043965637614240091e-02,5.285819123858220142e-02,3.970962592582259754e-02,5.661858800484489973e-02,-3.971920784793980114e-02,7.120997975363539678e-02,2.539313491544940155e-02,2.791705090337660150e-02
1.107266754538149961e-01,5.068011873981870252e-02,6.727790750762559745e-03,2.875809638242839833e-02,-2.771206412603280031e-02,-7.263698200219739949e-03,-4.708248345611389801e-02,3.430885887772629900e-02,2.007840549823790115e-03,7.762233388139309909e-02
-3.094232413594750000e-02,-4.464163650698899782e-02,4.660683748435590079e-02,1.498661360748330083e-02,-1.670444126042380101e-02,-4.703355284749029946e-02,7.788079970179680352e-04,-2.592261998182820038e-03,6.345592137206540473e-02,-2.593033898947460017e-02
1.750521923228520000e-03,5.068011873981870252e-02,2.612840808061879863e-02,-9.113481248670509197e-03,2.457414448561009990e-02,3.845597722105199845e-02,-2.131101882750449997e-02,3.430885887772629900e-02,9.436409146079870192e-03,3.064409414368320182e-03
9.015598825267629943e-03,-4.464163650698899782e-02,4.552902541047500196e-02,2.875809638242839833e-02,1.219056876180000040e-02,-1.383981589779990050e-02,2.655027262562750096e-02,-3.949338287409189657e-02,4.613233103941480340e-02,3.620126473304600273e-02
3.081082953138499989e-02,-4.464163650698899782e-02,4.013996504107050084e-02,7.695828609473599757e-02,1.769438019460449832e-02,3.782968029747289795e-02,-2.867429443567860031e-02,3.430885887772629900e-02,-1.498586820292070049e-03,1.190434030297399942e-01
3.807590643342410180e-02,5.068011873981870252e-02,-1.806188694849819934e-02,6.662967401352719310e-02,-5.110326271545199972e-02,-1.665815205390569834e-02,-7.653558588881050062e-02,3.430885887772629900e-02,-1.190068480150809939e-02,-1.350401824497050006e-02
9.015598825267629943e-03,-4.464163650698899782e-02,1.427247526792889930e-02,1.498661360748330083e-02,5.484510736603499803e-02,4.722413415115889884e-02,7.072992627467229731e-02,-3.949338287409189657e-02,-3.324878724762579674e-02,-5.906719430815229877e-02
9.256398319871740610e-02,-4.464163650698899782e-02,3.690652881942779739e-02,2.187235499495579841e-02,-2.496015840963049931e-02,-1.665815205390569834e-02,7.788079970179680352e-04,-3.949338287409189657e-02,-2.251217192966049885e-02,-2.178823207463989955e-02
6.713621404158050254e-02,-4.464163650698899782e-02,3.494354529119849794e-03,3.564383776990089764e-02,4.934129593323050011e-02,3.125356259989280072e-02,7.072992627467229731e-02,-3.949338287409189657e-02,-6.092541861022970299e-04,1.963283707370720027e-02
1.750521923228520000e-03,-4.464163650698899782e-02,-7.087467856866229432e-02,-2.288496402361559975e-02,-1.568959820211340015e-03,-1.000728964429089965e-03,2.655027262562750096e-02,-3.949338287409189657e-02,-2.251217192966049885e-02,7.206516329203029904e-03
3.081082953138499989e-02,-4.464163650698899782e-02,-3.315125598283080038e-02,-2.288496402361559975e-02,-4.697540414084860200e-02,-8.116673518254939601e-02,1.038646665114559969e-01,-7.639450375000099436e-02,-3.980959436433750137e-02,-5.492508739331759815e-02
2.717829108036539862e-02,5.068011873981870252e-02,9.403056873511560221e-02,9.761551025715360652e-02,-3.459182841703849903e-02,-3.200242668159279658e-02,-4.340084565202689815e-02,-2.592261998182820038e-03,3.664579779339879884e-02,1.066170822852360034e-01
1.264813727628719998e-02,5.068011873981870252e-02,3.582871674554689856e-02,4.941532054484590319e-02,5.346915450783389784e-02,7.415490186505870052e-02,-6.917231028063640375e-02,1.450122215054540087e-01,4.560080841412490066e-02,4.862758547755009764e-02
7.440129094361959405e-02,-4.464163650698899782e-02,3.151746845002330322e-02,1.010583809508899950e-01,4.658939021682820258e-02,3.689023491210430272e-02,1.550535921336619952e-02,-2.592261998182820038e-03,3.365681290238470291e-02,4.448547856271539702e-02
-4.183993948900609910e-02,-4.464163650698899782e-02,-6.548561819925780014e-02,-4.009931749229690007e-02,-5.696818394814720174e-03,1.434354566325799982e-02,-4.340084565202689815e-02,3.430885887772629900e-02,7.026862549151949647e-03,-1.350401824497050006e-02
-8.906293935226029801e-02,-4.464163650698899782e-02,-4.177375257387799801e-02,-1.944209332987930153e-02,-6.623874415566440021e-02,-7.427746902317970690e-02,8.142083605192099172e-03,-3.949338287409189657e-02,1.143797379512540100e-03,-3.007244590430930078e-02
2.354575262934580082e-02,5.068011873981870252e-02,-3.961812842611620034e-02,-5.670610554934250001e-03,-4.835135699904979933e-02,-3.325502052875090042e-02,1.182372140927919965e-02,-3.949338287409189657e-02,-1.016435479455120028e-01,-6.735140813782170000e-02
-4.547247794002570037e-02,-4.464163650698899782e-02,-3.854031635223530150e-02,-2.632783471735180084e-02,-1.532848840222260020e-02,8.781618063081050515e-04,-3.235593223976569732e-02,-2.592261998182820038e-03,1.143797379512540100e-03,-3.835665973397880263e-02
-2.367724723390840155e-02,5.068011873981870252e-02,-2.560657146566450160e-02,4.252957915737339695e-02,-5.385516843185429725e-02,-4.765984977106939996e-02,-2.131101882750449997e-02,-3.949338287409189657e-02,1.143797379512540100e-03,1.963283707370720027e-02
-9.996055470531900466e-02,-4.464163650698899782e-02,-2.345094731790270046e-02,-6.419941234845069622e-02,-5.798302700645770191e-02,-6.018578824265070210e-02,1.182372140927919965e-02,-3.949338287409189657e-02,-1.811826730789670159e-02,-5.078298047848289754e-02
-2.730978568492789874e-02,-4.464163650698899782e-02,-6.656343027313869898e-02,-1.123996020607579971e-01,-4.972730985725089953e-02,-4.139688053527879746e-02,7.788079970179680352e-04,-3.949338287409189657e-02,-3.581672810154919867e-02,-9.361911330135799444e-03
3.081082953138499989e-02,5.068011873981870252e-02,3.259528052390420205e-02,4.941532054484590319e-02,-4.009563984984299695e-02,-4.358891976780549654e-02,-6.917231028063640375e-02,3.430885887772629900e-02,6.301661511474640487e-02,3.064409414368320182e-03
-1.035930931563389945e-01,5.068011873981870252e-02,-4.608500086940160029e-02,-2.632783471735180084e-02,-2.496015840963049931e-02,-2.480001206043359885e-02,3.023191042971450082e-02,-3.949338287409189657e-02,-3.980959436433750137e-02,-5.492508739331759815e-02
6.713621404158050254e-02,5.068011873981870252e-02,-2.991781976118810041e-02,5.744868538213489945e-02,-1.930069620102049918e-04,-1.571870666853709964e-02,7.441156407875940126e-02,-5.056371913686460301e-02,-3.845911230135379971e-02,7.206516329203029904e-03
-5.273755484206479882e-02,-4.464163650698899782e-02,-1.267282657909369996e-02,-6.075654165471439799e-02,-1.930069620102049918e-04,8.080576427467340075e-03,1.182372140927919965e-02,-2.592261998182820038e-03,-2.712864555432650121e-02,-5.078298047848289754e-02
-2.730978568492789874e-02,5.068011873981870252e-02,-1.590626280073640167e-02,-2.977070541108809906e-02,3.934851612593179802e-03,-6.875805026395569565e-04,4.127682384197570165e-02,-3.949338287409189657e-02,-2.364455757213410059e-02,1.134862324403770016e-02
-3.820740103798660192e-02,5.068011873981870252e-02,7.139651518361660176e-02,-5.731367096097819691e-02,1.539137131565160022e-01,1.558866503921270130e-01,7.788079970179680352e-04,7.194800217115350505e-02,5.027649338998960160e-02,6.933812005172369786e-02
9.015598825267629943e-03,-4.464163650698899782e-02,-3.099563183506899924e-02,2.187235499495579841e-02,8.062710187196569719e-03,8.706873351046409346e-03,4.460445801105040325e-03,-2.592261998182820038e-03,9.436409146079870192e-03,1.134862324403770016e-02
1.264813727628719998e-02,5.068011873981870252e-02,2.609183074771409820e-04,-1.140872838930430053e-02,3.970962592582259754e-02,5.724488492842390308e-02,-3.971920784793980114e-02,5.608052019451260223e-02,2.405258322689299982e-02,3.205915781821130212e-02
6.713621404158050254e-02,-4.464163650698899782e-02,3.690652881942779739e-02,-5.042792957350569760e-02,-2.358420555142939912e-02,-3.450761437590899733e-02,4.864009945014990260e-02,-3.949338287409189657e-02,-2.595242443518940012e-02,-3.835665973397880263e-02
4.534098333546320025e-02,-4.464163650698899782e-02,3.906215296718960200e-02,4.597244985110970211e-02,6.686757328995440036e-03,-2.417371513685449835e-02,8.142083605192099172e-03,-1.255556463467829946e-02,6.432823302367089713e-02,5.691179930721949887e-02
6.713621404158050254e-02,5.068011873981870252e-02,-1.482845072685549936e-02,5.859630917623830093e-02,-5.935897986465880211e-02,-3.450761437590899733e-02,-6.180903467246220279e-02,1.290620876969899959e-02,-5.145307980263110273e-03,4.862758547755009764e-02
2.717829108036539862e-02,-4.464163650698899782e-02,6.727790750762559745e-03,3.564383776990089764e-02,7.961225881365530110e-02,7.071026878537380045e-02,1.550535921336619952e-02,3.430885887772629900e-02,4.067226371449769728e-02,1.134862324403770016e-02
5.623859868852180283e-02,-4.464163650698899782e-02,-6.871905442090049665e-02,-6.878990659528949614e-02,-1.930069620102049918e-04,-1.000728964429089965e-03,4.495846164606279866e-02,-3.764832683029650101e-02,-4.836172480289190057e-02,-1.077697500466389974e-03
3.444336798240450054e-02,5.068011873981870252e-02,-9.439390357450949676e-03,5.974393262605470073e-02,-3.596778127523959923e-02,-7.576846662009279788e-03,-7.653558588881050062e-02,7.120997975363539678e-02,1.100810104587249955e-02,-2.178823207463989955e-02
2.354575262934580082e-02,-4.464163650698899782e-02,1.966153563733339868e-02,-1.255635194240680048e-02,8.374011738825870577e-02,3.876912568284150012e-02,6.336665066649820044e-02,-2.592261998182820038e-03,6.604820616309839409e-02,4.862758547755009764e-02
4.897352178648269744e-02,5.068011873981870252e-02,7.462995140525929827e-02,6.662967401352719310e-02,-9.824676969418109224e-03,-2.253322811587220049e-03,-4.340084565202689815e-02,3.430885887772629900e-02,3.365681290238470291e-02,1.963283707370720027e-02
3.081082953138499989e-02,5.068011873981870252e-02,-8.361578283570040432e-03,4.658001526274530187e-03,1.494247447820220079e-02,2.749578105841839898e-02,8.142083605192099172e-03,-8.127430129569179762e-03,-2.952762274177360077e-02,5.691179930721949887e-02
-1.035930931563389945e-01,5.068011873981870252e-02,-2.345094731790270046e-02,-2.288496402361559975e-02,-8.687803702868139577e-02,-6.770135132559949864e-02,-1.762938102341739949e-02,-3.949338287409189657e-02,-7.814091066906959926e-02,-7.149351505265640061e-02
1.628067572730669890e-02,5.068011873981870252e-02,-4.608500086940160029e-02,1.154374291374709975e-02,-3.321587555883730170e-02,-1.603185513032660131e-02,-1.026610541524320026e-02,-2.592261998182820038e-03,-4.398540256559110156e-02,-4.249876664881350324e-02
-6.000263174410389727e-02,5.068011873981870252e-02,5.415152200152219958e-02,-1.944209332987930153e-02,-4.972730985725089953e-02,-4.891244361822749687e-02,2.286863482154040048e-02,-3.949338287409189657e-02,-4.398540256559110156e-02,-5.219804415301099697e-03
-2.730978568492789874e-02,-4.464163650698899782e-02,-3.530688013059259805e-02,-2.977070541108809906e-02,-5.660707414825649764e-02,-5.862004593370299943e-02,3.023191042971450082e-02,-3.949338287409189657e-02,-4.986846773523059828e-02,-1.294830118603420011e-01
4.170844488444359899e-02,-4.464163650698899782e-02,-3.207344390894990155e-02,-6.190416520781699683e-02,7.961225881365530110e-02,5.098191569263330059e-02,5.600337505832399948e-02,-9.972486173364639508e-03,4.506616833626150148e-02,-5.906719430815229877e-02
-8.179786245022120650e-02,-4.464163650698899782e-02,-8.165279930747129655e-02,-4.009931749229690007e-02,2.558898754392050119e-03,-1.853704282464289921e-02,7.072992627467229731e-02,-3.949338287409189657e-02,-1.090443584737709956e-02,-9.220404962683000083e-02
-4.183993948900609910e-02,-4.464163650698899782e-02,4.768464955823679963e-02,5.974393262605470073e-02,1.277706088506949944e-01,1.280164372928579986e-01,-2.499265663159149983e-02,1.081111006295440019e-01,6.389312063683939835e-02,4.034337164788070335e-02
-1.277963188084970010e-02,-4.464163650698899782e-02,6.061839444480759953e-02,5.285819123858220142e-02,4.796534307502930278e-02,2.937467182915549924e-02,-1.762938102341739949e-02,3.430885887772629900e-02,7.021129819331020649e-02,7.206516329203029904e-03
6.713621404158050254e-02,-4.464163650698899782e-02,5.630714614928399725e-02,7.351541540099980343e-02,-1.395253554402150001e-02,-3.920484130275200124e-02,-3.235593223976569732e-02,-2.592261998182820038e-03,7.573758845754760549e-02,3.620126473304600273e-02
-5.273755484206479882e-02,5.068011873981870252e-02,9.834181703063900326e-02,8.728689817594480205e-02,6.034891879883950289e-02,4.878987646010649742e-02,-5.812739686837520292e-02,1.081111006295440019e-01,8.449528221240310000e-02,4.034337164788070335e-02
5.383060374248070309e-03,-4.464163650698899782e-02,5.954058237092670069e-02,-5.616604740787570216e-02,2.457414448561009990e-02,5.286080646337049799e-02,-4.340084565202689815e-02,5.091436327188540029e-02,-4.219859706946029777e-03,-3.007244590430930078e-02
8.166636784565869944e-02,-4.464163650698899782e-02,3.367309259778510089e-02,8.100872220010799790e-03,5.209320164963270050e-02,5.661858800484489973e-02,-1.762938102341739949e-02,3.430885887772629900e-02,3.486419309615960277e-02,6.933812005172369786e-02
3.081082953138499989e-02,5.068011873981870252e-02,5.630714614928399725e-02,7.695828609473599757e-02,4.934129593323050011e-02,-1.227407358885230018e-02,-3.603757004385269719e-02,7.120997975363539678e-02,1.200533820015380060e-01,9.004865462589720093e-02
1.750521923228520000e-03,-4.464163650698899782e-02,-6.548561819925780014e-02,-5.670610554934250001e-03,-7.072771253015849857e-03,-1.947648821001150138e-02,4.127682384197570165e-02,-3.949338287409189657e-02,-3.303712578676999863e-03,7.206516329203029904e-03
-4.910501639104519755e-02,-4.464163650698899782e-02,1.608549173157310108e-01,-4.698505887976939938e-02,-2.908801698423390050e-02,-1.978963667180099958e-02,-4.708248345611389801e-02,3.430885887772629900e-02,2.801650652326400162e-02,1.134862324403770016e-02
-2.730978568492789874e-02,5.068011873981870252e-02,-5.578530953432969675e-02,2.531522568869210010e-02,-7.072771253015849857e-03,-2.354741821327540133e-02,5.232173725423699961e-02,-3.949338287409189657e-02,-5.145307980263110273e-03,-5.078298047848289754e-02
7.803382939463919532e-02,5.068011873981870252e-02,-2.452875939178359929e-02,-4.239456463293059946e-02,6.686757328995440036e-03,5.286080646337049799e-02,-6.917231028063640375e-02,8.080427118137170628e-02,-3.712834601047360072e-02,5.691179930721949887e-02
1.264813727628719998e-02,-4.464163650698899782e-02,-3.638469220447349689e-02,4.252957915737339695e-02,-1.395253554402150001e-02,1.293437758520510003e-02,-2.683347553363510038e-02,5.156973385758089994e-03,-4.398540256559110156e-02,7.206516329203029904e-03
4.170844488444359899e-02,-4.464163650698899782e-02,-8.361578283570040432e-03,-5.731367096097819691e-02,8.062710187196569719e-03,-3.137612975801370302e-02,1.517259579645879874e-01,-7.639450375000099436e-02,-8.023654024890179703e-02,-1.764612515980519894e-02
4.897352178648269744e-02,-4.464163650698899782e-02,-4.177375257387799801e-02,1.045012516446259948e-01,3.558176735121919981e-02,-2.573945744580210040e-02,1.774974225931970073e-01,-7.639450375000099436e-02,-1.290794225416879923e-02,1.549073015887240078e-02
-1.641217033186929963e-02,5.068011873981870252e-02,1.274427430254229943e-01,9.761551025715360652e-02,1.631842733640340160e-02,1.747503028115330106e-02,-2.131101882750449997e-02,3.430885887772629900e-02,3.486419309615960277e-02,3.064409414368320182e-03
-7.453278554818210111e-02,5.068011873981870252e-02,-7.734155101194770121e-02,-4.698505887976939938e-02,-4.697540414084860200e-02,-3.262872360517189707e-02,4.460445801105040325e-03,-3.949338287409189657e-02,-7.212845460195599356e-02,-1.764612515980519894e-02
3.444336798240450054e-02,5.068011873981870252e-02,2.828403222838059977e-02,-3.321357610482440076e-02,-4.559945128264750180e-02,-9.768885894535990141e-03,-5.076412126020100196e-02,-2.592261998182820038e-03,-5.947269741072230137e-02,-2.178823207463989955e-02
-3.457486258696700065e-02,5.068011873981870252e-02,-2.560657146566450160e-02,-1.714684618924559867e-02,1.182945896190920002e-03,-2.879619735166290186e-03,8.142083605192099172e-03,-1.550765430475099967e-02,1.482271084126630077e-02,4.034337164788070335e-02
-5.273755484206479882e-02,5.068011873981870252e-02,-6.225218197761509670e-02,1.154374291374709975e-02,-8.448724111216979540e-03,-3.669965360843580049e-02,1.222728555318910032e-01,-7.639450375000099436e-02,-8.682899321629239386e-02,3.064409414368320182e-03
5.987113713954139715e-02,-4.464163650698899782e-02,-8.168937664037369826e-04,-8.485663651086830517e-02,7.548440023905199359e-02,7.947842571548069390e-02,4.460445801105040325e-03,3.430885887772629900e-02,2.337484127982079885e-02,2.791705090337660150e-02
6.350367559056099842e-02,5.068011873981870252e-02,8.864150836571099701e-02,7.007254470726349826e-02,2.044628591100669870e-02,3.751653183568340322e-02,-5.076412126020100196e-02,7.120997975363539678e-02,2.930041326858690010e-02,7.348022696655839847e-02
9.015598825267629943e-03,-4.464163650698899782e-02,-3.207344390894990155e-02,-2.632783471735180084e-02,4.246153164222479792e-02,-1.039518281811509931e-02,1.590892335727620011e-01,-7.639450375000099436e-02,-1.190068480150809939e-02,-3.835665973397880263e-02
5.383060374248070309e-03,5.068011873981870252e-02,3.043965637614240091e-02,8.384402748220859403e-02,-3.734373413344069942e-02,-4.734670130927989828e-02,1.550535921336619952e-02,-3.949338287409189657e-02,8.640282933063080789e-03,1.549073015887240078e-02
3.807590643342410180e-02,5.068011873981870252e-02,8.883414898524360018e-03,4.252957915737339695e-02,-4.284754556624519733e-02,-2.104223051895920057e-02,-3.971920784793980114e-02,-2.592261998182820038e-03,-1.811826730789670159e-02,7.206516329203029904e-03
1.264813727628719998e-02,-4.464163650698899782e-02,6.727790750762559745e-03,-5.616604740787570216e-02,-7.587041416307230279e-02,-6.644875747844139480e-02,-2.131101882750449997e-02,-3.764832683029650101e-02,-1.811826730789670159e-02,-9.220404962683000083e-02
7.440129094361959405e-02,5.068011873981870252e-02,-2.021751109626000048e-02,4.597244985110970211e-02,7.410844738085080319e-02,3.281930490884039930e-02,-3.603757004385269719e-02,7.120997975363539678e-02,1.063542767417259977e-01,3.620126473304600273e-02
1.628067572730669890e-02,-4.464163650698899782e-02,-2.452875939178359929e-02,3.564383776990089764e-02,-7.072771253015849857e-03,-3.192768196955810076e-03,-1.394774321933030074e-02,-2.592261998182820038e-03,1.556684454070180086e-02,1.549073015887240078e-02
-5.514554978810590376e-03,5.068011873981870252e-02,-1.159501450521270051e-02,1.154374291374709975e-02,-2.220825269322829892e-02,-1.540555820674759969e-02,-2.131101882750449997e-02,-2.592261998182820038e-03,1.100810104587249955e-02,6.933812005172369786e-02
1.264813727628719998e-02,-4.464163650698899782e-02,2.612840808061879863e-02,6.318680331979099896e-02,1.250187031342930022e-01,9.169121572527250130e-02,6.336665066649820044e-02,-2.592261998182820038e-03,5.757285620242599822e-02,-2.178823207463989955e-02
-3.457486258696700065e-02,-4.464163650698899782e-02,-5.901874575597240019e-02,1.215130832538269907e-03,-5.385516843185429725e-02,-7.803525056465400456e-02,6.704828847058519337e-02,-7.639450375000099436e-02,-2.139368094035999993e-02,1.549073015887240078e-02
6.713621404158050254e-02,5.068011873981870252e-02,-3.638469220447349689e-02,-8.485663651086830517e-02,-7.072771253015849857e-03,1.966706951368000014e-02,-5.444575906428809897e-02,3.430885887772629900e-02,1.143797379512540100e-03,3.205915781821130212e-02
3.807590643342410180e-02,5.068011873981870252e-02,-2.452875939178359929e-02,4.658001526274530187e-03,-2.633611126783170012e-02,-2.636575436938120090e-02,1.550535921336619952e-02,-3.949338287409189657e-02,-1.599826775813870117e-02,-2.593033898947460017e-02
9.015598825267629943e-03,5.068011873981870252e-02,1.858372356345249984e-02,3.908670846363720280e-02,1.769438019460449832e-02,1.058576412178359981e-02,1.918699701745330000e-02,-2.592261998182820038e-03,1.630495279994180133e-02,-1.764612515980519894e-02
-9.269547780327989928e-02,5.068011873981870252e-02,-9.027529589851850111e-02,-5.731367096097819691e-02,-2.496015840963049931e-02,-3.043668437264510085e-02,-6.584467611156170040e-03,-2.592261998182820038e-03,2.405258322689299982e-02,3.064409414368320182e-03
7.076875249260000666e-02,-4.464163650698899782e-02,-5.128142061927360405e-03,-5.670610554934250001e-03,8.786797596286209655e-02,1.029645603496960049e-01,1.182372140927919965e-02,3.430885887772629900e-02,-8.944018957797799166e-03,2.791705090337660150e-02
-1.641217033186929963e-02,-4.464163650698899782e-02,-5.255187331268700024e-02,-3.321357610482440076e-02,-4.422349842444640161e-02,-3.638650514664620167e-02,1.918699701745330000e-02,-3.949338287409189657e-02,-6.832974362442149896e-02,-3.007244590430930078e-02
4.170844488444359899e-02,5.068011873981870252e-02,-2.237313524402180162e-02,2.875809638242839833e-02,-6.623874415566440021e-02,-4.515466207675319921e-02,-6.180903467246220279e-02,-2.592261998182820038e-03,2.863770518940129874e-03,-5.492508739331759815e-02
1.264813727628719998e-02,-4.464163650698899782e-02,-2.021751109626000048e-02,-1.599922263614299983e-02,1.219056876180000040e-02,2.123281182262769934e-02,-7.653558588881050062e-02,1.081111006295440019e-01,5.988072306548120061e-02,-2.178823207463989955e-02
-3.820740103798660192e-02,-4.464163650698899782e-02,-5.470749746044879791e-02,-7.797089512339580586e-02,-3.321587555883730170e-02,-8.649025903297140327e-02,1.406810445523269948e-01,-7.639450375000099436e-02,-1.919704761394450121e-02,-5.219804415301099697e-03
4.534098333546320025e-02,-4.464163650698899782e-02,-6.205954135808240159e-03,-1.599922263614299983e-02,1.250187031342930022e-01,1.251981011367520047e-01,1.918699701745330000e-02,3.430885887772629900e-02,3.243322577960189995e-02,-5.219804415301099697e-03
7.076875249260000666e-02,5.068011873981870252e-02,-1.698407487461730050e-02,2.187235499495579841e-02,4.383748450042589812e-02,5.630543954305530091e-02,3.759518603788870178e-02,-2.592261998182820038e-03,-7.020931272868760620e-02,-1.764612515980519894e-02
-7.453278554818210111e-02,5.068011873981870252e-02,5.522933407540309841e-02,-4.009931749229690007e-02,5.346915450783389784e-02,5.317395492515999966e-02,-4.340084565202689815e-02,7.120997975363539678e-02,6.123790751970099866e-02,-3.421455281914410201e-02
5.987113713954139715e-02,5.068011873981870252e-02,7.678557555302109594e-02,2.531522568869210010e-02,1.182945896190920002e-03,1.684873335757430118e-02,-5.444575906428809897e-02,3.430885887772629900e-02,2.993564839653250001e-02,4.448547856271539702e-02
7.440129094361959405e-02,-4.464163650698899782e-02,1.858372356345249984e-02,6.318680331979099896e-02,6.172487165704060308e-02,4.284005568610550069e-02,8.142083605192099172e-03,-2.592261998182820038e-03,5.803912766389510147e-02,-5.906719430815229877e-02
9.015598825267629943e-03,-4.464163650698899782e-02,-2.237313524402180162e-02,-3.206595255172180192e-02,-4.972730985725089953e-02,-6.864079671096809387e-02,7.809320188284639419e-02,-7.085933561861459951e-02,-6.291294991625119570e-02,-3.835665973397880263e-02
-7.090024709716259699e-02,-4.464163650698899782e-02,9.295275666123460623e-02,1.269136646684959971e-02,2.044628591100669870e-02,4.252690722431590187e-02,7.788079970179680352e-04,3.598276718899090076e-04,-5.454415271109520208e-02,-1.077697500466389974e-03
2.354575262934580082e-02,5.068011873981870252e-02,-3.099563183506899924e-02,-5.670610554934250001e-03,-1.670444126042380101e-02,1.778817874294279927e-02,-3.235593223976569732e-02,-2.592261998182820038e-03,-7.408887149153539631e-02,-3.421455281914410201e-02
-5.273755484206479882e-02,5.068011873981870252e-02,3.906215296718960200e-02,-4.009931749229690007e-02,-5.696818394814720174e-03,-1.290037051243130006e-02,1.182372140927919965e-02,-3.949338287409189657e-02,1.630495279994180133e-02,3.064409414368320182e-03
6.713621404158050254e-02,-4.464163650698899782e-02,-6.117436990373419786e-02,-4.009931749229690007e-02,-2.633611126783170012e-02,-2.448686359864400003e-02,3.391354823380159783e-02,-3.949338287409189657e-02,-5.615757309500619965e-02,-5.906719430815229877e-02
1.750521923228520000e-03,-4.464163650698899782e-02,-8.361578283570040432e-03,-6.419941234845069622e-02,-3.871968699164179961e-02,-2.448686359864400003e-02,4.460445801105040325e-03,-3.949338287409189657e-02,-6.468302246445030435e-02,-5.492508739331759815e-02
2.354575262934580082e-02,5.068011873981870252e-02,-3.746250427835440266e-02,-4.698505887976939938e-02,-9.100589560328480043e-02,-7.553006287033779687e-02,-3.235593223976569732e-02,-3.949338287409189657e-02,-3.075120986455629965e-02,-1.350401824497050006e-02
3.807590643342410180e-02,5.068011873981870252e-02,-1.375063865297449991e-02,-1.599922263614299983e-02,-3.596778127523959923e-02,-2.198167590432769866e-02,-1.394774321933030074e-02,-2.592261998182820038e-03,-2.595242443518940012e-02,-1.077697500466389974e-03
1.628067572730669890e-02,-4.464163650698899782e-02,7.355213933137849658e-02,-4.124694104539940176e-02,-4.320865536613589623e-03,-1.352666743601040056e-02,-1.394774321933030074e-02,-1.116217163146459961e-03,4.289568789252869857e-02,4.448547856271539702e-02
-1.882016527791040067e-03,5.068011873981870252e-02,-2.452875939178359929e-02,5.285819123858220142e-02,2.732605020201240090e-02,3.000096875273459973e-02,3.023191042971450082e-02,-2.592261998182820038e-03,-2.139368094035999993e-02,3.620126473304600273e-02
1.264813727628719998e-02,-4.464163650698899782e-02,3.367309259778510089e-02,3.334859052598110329e-02,3.007795591841460128e-02,2.718263259662880016e-02,-2.902829807069099918e-03,8.847085473348980864e-03,3.119299070280229930e-02,2.791705090337660150e-02
7.440129094361959405e-02,-4.464163650698899782e-02,3.475090467166599972e-02,9.417263956341730136e-02,5.759701308243719842e-02,2.029336643725910064e-02,2.286863482154040048e-02,-2.592261998182820038e-03,7.380214692004880006e-02,-2.178823207463989955e-02
4.170844488444359899e-02,5.068011873981870252e-02,-3.854031635223530150e-02,5.285819123858220142e-02,7.686035309725310072e-02,1.164299442066459994e-01,-3.971920784793980114e-02,7.120997975363539678e-02,-2.251217192966049885e-02,-1.350401824497050006e-02
-9.147093429830140468e-03,5.068011873981870252e-02,-3.961812842611620034e-02,-4.009931749229690007e-02,-8.448724111216979540e-03,1.622243643399520069e-02,-6.549067247654929980e-02,7.120997975363539678e-02,1.776347786711730131e-02,-6.735140813782170000e-02
9.015598825267629943e-03,5.068011873981870252e-02,-1.894705840284650021e-03,2.187235499495579841e-02,-3.871968699164179961e-02,-2.480001206043359885e-02,-6.584467611156170040e-03,-3.949338287409189657e-02,-3.980959436433750137e-02,-1.350401824497050006e-02
6.713621404158050254e-02,5.068011873981870252e-02,-3.099563183506899924e-02,4.658001526274530187e-03,2.457414448561009990e-02,3.563764106494619888e-02,-2.867429443567860031e-02,3.430885887772629900e-02,2.337484127982079885e-02,8.176444079622779970e-02
1.750521923228520000e-03,-4.464163650698899782e-02,-4.608500086940160029e-02,-3.321357610482440076e-02,-7.311850844667000526e-02,-8.147988364433890462e-02,4.495846164606279866e-02,-6.938329078357829971e-02,-6.117659509433449883e-02,-7.977772888232589898e-02
-9.147093429830140468e-03,5.068011873981870252e-02,1.338730381358059929e-03,-2.227739861197989939e-03,7.961225881365530110e-02,7.008397186179469995e-02,3.391354823380159783e-02,-2.592261998182820038e-03,2.671425763351279944e-02,8.176444079622779970e-02
-5.514554978810590376e-03,-4.464163650698899782e-02,6.492964274033119487e-02,3.564383776990089764e-02,-1.568959820211340015e-03,1.496984258683710031e-02,-1.394774321933030074e-02,7.288388806489919797e-04,-1.811826730789670159e-02,3.205915781821130212e-02
9.619652164973699349e-02,-4.464163650698899782e-02,4.013996504107050084e-02,-5.731367096097819691e-02,4.521343735862710239e-02,6.068951800810880315e-02,-2.131101882750449997e-02,3.615391492152170150e-02,1.255315281338930007e-02,2.377494398854190089e-02
-7.453278554818210111e-02,-4.464163650698899782e-02,-2.345094731790270046e-02,-5.670610554934250001e-03,-2.083229983502719873e-02,-1.415296435958940044e-02,1.550535921336619952e-02,-3.949338287409189657e-02,-3.845911230135379971e-02,-3.007244590430930078e-02
5.987113713954139715e-02,5.068011873981870252e-02,5.307370992764130074e-02,5.285819123858220142e-02,3.282986163481690228e-02,1.966706951368000014e-02,-1.026610541524320026e-02,3.430885887772629900e-02,5.520503808961670089e-02,-1.077697500466389974e-03
-2.367724723390840155e-02,-4.464163650698899782e-02,4.013996504107050084e-02,-1.255635194240680048e-02,-9.824676969418109224e-03,-1.000728964429089965e-03,-2.902829807069099918e-03,-2.592261998182820038e-03,-1.190068480150809939e-02,-3.835665973397880263e-02
9.015598825267629943e-03,-4.464163650698899782e-02,-2.021751109626000048e-02,-5.387080026724189868e-02,3.145390877661580209e-02,2.060651489904859884e-02,5.600337505832399948e-02,-3.949338287409189657e-02,-1.090443584737709956e-02,-1.077697500466389974e-03
1.628067572730669890e-02,5.068011873981870252e-02,1.427247526792889930e-02,1.215130832538269907e-03,1.182945896190920002e-03,-2.135537898074869878e-02,-3.235593223976569732e-02,3.430885887772629900e-02,7.496833602773420036e-02,4.034337164788070335e-02
1.991321417832630017e-02,-4.464163650698899782e-02,-3.422906805671169922e-02,5.515343848250200270e-02,6.722868308984519814e-02,7.415490186505870052e-02,-6.584467611156170040e-03,3.283281404268990206e-02,2.472532334280450050e-02,6.933812005172369786e-02
8.893144474769780483e-02,-4.464163650698899782e-02,6.727790750762559745e-03,2.531522568869210010e-02,3.007795591841460128e-02,8.706873351046409346e-03,6.336665066649820044e-02,-3.949338287409189657e-02,9.436409146079870192e-03,3.205915781821130212e-02
1.991321417832630017e-02,-4.464163650698899782e-02,4.572166603000769880e-03,4.597244985110970211e-02,-1.808039411862490120e-02,-5.454911593043910295e-02,6.336665066649820044e-02,-3.949338287409189657e-02,2.866072031380889965e-02,6.105390622205419948e-02
-2.367724723390840155e-02,-4.464163650698899782e-02,3.043965637614240091e-02,-5.670610554934250001e-03,8.236416453005759863e-02,9.200436418706199604e-02,-1.762938102341739949e-02,7.120997975363539678e-02,3.304707235493409972e-02,3.064409414368320182e-03
9.619652164973699349e-02,-4.464163650698899782e-02,5.199589785376040191e-02,7.925353333865589600e-02,5.484510736603499803e-02,3.657708645031480105e-02,-7.653558588881050062e-02,1.413221094178629955e-01,9.864637430492799453e-02,6.105390622205419948e-02
2.354575262934580082e-02,5.068011873981870252e-02,6.169620651868849837e-02,6.203917986997459916e-02,2.457414448561009990e-02,-3.607335668485669999e-02,-9.126213710515880539e-02,1.553445353507079962e-01,1.333957338374689994e-01,8.176444079622779970e-02
7.076875249260000666e-02,5.068011873981870252e-02,-7.283766209689159811e-03,4.941532054484590319e-02,6.034891879883950289e-02,-4.445362044113949918e-03,-5.444575906428809897e-02,1.081111006295440019e-01,1.290194116001679991e-01,5.691179930721949887e-02
3.081082953138499989e-02,-4.464163650698899782e-02,5.649978676881649634e-03,1.154374291374709975e-02,7.823630595545419397e-02,7.791268340653299818e-02,-4.340084565202689815e-02,1.081111006295440019e-01,6.604820616309839409e-02,1.963283707370720027e-02
-1.882016527791040067e-03,-4.464163650698899782e-02,5.415152200152219958e-02,-6.649465948908450663e-02,7.273249452264969606e-02,5.661858800484489973e-02,-4.340084565202689815e-02,8.486339447772170419e-02,8.449528221240310000e-02,4.862758547755009764e-02
4.534098333546320025e-02,5.068011873981870252e-02,-8.361578283570040432e-03,-3.321357610482440076e-02,-7.072771253015849857e-03,1.191310268097639903e-03,-3.971920784793980114e-02,3.430885887772629900e-02,2.993564839653250001e-02,2.791705090337660150e-02
7.440129094361959405e-02,-4.464163650698899782e-02,1.145089981388529993e-01,2.875809638242839833e-02,2.457414448561009990e-02,2.499059336410210108e-02,1.918699701745330000e-02,-2.592261998182820038e-03,-6.092541861022970299e-04,-5.219804415301099697e-03
-3.820740103798660192e-02,-4.464163650698899782e-02,6.708526688809300642e-02,-6.075654165471439799e-02,-2.908801698423390050e-02,-2.323426975148589965e-02,-1.026610541524320026e-02,-2.592261998182820038e-03,-1.498586820292070049e-03,1.963283707370720027e-02
-1.277963188084970010e-02,5.068011873981870252e-02,-5.578530953432969675e-02,-2.227739861197989939e-03,-2.771206412603280031e-02,-2.918409052548700047e-02,1.918699701745330000e-02,-3.949338287409189657e-02,-1.705210460474350029e-02,4.448547856271539702e-02
9.015598825267629943e-03,5.068011873981870252e-02,3.043965637614240091e-02,4.252957915737339695e-02,-2.944912678412469915e-03,3.689023491210430272e-02,-6.549067247654929980e-02,7.120997975363539678e-02,-2.364455757213410059e-02,1.549073015887240078e-02
8.166636784565869944e-02,5.068011873981870252e-02,-2.560657146566450160e-02,-3.665644679856060184e-02,-7.036660273026780488e-02,-4.640725592391130305e-02,-3.971920784793980114e-02,-2.592261998182820038e-03,-4.118038518800790082e-02,-5.219804415301099697e-03
3.081082953138499989e-02,-4.464163650698899782e-02,1.048086894739250069e-01,7.695828609473599757e-02,-1.120062982761920074e-02,-1.133462820348369975e-02,-5.812739686837520292e-02,3.430885887772629900e-02,5.710418744784390155e-02,3.620126473304600273e-02
2.717829108036539862e-02,5.068011873981870252e-02,-6.205954135808240159e-03,2.875809638242839833e-02,-1.670444126042380101e-02,-1.627025888008149911e-03,-5.812739686837520292e-02,3.430885887772629900e-02,2.930041326858690010e-02,3.205915781821130212e-02
-6.000263174410389727e-02,5.068011873981870252e-02,-4.716281294328249912e-02,-2.288496402361559975e-02,-7.174255558846899528e-02,-5.768060054833450134e-02,-6.584467611156170040e-03,-3.949338287409189657e-02,-6.291294991625119570e-02,-5.492508739331759815e-02
5.383060374248070309e-03,-4.464163650698899782e-02,-4.824062501716339796e-02,-1.255635194240680048e-02,1.182945896190920002e-03,-6.637401276640669812e-03,6.336665066649820044e-02,-3.949338287409189657e-02,-5.140053526058249722e-02,-5.906719430815229877e-02
-2.004470878288880029e-02,-4.464163650698899782e-02,8.540807214406830050e-02,-3.665644679856060184e-02,9.199583453746550121e-02,8.949917649274570508e-02,-6.180903467246220279e-02,1.450122215054540087e-01,8.094791351127560153e-02,5.276969239238479825e-02
1.991321417832630017e-02,5.068011873981870252e-02,-1.267282657909369996e-02,7.007254470726349826e-02,-1.120062982761920074e-02,7.141131042098750048e-03,-3.971920784793980114e-02,3.430885887772629900e-02,5.384369968545729690e-03,3.064409414368320182e-03
-6.363517019512339445e-02,-4.464163650698899782e-02,-3.315125598283080038e-02,-3.321357610482440076e-02,1.182945896190920002e-03,2.405114797873349891e-02,-2.499265663159149983e-02,-2.592261998182820038e-03,-2.251217192966049885e-02,-5.906719430815229877e-02
2.717829108036539862e-02,-4.464163650698899782e-02,-7.283766209689159811e-03,-5.042792957350569760e-02,7.548440023905199359e-02,5.661858800484489973e-02,3.391354823380159783e-02,-2.592261998182820038e-03,4.344317225278129802e-02,1.549073015887240078e-02
-1.641217033186929963e-02,-4.464163650698899782e-02,-1.375063865297449991e-02,1.320442171945160059e-01,-9.824676969418109224e-03,-3.819065120534880214e-03,1.918699701745330000e-02,-3.949338287409189657e-02,-3.581672810154919867e-02,-3.007244590430930078e-02
3.081082953138499989e-02,5.068011873981870252e-02,5.954058237092670069e-02,5.630106193231849965e-02,-2.220825269322829892e-02,1.191310268097639903e-03,-3.235593223976569732e-02,-2.592261998182820038e-03,-2.479118743246069845e-02,-1.764612515980519894e-02
5.623859868852180283e-02,5.068011873981870252e-02,2.181715978509519982e-02,5.630106193231849965e-02,-7.072771253015849857e-03,1.810132720473240156e-02,-3.235593223976569732e-02,-2.592261998182820038e-03,-2.364455757213410059e-02,2.377494398854190089e-02
-2.004470878288880029e-02,-4.464163650698899782e-02,1.858372356345249984e-02,9.072976886968099619e-02,3.934851612593179802e-03,8.706873351046409346e-03,3.759518603788870178e-02,-3.949338287409189657e-02,-5.780006567561250114e-02,7.206516329203029904e-03
-1.072256316073579990e-01,-4.464163650698899782e-02,-1.159501450521270051e-02,-4.009931749229690007e-02,4.934129593323050011e-02,6.444729954958319795e-02,-1.394774321933030074e-02,3.430885887772629900e-02,7.026862549151949647e-03,-3.007244590430930078e-02
8.166636784565869944e-02,5.068011873981870252e-02,-2.972517914165530208e-03,-3.321357610482440076e-02,4.246153164222479792e-02,5.787118185200299664e-02,-1.026610541524320026e-02,3.430885887772629900e-02,-6.092541861022970299e-04,-1.077697500466389974e-03
5.383060374248070309e-03,5.068011873981870252e-02,1.750591148957160101e-02,3.220096707616459941e-02,1.277706088506949944e-01,1.273901403692790091e-01,-2.131101882750449997e-02,7.120997975363539678e-02,6.257518145805600340e-02,1.549073015887240078e-02
3.807590643342410180e-02,5.068011873981870252e-02,-2.991781976118810041e-02,-7.452802442965950069e-02,-1.257658268582039982e-02,-1.258722205064180012e-02,4.460445801105040325e-03,-2.592261998182820038e-03,3.711738233435969789e-03,-3.007244590430930078e-02
3.081082953138499989e-02,-4.464163650698899782e-02,-2.021751109626000048e-02,-5.670610554934250001e-03,-4.320865536613589623e-03,-2.949723898727649868e-02,7.809320188284639419e-02,-3.949338287409189657e-02,-1.090443584737709956e-02,-1.077697500466389974e-03
1.750521923228520000e-03,5.068011873981870252e-02,-5.794093368209150136e-02,-4.354218818603310115e-02,-9.650970703608929835e-02,-4.703355284749029946e-02,-9.862541271333299941e-02,3.430885887772629900e-02,-6.117659509433449883e-02,-7.149351505265640061e-02
-2.730978568492789874e-02,5.068011873981870252e-02,6.061839444480759953e-02,1.079441223383619947e-01,1.219056876180000040e-02,-1.759759743927430051e-02,-2.902829807069099918e-03,-2.592261998182820038e-03,7.021129819331020649e-02,1.356118306890790048e-01
-8.543040090124079389e-02,5.068011873981870252e-02,-4.069594049999709917e-02,-3.321357610482440076e-02,-8.137422559587689785e-02,-6.958024209633670298e-02,-6.584467611156170040e-03,-3.949338287409189657e-02,-5.780006567561250114e-02,-4.249876664881350324e-02
1.264813727628719998e-02,5.068011873981870252e-02,-7.195249064254319316e-02,-4.698505887976939938e-02,-5.110326271545199972e-02,-9.713730673381550107e-02,1.185912177278039964e-01,-7.639450375000099436e-02,-2.028874775162960165e-02,-3.835665973397880263e-02
-5.273755484206479882e-02,-4.464163650698899782e-02,-5.578530953432969675e-02,-3.665644679856060184e-02,8.924392882106320368e-02,-3.192768196955810076e-03,8.142083605192099172e-03,3.430885887772629900e-02,1.323726493386760128e-01,3.064409414368320182e-03
-2.367724723390840155e-02,5.068011873981870252e-02,4.552902541047500196e-02,2.187235499495579841e-02,1.098832216940800049e-01,8.887287956916670173e-02,7.788079970179680352e-04,3.430885887772629900e-02,7.419253669003070262e-02,6.105390622205419948e-02
-7.453278554818210111e-02,5.068011873981870252e-02,-9.439390357450949676e-03,1.498661360748330083e-02,-3.734373413344069942e-02,-2.166852744253820046e-02,-1.394774321933030074e-02,-2.592261998182820038e-03,-3.324878724762579674e-02,1.134862324403770016e-02
-5.514554978810590376e-03,5.068011873981870252e-02,-3.315125598283080038e-02,-1.599922263614299983e-02,8.062710187196569719e-03,1.622243643399520069e-02,1.550535921336619952e-02,-2.592261998182820038e-03,-2.832024254799870092e-02,-7.563562196749110123e-02
-6.000263174410389727e-02,5.068011873981870252e-02,4.984027370599859730e-02,1.842948430121960079e-02,-1.670444126042380101e-02,-3.012353591085559917e-02,-1.762938102341739949e-02,-2.592261998182820038e-03,4.976865992074899769e-02,-5.906719430815229877e-02
-2.004470878288880029e-02,-4.464163650698899782e-02,-8.488623552911400694e-02,-2.632783471735180084e-02,-3.596778127523959923e-02,-3.419446591411950259e-02,4.127682384197570165e-02,-5.167075276314189725e-02,-8.238148325810279449e-02,-4.664087356364819692e-02
3.807590643342410180e-02,5.068011873981870252e-02,5.649978676881649634e-03,3.220096707616459941e-02,6.686757328995440036e-03,1.747503028115330106e-02,-2.499265663159149983e-02,3.430885887772629900e-02,1.482271084126630077e-02,6.105390622205419948e-02
1.628067572730669890e-02,-4.464163650698899782e-02,2.073934771121430098e-02,2.187235499495579841e-02,-1.395253554402150001e-02,-1.321351897422090062e-02,-6.584467611156170040e-03,-2.592261998182820038e-03,1.331596790892770020e-02,4.034337164788070335e-02
4.170844488444359899e-02,-4.464163650698899782e-02,-7.283766209689159811e-03,2.875809638242839833e-02,-4.284754556624519733e-02,-4.828614669464850045e-02,5.232173725423699961e-02,-7.639450375000099436e-02,-7.212845460195599356e-02,2.377494398854190089e-02
1.991321417832630017e-02,5.068011873981870252e-02,1.048086894739250069e-01,7.007254470726349826e-02,-3.596778127523959923e-02,-2.667890283117069911e-02,-2.499265663159149983e-02,-2.592261998182820038e-03,3.711738233435969789e-03,4.034337164788070335e-02
-4.910501639104519755e-02,5.068011873981870252e-02,-2.452875939178359929e-02,6.750727943574620551e-05,-4.697540414084860200e-02,-2.824464514011839830e-02,-6.549067247654929980e-02,2.840467953758080144e-02,1.919903307856710151e-02,1.134862324403770016e-02
1.750521923228520000e-03,5.068011873981870252e-02,-6.205954135808240159e-03,-1.944209332987930153e-02,-9.824676969418109224e-03,4.949091809572019746e-03,-3.971920784793980114e-02,3.430885887772629900e-02,1.482271084126630077e-02,9.833286845556660216e-02
3.444336798240450054e-02,-4.464163650698899782e-02,-3.854031635223530150e-02,-1.255635194240680048e-02,9.438663045397699403e-03,5.262240271361550044e-03,-6.584467611156170040e-03,-2.592261998182820038e-03,3.119299070280229930e-02,9.833286845556660216e-02
-4.547247794002570037e-02,5.068011873981870252e-02,1.371430516903520136e-01,-1.599922263614299983e-02,4.108557878402369773e-02,3.187985952347179713e-02,-4.340084565202689815e-02,7.120997975363539678e-02,7.102157794598219775e-02,4.862758547755009764e-02
-9.147093429830140468e-03,5.068011873981870252e-02,1.705552259806600024e-01,1.498661360748330083e-02,3.007795591841460128e-02,3.375875029420900147e-02,-2.131101882750449997e-02,3.430885887772629900e-02,3.365681290238470291e-02,3.205915781821130212e-02
-1.641217033186929963e-02,5.068011873981870252e-02,2.416542455238970041e-03,1.498661360748330083e-02,2.182223876920789951e-02,-1.008203435632550049e-02,-2.499265663159149983e-02,3.430885887772629900e-02,8.553312118743899850e-02,8.176444079622779970e-02
-9.147093429830140468e-03,-4.464163650698899782e-02,3.798434089330870317e-02,-4.009931749229690007e-02,-2.496015840963049931e-02,-3.819065120534880214e-03,-4.340084565202689815e-02,1.585829843977170153e-02,-5.145307980263110273e-03,2.791705090337660150e-02
1.991321417832630017e-02,-4.464163650698899782e-02,-5.794093368209150136e-02,-5.731367096097819691e-02,-1.568959820211340015e-03,-1.258722205064180012e-02,7.441156407875940126e-02,-3.949338287409189657e-02,-6.117659509433449883e-02,-7.563562196749110123e-02
5.260606023750229870e-02,5.068011873981870252e-02,-9.439390357450949676e-03,4.941532054484590319e-02,5.071724879143160031e-02,-1.916333974822199970e-02,-1.394774321933030074e-02,3.430885887772629900e-02,1.193439942037869961e-01,-1.764612515980519894e-02
-2.730978568492789874e-02,5.068011873981870252e-02,-2.345094731790270046e-02,-1.599922263614299983e-02,1.356652162000110060e-02,1.277780335431030062e-02,2.655027262562750096e-02,-2.592261998182820038e-03,-1.090443584737709956e-02,-2.178823207463989955e-02
-7.453278554818210111e-02,-4.464163650698899782e-02,-1.051720243133190055e-02,-5.670610554934250001e-03,-6.623874415566440021e-02,-5.705430362475540085e-02,-2.902829807069099918e-03,-3.949338287409189657e-02,-4.257210492279420166e-02,-1.077697500466389974e-03
-1.072256316073579990e-01,-4.464163650698899782e-02,-3.422906805671169922e-02,-6.764228304218700139e-02,-6.348683843926219983e-02,-7.051968748170529822e-02,8.142083605192099172e-03,-3.949338287409189657e-02,-6.092541861022970299e-04,-7.977772888232589898e-02
4.534098333546320025e-02,5.068011873981870252e-02,-2.972517914165530208e-03,1.079441223383619947e-01,3.558176735121919981e-02,2.248540566978590033e-02,2.655027262562750096e-02,-2.592261998182820038e-03,2.801650652326400162e-02,1.963283707370720027e-02
-1.882016527791040067e-03,-4.464163650698899782e-02,6.816307896197400240e-02,-5.670610554934250001e-03,1.195148917014880047e-01,1.302084765253850029e-01,-2.499265663159149983e-02,8.670845052151719690e-02,4.613233103941480340e-02,-1.077697500466389974e-03
1.991321417832630017e-02,5.068011873981870252e-02,9.961226972405269262e-03,1.842948430121960079e-02,1.494247447820220079e-02,4.471894645684260094e-02,-6.180903467246220279e-02,7.120997975363539678e-02,9.436409146079870192e-03,-6.320930122298699938e-02
1.628067572730669890e-02,5.068011873981870252e-02,2.416542455238970041e-03,-5.670610554934250001e-03,-5.696818394814720174e-03,1.089891258357309975e-02,-5.076412126020100196e-02,3.430885887772629900e-02,2.269202256674450122e-02,-3.835665973397880263e-02
-1.882016527791040067e-03,-4.464163650698899782e-02,-3.854031635223530150e-02,2.187235499495579841e-02,-1.088932827598989989e-01,-1.156130659793979942e-01,2.286863482154040048e-02,-7.639450375000099436e-02,-4.687948284421659950e-02,2.377494398854190089e-02
1.628067572730669890e-02,-4.464163650698899782e-02,2.612840808061879863e-02,5.859630917623830093e-02,-6.073493272285990230e-02,-4.421521669138449989e-02,-1.394774321933030074e-02,-3.395821474270550172e-02,-5.140053526058249722e-02,-2.593033898947460017e-02
-7.090024709716259699e-02,5.068011873981870252e-02,-8.919748382463760228e-02,-7.452802442965950069e-02,-4.284754556624519733e-02,-2.573945744580210040e-02,-3.235593223976569732e-02,-2.592261998182820038e-03,-1.290794225416879923e-02,-5.492508739331759815e-02
4.897352178648269744e-02,-4.464163650698899782e-02,6.061839444480759953e-02,-2.288496402361559975e-02,-2.358420555142939912e-02,-7.271172671423199729e-02,-4.340084565202689815e-02,-2.592261998182820038e-03,1.041376113589790042e-01,3.620126473304600273e-02
5.383060374248070309e-03,5.068011873981870252e-02,-2.884000768730720157e-02,-9.113481248670509197e-03,-3.183992270063620150e-02,-2.887094206369749880e-02,8.142083605192099172e-03,-3.949338287409189657e-02,-1.811826730789670159e-02,7.206516329203029904e-03
3.444336798240450054e-02,5.068011873981870252e-02,-2.991781976118810041e-02,4.658001526274530187e-03,9.337178739566659447e-02,8.699398879842949739e-02,3.391354823380159783e-02,-2.592261998182820038e-03,2.405258322689299982e-02,-3.835665973397880263e-02
2.354575262934580082e-02,5.068011873981870252e-02,-1.913969902237900103e-02,4.941532054484590319e-02,-6.348683843926219983e-02,-6.112523362801929733e-02,4.460445801105040325e-03,-3.949338287409189657e-02,-2.595242443518940012e-02,-1.350401824497050006e-02
1.991321417832630017e-02,-4.464163650698899782e-02,-4.069594049999709917e-02,-1.599922263614299983e-02,-8.448724111216979540e-03,-1.759759743927430051e-02,5.232173725423699961e-02,-3.949338287409189657e-02,-3.075120986455629965e-02,3.064409414368320182e-03
-4.547247794002570037e-02,-4.464163650698899782e-02,1.535028734180979987e-02,-7.452802442965950069e-02,-4.972730985725089953e-02,-1.728444897748479883e-02,-2.867429443567860031e-02,-2.592261998182820038e-03,-1.043648208321659998e-01,-7.563562196749110123e-02
5.260606023750229870e-02,5.068011873981870252e-02,-2.452875939178359929e-02,5.630106193231849965e-02,-7.072771253015849857e-03,-5.071658967693000106e-03,-2.131101882750449997e-02,-2.592261998182820038e-03,2.671425763351279944e-02,-3.835665973397880263e-02
-5.514554978810590376e-03,5.068011873981870252e-02,1.338730381358059929e-03,-8.485663651086830517e-02,-1.120062982761920074e-02,-1.665815205390569834e-02,4.864009945014990260e-02,-3.949338287409189657e-02,-4.118038518800790082e-02,-8.806194271199530021e-02
9.015598825267629943e-03,5.068011873981870252e-02,6.924089103585480409e-02,5.974393262605470073e-02,1.769438019460449832e-02,-2.323426975148589965e-02,-4.708248345611389801e-02,3.430885887772629900e-02,1.032922649115240038e-01,7.348022696655839847e-02
-2.367724723390840155e-02,-4.464163650698899782e-02,-6.979686649478139548e-02,-6.419941234845069622e-02,-5.935897986465880211e-02,-5.047818592717519953e-02,1.918699701745330000e-02,-3.949338287409189657e-02,-8.913686007934769340e-02,-5.078298047848289754e-02
-4.183993948900609910e-02,5.068011873981870252e-02,-2.991781976118810041e-02,-2.227739861197989939e-03,2.182223876920789951e-02,3.657708645031480105e-02,1.182372140927919965e-02,-2.592261998182820038e-03,-4.118038518800790082e-02,6.519601313688899724e-02
-7.453278554818210111e-02,-4.464163650698899782e-02,-4.608500086940160029e-02,-4.354218818603310115e-02,-2.908801698423390050e-02,-2.323426975148589965e-02,1.550535921336619952e-02,-3.949338287409189657e-02,-3.980959436433750137e-02,-2.178823207463989955e-02
3.444336798240450054e-02,-4.464163650698899782e-02,1.858372356345249984e-02,5.630106193231849965e-02,1.219056876180000040e-02,-5.454911593043910295e-02,-6.917231028063640375e-02,7.120997975363539678e-02,1.300806095217529879e-01,7.206516329203029904e-03
-6.000263174410389727e-02,-4.464163650698899782e-02,1.338730381358059929e-03,-2.977070541108809906e-02,-7.072771253015849857e-03,-2.166852744253820046e-02,1.182372140927919965e-02,-2.592261998182820038e-03,3.181521750079859684e-02,-5.492508739331759815e-02
-8.543040090124079389e-02,5.068011873981870252e-02,-3.099563183506899924e-02,-2.288496402361559975e-02,-6.348683843926219983e-02,-5.423596746864960128e-02,1.918699701745330000e-02,-3.949338287409189657e-02,-9.643322289178400675e-02,-3.421455281914410201e-02
5.260606023750229870e-02,-4.464163650698899782e-02,-4.050329988046450294e-03,-3.091832896419060075e-02,-4.697540414084860200e-02,-5.830689747191349775e-02,-1.394774321933030074e-02,-2.583996815000549896e-02,3.605579008983190309e-02,2.377494398854190089e-02
1.264813727628719998e-02,-4.464163650698899782e-02,1.535028734180979987e-02,-3.321357610482440076e-02,4.108557878402369773e-02,3.219300798526129881e-02,-2.902829807069099918e-03,-2.592261998182820038e-03,4.506616833626150148e-02,-6.735140813782170000e-02
5.987113713954139715e-02,5.068011873981870252e-02,2.289497185897609866e-02,4.941532054484590319e-02,1.631842733640340160e-02,1.183835796894170019e-02,-1.394774321933030074e-02,-2.592261998182820038e-03,3.953987807202419963e-02,1.963283707370720027e-02
-2.367724723390840155e-02,-4.464163650698899782e-02,4.552902541047500196e-02,9.072976886968099619e-02,-1.808039411862490120e-02,-3.544705976127759950e-02,7.072992627467229731e-02,-3.949338287409189657e-02,-3.452371533034950118e-02,-9.361911330135799444e-03
1.628067572730669890e-02,-4.464163650698899782e-02,-4.500718879552070145e-02,-5.731367096097819691e-02,-3.459182841703849903e-02,-5.392281900686000246e-02,7.441156407875940126e-02,-7.639450375000099436e-02,-4.257210492279420166e-02,4.034337164788070335e-02
1.107266754538149961e-01,5.068011873981870252e-02,-3.315125598283080038e-02,-2.288496402361559975e-02,-4.320865536613589623e-03,2.029336643725910064e-02,-6.180903467246220279e-02,7.120997975363539678e-02,1.556684454070180086e-02,4.448547856271539702e-02
-2.004470878288880029e-02,-4.464163650698899782e-02,9.726400495675820157e-02,-5.670610554934250001e-03,-5.696818394814720174e-03,-2.386056667506489953e-02,-2.131101882750449997e-02,-2.592261998182820038e-03,6.168584882386619894e-02,4.034337164788070335e-02
-1.641217033186929963e-02,-4.464163650698899782e-02,5.415152200152219958e-02,7.007254470726349826e-02,-3.321587555883730170e-02,-2.793149667832890010e-02,8.142083605192099172e-03,-3.949338287409189657e-02,-2.712864555432650121e-02,-9.361911330135799444e-03
4.897352178648269744e-02,5.068011873981870252e-02,1.231314947298999957e-01,8.384402748220859403e-02,-1.047654241852959967e-01,-1.008950882752900069e-01,-6.917231028063640375e-02,-2.592261998182820038e-03,3.664579779339879884e-02,-3.007244590430930078e-02
-5.637009329308430294e-02,-4.464163650698899782e-02,-8.057498723359039772e-02,-8.485663651086830517e-02,-3.734373413344069942e-02,-3.701280207022530216e-02,3.391354823380159783e-02,-3.949338287409189657e-02,-5.615757309500619965e-02,-1.377672256900120129e-01
2.717829108036539862e-02,-4.464163650698899782e-02,9.295275666123460623e-02,-5.272317671413939699e-02,8.062710187196569719e-03,3.970857106821010230e-02,-2.867429443567860031e-02,2.102445536239900062e-02,-4.836172480289190057e-02,1.963283707370720027e-02
6.350367559056099842e-02,-4.464163650698899782e-02,-5.039624916492520257e-02,1.079441223383619947e-01,3.145390877661580209e-02,1.935392105189049847e-02,-1.762938102341739949e-02,2.360753382371260159e-02,5.803912766389510147e-02,4.034337164788070335e-02
-5.273755484206479882e-02,5.068011873981870252e-02,-1.159501450521270051e-02,5.630106193231849965e-02,5.622106022423609822e-02,7.290230801790049953e-02,-3.971920784793980114e-02,7.120997975363539678e-02,3.056648739841480097e-02,-5.219804415301099697e-03
-9.147093429830140468e-03,5.068011873981870252e-02,-2.776219561342629927e-02,8.100872220010799790e-03,4.796534307502930278e-02,3.720338337389379746e-02,-2.867429443567860031e-02,3.430885887772629900e-02,6.604820616309839409e-02,-4.249876664881350324e-02
5.383060374248070309e-03,-4.464163650698899782e-02,5.846277029704580186e-02,-4.354218818603310115e-02,-7.311850844667000526e-02,-7.239857825244250256e-02,1.918699701745330000e-02,-7.639450375000099436e-02,-5.140053526058249722e-02,-2.593033898947460017e-02
7.440129094361959405e-02,-4.464163650698899782e-02,8.540807214406830050e-02,6.318680331979099896e-02,1.494247447820220079e-02,1.309095181609989944e-02,1.550535921336619952e-02,-2.592261998182820038e-03,6.209315616505399656e-03,8.590654771106250032e-02
-5.273755484206479882e-02,-4.464163650698899782e-02,-8.168937664037369826e-04,-2.632783471735180084e-02,1.081461590359879960e-02,7.141131042098750048e-03,4.864009945014990260e-02,-3.949338287409189657e-02,-3.581672810154919867e-02,1.963283707370720027e-02
8.166636784565869944e-02,5.068011873981870252e-02,6.727790750762559745e-03,-4.522987001831730094e-03,1.098832216940800049e-01,1.170562411302250028e-01,-3.235593223976569732e-02,9.187460744414439884e-02,5.472400334817909689e-02,7.206516329203029904e-03
-5.514554978810590376e-03,-4.464163650698899782e-02,8.883414898524360018e-03,-5.042792957350569760e-02,2.595009734381130070e-02,4.722413415115889884e-02,-4.340084565202689815e-02,7.120997975363539678e-02,1.482271084126630077e-02,3.064409414368320182e-03
-2.730978568492789874e-02,-4.464163650698899782e-02,8.001901177466380632e-02,9.876313370696999938e-02,-2.944912678412469915e-03,1.810132720473240156e-02,-1.762938102341739949e-02,3.311917341962639788e-03,-2.952762274177360077e-02,3.620126473304600273e-02
-5.273755484206479882e-02,-4.464163650698899782e-02,7.139651518361660176e-02,-7.452802442965950069e-02,-1.532848840222260020e-02,-1.313877426218630021e-03,4.460445801105040325e-03,-2.141183364489639834e-02,-4.687948284421659950e-02,3.064409414368320182e-03
9.015598825267629943e-03,-4.464163650698899782e-02,-2.452875939178359929e-02,-2.632783471735180084e-02,9.887559882847110626e-02,9.419640341958869512e-02,7.072992627467229731e-02,-2.592261998182820038e-03,-2.139368094035999993e-02,7.206516329203029904e-03
-2.004470878288880029e-02,-4.464163650698899782e-02,-5.470749746044879791e-02,-5.387080026724189868e-02,-6.623874415566440021e-02,-5.736745208654490252e-02,1.182372140927919965e-02,-3.949338287409189657e-02,-7.408887149153539631e-02,-5.219804415301099697e-03
2.354575262934580082e-02,-4.464163650698899782e-02,-3.638469220447349689e-02,6.750727943574620551e-05,1.182945896190920002e-03,3.469819567957759671e-02,-4.340084565202689815e-02,3.430885887772629900e-02,-3.324878724762579674e-02,6.105390622205419948e-02
3.807590643342410180e-02,5.068011873981870252e-02,1.642809941569069870e-02,2.187235499495579841e-02,3.970962592582259754e-02,4.503209491863210262e-02,-4.340084565202689815e-02,7.120997975363539678e-02,4.976865992074899769e-02,1.549073015887240078e-02
-7.816532399920170238e-02,5.068011873981870252e-02,7.786338762690199478e-02,5.285819123858220142e-02,7.823630595545419397e-02,6.444729954958319795e-02,2.655027262562750096e-02,-2.592261998182820038e-03,4.067226371449769728e-02,-9.361911330135799444e-03
9.015598825267629943e-03,5.068011873981870252e-02,-3.961812842611620034e-02,2.875809638242839833e-02,3.833367306762140020e-02,7.352860494147960002e-02,-7.285394808472339667e-02,1.081111006295440019e-01,1.556684454070180086e-02,-4.664087356364819692e-02
1.750521923228520000e-03,5.068011873981870252e-02,1.103903904628619932e-02,-1.944209332987930153e-02,-1.670444126042380101e-02,-3.819065120534880214e-03,-4.708248345611389801e-02,3.430885887772629900e-02,2.405258322689299982e-02,2.377494398854190089e-02
-7.816532399920170238e-02,-4.464163650698899782e-02,-4.069594049999709917e-02,-8.141376581713200000e-02,-1.006375656106929944e-01,-1.127947298232920004e-01,2.286863482154040048e-02,-7.639450375000099436e-02,-2.028874775162960165e-02,-5.078298047848289754e-02
3.081082953138499989e-02,5.068011873981870252e-02,-3.422906805671169922e-02,4.367720260718979675e-02,5.759701308243719842e-02,6.883137801463659611e-02,-3.235593223976569732e-02,5.755656502954899917e-02,3.546193866076970125e-02,8.590654771106250032e-02
-3.457486258696700065e-02,5.068011873981870252e-02,5.649978676881649634e-03,-5.670610554934250001e-03,-7.311850844667000526e-02,-6.269097593696699999e-02,-6.584467611156170040e-03,-3.949338287409189657e-02,-4.542095777704099890e-02,3.205915781821130212e-02
4.897352178648269744e-02,5.068011873981870252e-02,8.864150836571099701e-02,8.728689817594480205e-02,3.558176735121919981e-02,2.154596028441720101e-02,-2.499265663159149983e-02,3.430885887772629900e-02,6.604820616309839409e-02,1.314697237742440128e-01
-4.183993948900609910e-02,-4.464163650698899782e-02,-3.315125598283080038e-02,-2.288496402361559975e-02,4.658939021682820258e-02,4.158746183894729970e-02,5.600337505832399948e-02,-2.473293452372829840e-02,-2.595242443518940012e-02,-3.835665973397880263e-02
-9.147093429830140468e-03,-4.464163650698899782e-02,-5.686312160821060252e-02,-5.042792957350569760e-02,2.182223876920789951e-02,4.534524338042170144e-02,-2.867429443567860031e-02,3.430885887772629900e-02,-9.918957363154769225e-03,-1.764612515980519894e-02
7.076875249260000666e-02,5.068011873981870252e-02,-3.099563183506899924e-02,2.187235499495579841e-02,-3.734373413344069942e-02,-4.703355284749029946e-02,3.391354823380159783e-02,-3.949338287409189657e-02,-1.495647502491130078e-02,-1.077697500466389974e-03
9.015598825267629943e-03,-4.464163650698899782e-02,5.522933407540309841e-02,-5.670610554934250001e-03,5.759701308243719842e-02,4.471894645684260094e-02,-2.902829807069099918e-03,2.323852261495349888e-02,5.568354770267369691e-02,1.066170822852360034e-01
-2.730978568492789874e-02,-4.464163650698899782e-02,-6.009655782985329903e-02,-2.977070541108809906e-02,4.658939021682820258e-02,1.998021797546959896e-02,1.222728555318910032e-01,-3.949338287409189657e-02,-5.140053526058249722e-02,-9.361911330135799444e-03
1.628067572730669890e-02,-4.464163650698899782e-02,1.338730381358059929e-03,8.100872220010799790e-03,5.310804470794310353e-03,1.089891258357309975e-02,3.023191042971450082e-02,-3.949338287409189657e-02,-4.542095777704099890e-02,3.205915781821130212e-02
-1.277963188084970010e-02,-4.464163650698899782e-02,-2.345094731790270046e-02,-4.009931749229690007e-02,-1.670444126042380101e-02,4.635943347782499856e-03,-1.762938102341739949e-02,-2.592261998182820038e-03,-3.845911230135379971e-02,-3.835665973397880263e-02
-5.637009329308430294e-02,-4.464163650698899782e-02,-7.410811479030500470e-02,-5.042792957350569760e-02,-2.496015840963049931e-02,-4.703355284749029946e-02,9.281975309919469896e-02,-7.639450375000099436e-02,-6.117659509433449883e-02,-4.664087356364819692e-02
4.170844488444359899e-02,5.068011873981870252e-02,1.966153563733339868e-02,5.974393262605470073e-02,-5.696818394814720174e-03,-2.566471273376759888e-03,-2.867429443567860031e-02,-2.592261998182820038e-03,3.119299070280229930e-02,7.206516329203029904e-03
-5.514554978810590376e-03,5.068011873981870252e-02,-1.590626280073640167e-02,-6.764228304218700139e-02,4.934129593323050011e-02,7.916527725369119917e-02,-2.867429443567860031e-02,3.430885887772629900e-02,-1.811826730789670159e-02,4.448547856271539702e-02
4.170844488444359899e-02,5.068011873981870252e-02,-1.590626280073640167e-02,1.728186074811709910e-02,-3.734373413344069942e-02,-1.383981589779990050e-02,-2.499265663159149983e-02,-1.107951979964190078e-02,-4.687948284421659950e-02,1.549073015887240078e-02
-4.547247794002570037e-02,-4.464163650698899782e-02,3.906215296718960200e-02,1.215130832538269907e-03,1.631842733640340160e-02,1.528299104862660025e-02,-2.867429443567860031e-02,2.655962349378539894e-02,4.452837402140529671e-02,-2.593033898947460017e-02
-4.547247794002570037e-02,-4.464163650698899782e-02,-7.303030271642410587e-02,-8.141376581713200000e-02,8.374011738825870577e-02,2.780892952020790065e-02,1.738157847891100005e-01,-3.949338287409189657e-02,-4.219859706946029777e-03,3.064409414368320182e-03
1 3.807590643342410180e-02 5.068011873981870252e-02 6.169620651868849837e-02 2.187235499495579841e-02 -4.422349842444640161e-02 -3.482076283769860309e-02 -4.340084565202689815e-02 -2.592261998182820038e-03 1.990842087631829876e-02 -1.764612515980519894e-02
2 -1.882016527791040067e-03 -4.464163650698899782e-02 -5.147406123880610140e-02 -2.632783471735180084e-02 -8.448724111216979540e-03 -1.916333974822199970e-02 7.441156407875940126e-02 -3.949338287409189657e-02 -6.832974362442149896e-02 -9.220404962683000083e-02
3 8.529890629667830071e-02 5.068011873981870252e-02 4.445121333659410312e-02 -5.670610554934250001e-03 -4.559945128264750180e-02 -3.419446591411950259e-02 -3.235593223976569732e-02 -2.592261998182820038e-03 2.863770518940129874e-03 -2.593033898947460017e-02
4 -8.906293935226029801e-02 -4.464163650698899782e-02 -1.159501450521270051e-02 -3.665644679856060184e-02 1.219056876180000040e-02 2.499059336410210108e-02 -3.603757004385269719e-02 3.430885887772629900e-02 2.269202256674450122e-02 -9.361911330135799444e-03
5 5.383060374248070309e-03 -4.464163650698899782e-02 -3.638469220447349689e-02 2.187235499495579841e-02 3.934851612593179802e-03 1.559613951041610019e-02 8.142083605192099172e-03 -2.592261998182820038e-03 -3.199144494135589684e-02 -4.664087356364819692e-02
6 -9.269547780327989928e-02 -4.464163650698899782e-02 -4.069594049999709917e-02 -1.944209332987930153e-02 -6.899064987206669775e-02 -7.928784441181220555e-02 4.127682384197570165e-02 -7.639450375000099436e-02 -4.118038518800790082e-02 -9.634615654166470144e-02
7 -4.547247794002570037e-02 5.068011873981870252e-02 -4.716281294328249912e-02 -1.599922263614299983e-02 -4.009563984984299695e-02 -2.480001206043359885e-02 7.788079970179680352e-04 -3.949338287409189657e-02 -6.291294991625119570e-02 -3.835665973397880263e-02
8 6.350367559056099842e-02 5.068011873981870252e-02 -1.894705840284650021e-03 6.662967401352719310e-02 9.061988167926439408e-02 1.089143811236970016e-01 2.286863482154040048e-02 1.770335448356720118e-02 -3.581672810154919867e-02 3.064409414368320182e-03
9 4.170844488444359899e-02 5.068011873981870252e-02 6.169620651868849837e-02 -4.009931749229690007e-02 -1.395253554402150001e-02 6.201685656730160021e-03 -2.867429443567860031e-02 -2.592261998182820038e-03 -1.495647502491130078e-02 1.134862324403770016e-02
10 -7.090024709716259699e-02 -4.464163650698899782e-02 3.906215296718960200e-02 -3.321357610482440076e-02 -1.257658268582039982e-02 -3.450761437590899733e-02 -2.499265663159149983e-02 -2.592261998182820038e-03 6.773632611028609918e-02 -1.350401824497050006e-02
11 -9.632801625429950054e-02 -4.464163650698899782e-02 -8.380842345523309422e-02 8.100872220010799790e-03 -1.033894713270950005e-01 -9.056118903623530669e-02 -1.394774321933030074e-02 -7.639450375000099436e-02 -6.291294991625119570e-02 -3.421455281914410201e-02
12 2.717829108036539862e-02 5.068011873981870252e-02 1.750591148957160101e-02 -3.321357610482440076e-02 -7.072771253015849857e-03 4.597154030400080194e-02 -6.549067247654929980e-02 7.120997975363539678e-02 -9.643322289178400675e-02 -5.906719430815229877e-02
13 1.628067572730669890e-02 -4.464163650698899782e-02 -2.884000768730720157e-02 -9.113481248670509197e-03 -4.320865536613589623e-03 -9.768885894535990141e-03 4.495846164606279866e-02 -3.949338287409189657e-02 -3.075120986455629965e-02 -4.249876664881350324e-02
14 5.383060374248070309e-03 5.068011873981870252e-02 -1.894705840284650021e-03 8.100872220010799790e-03 -4.320865536613589623e-03 -1.571870666853709964e-02 -2.902829807069099918e-03 -2.592261998182820038e-03 3.839324821169769891e-02 -1.350401824497050006e-02
15 4.534098333546320025e-02 -4.464163650698899782e-02 -2.560657146566450160e-02 -1.255635194240680048e-02 1.769438019460449832e-02 -6.128357906048329537e-05 8.177483968693349814e-02 -3.949338287409189657e-02 -3.199144494135589684e-02 -7.563562196749110123e-02
16 -5.273755484206479882e-02 5.068011873981870252e-02 -1.806188694849819934e-02 8.040115678847230274e-02 8.924392882106320368e-02 1.076617872765389949e-01 -3.971920784793980114e-02 1.081111006295440019e-01 3.605579008983190309e-02 -4.249876664881350324e-02
17 -5.514554978810590376e-03 -4.464163650698899782e-02 4.229558918883229851e-02 4.941532054484590319e-02 2.457414448561009990e-02 -2.386056667506489953e-02 7.441156407875940126e-02 -3.949338287409189657e-02 5.227999979678119719e-02 2.791705090337660150e-02
18 7.076875249260000666e-02 5.068011873981870252e-02 1.211685112016709989e-02 5.630106193231849965e-02 3.420581449301800248e-02 4.941617338368559792e-02 -3.971920784793980114e-02 3.430885887772629900e-02 2.736770754260900093e-02 -1.077697500466389974e-03
19 -3.820740103798660192e-02 -4.464163650698899782e-02 -1.051720243133190055e-02 -3.665644679856060184e-02 -3.734373413344069942e-02 -1.947648821001150138e-02 -2.867429443567860031e-02 -2.592261998182820038e-03 -1.811826730789670159e-02 -1.764612515980519894e-02
20 -2.730978568492789874e-02 -4.464163650698899782e-02 -1.806188694849819934e-02 -4.009931749229690007e-02 -2.944912678412469915e-03 -1.133462820348369975e-02 3.759518603788870178e-02 -3.949338287409189657e-02 -8.944018957797799166e-03 -5.492508739331759815e-02
21 -4.910501639104519755e-02 -4.464163650698899782e-02 -5.686312160821060252e-02 -4.354218818603310115e-02 -4.559945128264750180e-02 -4.327577130601600180e-02 7.788079970179680352e-04 -3.949338287409189657e-02 -1.190068480150809939e-02 1.549073015887240078e-02
22 -8.543040090124079389e-02 5.068011873981870252e-02 -2.237313524402180162e-02 1.215130832538269907e-03 -3.734373413344069942e-02 -2.636575436938120090e-02 1.550535921336619952e-02 -3.949338287409189657e-02 -7.212845460195599356e-02 -1.764612515980519894e-02
23 -8.543040090124079389e-02 -4.464163650698899782e-02 -4.050329988046450294e-03 -9.113481248670509197e-03 -2.944912678412469915e-03 7.767427965677820186e-03 2.286863482154040048e-02 -3.949338287409189657e-02 -6.117659509433449883e-02 -1.350401824497050006e-02
24 4.534098333546320025e-02 5.068011873981870252e-02 6.061839444480759953e-02 3.105334362634819961e-02 2.870200306021350109e-02 -4.734670130927989828e-02 -5.444575906428809897e-02 7.120997975363539678e-02 1.335989800130079896e-01 1.356118306890790048e-01
25 -6.363517019512339445e-02 -4.464163650698899782e-02 3.582871674554689856e-02 -2.288496402361559975e-02 -3.046396984243510131e-02 -1.885019128643240088e-02 -6.584467611156170040e-03 -2.592261998182820038e-03 -2.595242443518940012e-02 -5.492508739331759815e-02
26 -6.726770864614299572e-02 5.068011873981870252e-02 -1.267282657909369996e-02 -4.009931749229690007e-02 -1.532848840222260020e-02 4.635943347782499856e-03 -5.812739686837520292e-02 3.430885887772629900e-02 1.919903307856710151e-02 -3.421455281914410201e-02
27 -1.072256316073579990e-01 -4.464163650698899782e-02 -7.734155101194770121e-02 -2.632783471735180084e-02 -8.962994274508359616e-02 -9.619786134844690584e-02 2.655027262562750096e-02 -7.639450375000099436e-02 -4.257210492279420166e-02 -5.219804415301099697e-03
28 -2.367724723390840155e-02 -4.464163650698899782e-02 5.954058237092670069e-02 -4.009931749229690007e-02 -4.284754556624519733e-02 -4.358891976780549654e-02 1.182372140927919965e-02 -3.949338287409189657e-02 -1.599826775813870117e-02 4.034337164788070335e-02
29 5.260606023750229870e-02 -4.464163650698899782e-02 -2.129532317014089932e-02 -7.452802442965950069e-02 -4.009563984984299695e-02 -3.763909899380440266e-02 -6.584467611156170040e-03 -3.949338287409189657e-02 -6.092541861022970299e-04 -5.492508739331759815e-02
30 6.713621404158050254e-02 5.068011873981870252e-02 -6.205954135808240159e-03 6.318680331979099896e-02 -4.284754556624519733e-02 -9.588471288665739722e-02 5.232173725423699961e-02 -7.639450375000099436e-02 5.942380044479410317e-02 5.276969239238479825e-02
31 -6.000263174410389727e-02 -4.464163650698899782e-02 4.445121333659410312e-02 -1.944209332987930153e-02 -9.824676969418109224e-03 -7.576846662009279788e-03 2.286863482154040048e-02 -3.949338287409189657e-02 -2.712864555432650121e-02 -9.361911330135799444e-03
32 -2.367724723390840155e-02 -4.464163650698899782e-02 -6.548561819925780014e-02 -8.141376581713200000e-02 -3.871968699164179961e-02 -5.360967054507050078e-02 5.968501286241110343e-02 -7.639450375000099436e-02 -3.712834601047360072e-02 -4.249876664881350324e-02
33 3.444336798240450054e-02 5.068011873981870252e-02 1.252871188776620015e-01 2.875809638242839833e-02 -5.385516843185429725e-02 -1.290037051243130006e-02 -1.023070505174200062e-01 1.081111006295440019e-01 2.714857279071319972e-04 2.791705090337660150e-02
34 3.081082953138499989e-02 -4.464163650698899782e-02 -5.039624916492520257e-02 -2.227739861197989939e-03 -4.422349842444640161e-02 -8.993489211265630334e-02 1.185912177278039964e-01 -7.639450375000099436e-02 -1.811826730789670159e-02 3.064409414368320182e-03
35 1.628067572730669890e-02 -4.464163650698899782e-02 -6.332999405149600247e-02 -5.731367096097819691e-02 -5.798302700645770191e-02 -4.891244361822749687e-02 8.142083605192099172e-03 -3.949338287409189657e-02 -5.947269741072230137e-02 -6.735140813782170000e-02
36 4.897352178648269744e-02 5.068011873981870252e-02 -3.099563183506899924e-02 -4.928030602040309877e-02 4.934129593323050011e-02 -4.132213582324419619e-03 1.333177689441520097e-01 -5.351580880693729975e-02 2.131084656824479978e-02 1.963283707370720027e-02
37 1.264813727628719998e-02 -4.464163650698899782e-02 2.289497185897609866e-02 5.285819123858220142e-02 8.062710187196569719e-03 -2.855779360190789998e-02 3.759518603788870178e-02 -3.949338287409189657e-02 5.472400334817909689e-02 -2.593033898947460017e-02
38 -9.147093429830140468e-03 -4.464163650698899782e-02 1.103903904628619932e-02 -5.731367096097819691e-02 -2.496015840963049931e-02 -4.296262284422640298e-02 3.023191042971450082e-02 -3.949338287409189657e-02 1.703713241477999851e-02 -5.219804415301099697e-03
39 -1.882016527791040067e-03 5.068011873981870252e-02 7.139651518361660176e-02 9.761551025715360652e-02 8.786797596286209655e-02 7.540749571221680436e-02 -2.131101882750449997e-02 7.120997975363539678e-02 7.142403278057639360e-02 2.377494398854190089e-02
40 -1.882016527791040067e-03 5.068011873981870252e-02 1.427247526792889930e-02 -7.452802442965950069e-02 2.558898754392050119e-03 6.201685656730160021e-03 -1.394774321933030074e-02 -2.592261998182820038e-03 1.919903307856710151e-02 3.064409414368320182e-03
41 5.383060374248070309e-03 5.068011873981870252e-02 -8.361578283570040432e-03 2.187235499495579841e-02 5.484510736603499803e-02 7.321545647968999426e-02 -2.499265663159149983e-02 3.430885887772629900e-02 1.255315281338930007e-02 9.419076154073199869e-02
42 -9.996055470531900466e-02 -4.464163650698899782e-02 -6.764124234701959781e-02 -1.089567313670219972e-01 -7.449446130487119566e-02 -7.271172671423199729e-02 1.550535921336619952e-02 -3.949338287409189657e-02 -4.986846773523059828e-02 -9.361911330135799444e-03
43 -6.000263174410389727e-02 5.068011873981870252e-02 -1.051720243133190055e-02 -1.485159908304049987e-02 -4.972730985725089953e-02 -2.354741821327540133e-02 -5.812739686837520292e-02 1.585829843977170153e-02 -9.918957363154769225e-03 -3.421455281914410201e-02
44 1.991321417832630017e-02 -4.464163650698899782e-02 -2.345094731790270046e-02 -7.108515373592319553e-02 2.044628591100669870e-02 -1.008203435632550049e-02 1.185912177278039964e-01 -7.639450375000099436e-02 -4.257210492279420166e-02 7.348022696655839847e-02
45 4.534098333546320025e-02 5.068011873981870252e-02 6.816307896197400240e-02 8.100872220010799790e-03 -1.670444126042380101e-02 4.635943347782499856e-03 -7.653558588881050062e-02 7.120997975363539678e-02 3.243322577960189995e-02 -1.764612515980519894e-02
46 2.717829108036539862e-02 5.068011873981870252e-02 -3.530688013059259805e-02 3.220096707616459941e-02 -1.120062982761920074e-02 1.504458729887179960e-03 -1.026610541524320026e-02 -2.592261998182820038e-03 -1.495647502491130078e-02 -5.078298047848289754e-02
47 -5.637009329308430294e-02 -4.464163650698899782e-02 -1.159501450521270051e-02 -3.321357610482440076e-02 -4.697540414084860200e-02 -4.765984977106939996e-02 4.460445801105040325e-03 -3.949338287409189657e-02 -7.979397554541639223e-03 -8.806194271199530021e-02
48 -7.816532399920170238e-02 -4.464163650698899782e-02 -7.303030271642410587e-02 -5.731367096097819691e-02 -8.412613131227909824e-02 -7.427746902317970690e-02 -2.499265663159149983e-02 -3.949338287409189657e-02 -1.811826730789670159e-02 -8.391983579716059960e-02
49 6.713621404158050254e-02 5.068011873981870252e-02 -4.177375257387799801e-02 1.154374291374709975e-02 2.558898754392050119e-03 5.888537194940629722e-03 4.127682384197570165e-02 -3.949338287409189657e-02 -5.947269741072230137e-02 -2.178823207463989955e-02
50 -4.183993948900609910e-02 5.068011873981870252e-02 1.427247526792889930e-02 -5.670610554934250001e-03 -1.257658268582039982e-02 6.201685656730160021e-03 -7.285394808472339667e-02 7.120997975363539678e-02 3.546193866076970125e-02 -1.350401824497050006e-02
51 3.444336798240450054e-02 -4.464163650698899782e-02 -7.283766209689159811e-03 1.498661360748330083e-02 -4.422349842444640161e-02 -3.732595053201490098e-02 -2.902829807069099918e-03 -3.949338287409189657e-02 -2.139368094035999993e-02 7.206516329203029904e-03
52 5.987113713954139715e-02 5.068011873981870252e-02 1.642809941569069870e-02 2.875809638242839833e-02 -4.147159270804409714e-02 -2.918409052548700047e-02 -2.867429443567860031e-02 -2.592261998182820038e-03 -2.396681493414269844e-03 -2.178823207463989955e-02
53 -5.273755484206479882e-02 -4.464163650698899782e-02 -9.439390357450949676e-03 -5.670610554934250001e-03 3.970962592582259754e-02 4.471894645684260094e-02 2.655027262562750096e-02 -2.592261998182820038e-03 -1.811826730789670159e-02 -1.350401824497050006e-02
54 -9.147093429830140468e-03 -4.464163650698899782e-02 -1.590626280073640167e-02 7.007254470726349826e-02 1.219056876180000040e-02 2.217225720799630151e-02 1.550535921336619952e-02 -2.592261998182820038e-03 -3.324878724762579674e-02 4.862758547755009764e-02
55 -4.910501639104519755e-02 -4.464163650698899782e-02 2.505059600673789980e-02 8.100872220010799790e-03 2.044628591100669870e-02 1.778817874294279927e-02 5.232173725423699961e-02 -3.949338287409189657e-02 -4.118038518800790082e-02 7.206516329203029904e-03
56 -4.183993948900609910e-02 -4.464163650698899782e-02 -4.931843709104429679e-02 -3.665644679856060184e-02 -7.072771253015849857e-03 -2.260797282790679916e-02 8.545647749102060209e-02 -3.949338287409189657e-02 -6.648814822283539983e-02 7.206516329203029904e-03
57 -4.183993948900609910e-02 -4.464163650698899782e-02 4.121777711495139968e-02 -2.632783471735180084e-02 -3.183992270063620150e-02 -3.043668437264510085e-02 -3.603757004385269719e-02 2.942906133203560069e-03 3.365681290238470291e-02 -1.764612515980519894e-02
58 -2.730978568492789874e-02 -4.464163650698899782e-02 -6.332999405149600247e-02 -5.042792957350569760e-02 -8.962994274508359616e-02 -1.043397213549750041e-01 5.232173725423699961e-02 -7.639450375000099436e-02 -5.615757309500619965e-02 -6.735140813782170000e-02
59 4.170844488444359899e-02 -4.464163650698899782e-02 -6.440780612537699845e-02 3.564383776990089764e-02 1.219056876180000040e-02 -5.799374901012400302e-02 1.811790603972839864e-01 -7.639450375000099436e-02 -6.092541861022970299e-04 -5.078298047848289754e-02
60 6.350367559056099842e-02 5.068011873981870252e-02 -2.560657146566450160e-02 1.154374291374709975e-02 6.447677737344290061e-02 4.847672799831700269e-02 3.023191042971450082e-02 -2.592261998182820038e-03 3.839324821169769891e-02 1.963283707370720027e-02
61 -7.090024709716259699e-02 -4.464163650698899782e-02 -4.050329988046450294e-03 -4.009931749229690007e-02 -6.623874415566440021e-02 -7.866154748823310505e-02 5.232173725423699961e-02 -7.639450375000099436e-02 -5.140053526058249722e-02 -3.421455281914410201e-02
62 -4.183993948900609910e-02 5.068011873981870252e-02 4.572166603000769880e-03 -5.387080026724189868e-02 -4.422349842444640161e-02 -2.730519975474979960e-02 -8.021722369289760457e-02 7.120997975363539678e-02 3.664579779339879884e-02 1.963283707370720027e-02
63 -2.730978568492789874e-02 5.068011873981870252e-02 -7.283766209689159811e-03 -4.009931749229690007e-02 -1.120062982761920074e-02 -1.383981589779990050e-02 5.968501286241110343e-02 -3.949338287409189657e-02 -8.238148325810279449e-02 -2.593033898947460017e-02
64 -3.457486258696700065e-02 -4.464163650698899782e-02 -3.746250427835440266e-02 -6.075654165471439799e-02 2.044628591100669870e-02 4.346635260968449710e-02 -1.394774321933030074e-02 -2.592261998182820038e-03 -3.075120986455629965e-02 -7.149351505265640061e-02
65 6.713621404158050254e-02 5.068011873981870252e-02 -2.560657146566450160e-02 -4.009931749229690007e-02 -6.348683843926219983e-02 -5.987263978086120042e-02 -2.902829807069099918e-03 -3.949338287409189657e-02 -1.919704761394450121e-02 1.134862324403770016e-02
66 -4.547247794002570037e-02 5.068011873981870252e-02 -2.452875939178359929e-02 5.974393262605470073e-02 5.310804470794310353e-03 1.496984258683710031e-02 -5.444575906428809897e-02 7.120997975363539678e-02 4.234489544960749752e-02 1.549073015887240078e-02
67 -9.147093429830140468e-03 5.068011873981870252e-02 -1.806188694849819934e-02 -3.321357610482440076e-02 -2.083229983502719873e-02 1.215150643073130074e-02 -7.285394808472339667e-02 7.120997975363539678e-02 2.714857279071319972e-04 1.963283707370720027e-02
68 4.170844488444359899e-02 5.068011873981870252e-02 -1.482845072685549936e-02 -1.714684618924559867e-02 -5.696818394814720174e-03 8.393724889256879915e-03 -1.394774321933030074e-02 -1.854239580664649974e-03 -1.190068480150809939e-02 3.064409414368320182e-03
69 3.807590643342410180e-02 5.068011873981870252e-02 -2.991781976118810041e-02 -4.009931749229690007e-02 -3.321587555883730170e-02 -2.417371513685449835e-02 -1.026610541524320026e-02 -2.592261998182820038e-03 -1.290794225416879923e-02 3.064409414368320182e-03
70 1.628067572730669890e-02 -4.464163650698899782e-02 -4.608500086940160029e-02 -5.670610554934250001e-03 -7.587041416307230279e-02 -6.143838208980879900e-02 -1.394774321933030074e-02 -3.949338287409189657e-02 -5.140053526058249722e-02 1.963283707370720027e-02
71 -1.882016527791040067e-03 -4.464163650698899782e-02 -6.979686649478139548e-02 -1.255635194240680048e-02 -1.930069620102049918e-04 -9.142588970956939953e-03 7.072992627467229731e-02 -3.949338287409189657e-02 -6.291294991625119570e-02 4.034337164788070335e-02
72 -1.882016527791040067e-03 -4.464163650698899782e-02 3.367309259778510089e-02 1.251584758070440062e-01 2.457414448561009990e-02 2.624318721126020146e-02 -1.026610541524320026e-02 -2.592261998182820038e-03 2.671425763351279944e-02 6.105390622205419948e-02
73 6.350367559056099842e-02 5.068011873981870252e-02 -4.050329988046450294e-03 -1.255635194240680048e-02 1.030034574030749966e-01 4.878987646010649742e-02 5.600337505832399948e-02 -2.592261998182820038e-03 8.449528221240310000e-02 -1.764612515980519894e-02
74 1.264813727628719998e-02 5.068011873981870252e-02 -2.021751109626000048e-02 -2.227739861197989939e-03 3.833367306762140020e-02 5.317395492515999966e-02 -6.584467611156170040e-03 3.430885887772629900e-02 -5.145307980263110273e-03 -9.361911330135799444e-03
75 1.264813727628719998e-02 5.068011873981870252e-02 2.416542455238970041e-03 5.630106193231849965e-02 2.732605020201240090e-02 1.716188181936379939e-02 4.127682384197570165e-02 -3.949338287409189657e-02 3.711738233435969789e-03 7.348022696655839847e-02
76 -9.147093429830140468e-03 5.068011873981870252e-02 -3.099563183506899924e-02 -2.632783471735180084e-02 -1.120062982761920074e-02 -1.000728964429089965e-03 -2.131101882750449997e-02 -2.592261998182820038e-03 6.209315616505399656e-03 2.791705090337660150e-02
77 -3.094232413594750000e-02 5.068011873981870252e-02 2.828403222838059977e-02 7.007254470726349826e-02 -1.267806699165139883e-01 -1.068449090492910036e-01 -5.444575906428809897e-02 -4.798064067555100204e-02 -3.075120986455629965e-02 1.549073015887240078e-02
78 -9.632801625429950054e-02 -4.464163650698899782e-02 -3.638469220447349689e-02 -7.452802442965950069e-02 -3.871968699164179961e-02 -2.761834821653930128e-02 1.550535921336619952e-02 -3.949338287409189657e-02 -7.408887149153539631e-02 -1.077697500466389974e-03
79 5.383060374248070309e-03 -4.464163650698899782e-02 -5.794093368209150136e-02 -2.288496402361559975e-02 -6.761469701386560449e-02 -6.832764824917850199e-02 -5.444575906428809897e-02 -2.592261998182820038e-03 4.289568789252869857e-02 -8.391983579716059960e-02
80 -1.035930931563389945e-01 -4.464163650698899782e-02 -3.746250427835440266e-02 -2.632783471735180084e-02 2.558898754392050119e-03 1.998021797546959896e-02 1.182372140927919965e-02 -2.592261998182820038e-03 -6.832974362442149896e-02 -2.593033898947460017e-02
81 7.076875249260000666e-02 -4.464163650698899782e-02 1.211685112016709989e-02 4.252957915737339695e-02 7.135654166444850566e-02 5.348710338694950134e-02 5.232173725423699961e-02 -2.592261998182820038e-03 2.539313491544940155e-02 -5.219804415301099697e-03
82 1.264813727628719998e-02 5.068011873981870252e-02 -2.237313524402180162e-02 -2.977070541108809906e-02 1.081461590359879960e-02 2.843522644378690054e-02 -2.131101882750449997e-02 3.430885887772629900e-02 -6.080248196314420352e-03 -1.077697500466389974e-03
83 -1.641217033186929963e-02 -4.464163650698899782e-02 -3.530688013059259805e-02 -2.632783471735180084e-02 3.282986163481690228e-02 1.716188181936379939e-02 1.001830287073690040e-01 -3.949338287409189657e-02 -7.020931272868760620e-02 -7.977772888232589898e-02
84 -3.820740103798660192e-02 -4.464163650698899782e-02 9.961226972405269262e-03 -4.698505887976939938e-02 -5.935897986465880211e-02 -5.298337362149149743e-02 -1.026610541524320026e-02 -3.949338287409189657e-02 -1.599826775813870117e-02 -4.249876664881350324e-02
85 1.750521923228520000e-03 -4.464163650698899782e-02 -3.961812842611620034e-02 -1.009233664264470032e-01 -2.908801698423390050e-02 -3.012353591085559917e-02 4.495846164606279866e-02 -5.019470792810550031e-02 -6.832974362442149896e-02 -1.294830118603420011e-01
86 4.534098333546320025e-02 -4.464163650698899782e-02 7.139651518361660176e-02 1.215130832538269907e-03 -9.824676969418109224e-03 -1.000728964429089965e-03 1.550535921336619952e-02 -3.949338287409189657e-02 -4.118038518800790082e-02 -7.149351505265640061e-02
87 -7.090024709716259699e-02 5.068011873981870252e-02 -7.518592686418590354e-02 -4.009931749229690007e-02 -5.110326271545199972e-02 -1.509240974495799914e-02 -3.971920784793980114e-02 -2.592261998182820038e-03 -9.643322289178400675e-02 -3.421455281914410201e-02
88 4.534098333546320025e-02 -4.464163650698899782e-02 -6.205954135808240159e-03 1.154374291374709975e-02 6.310082451524179348e-02 1.622243643399520069e-02 9.650139090328180291e-02 -3.949338287409189657e-02 4.289568789252869857e-02 -3.835665973397880263e-02
89 -5.273755484206479882e-02 5.068011873981870252e-02 -4.069594049999709917e-02 -6.764228304218700139e-02 -3.183992270063620150e-02 -3.701280207022530216e-02 3.759518603788870178e-02 -3.949338287409189657e-02 -3.452371533034950118e-02 6.933812005172369786e-02
90 -4.547247794002570037e-02 -4.464163650698899782e-02 -4.824062501716339796e-02 -1.944209332987930153e-02 -1.930069620102049918e-04 -1.603185513032660131e-02 6.704828847058519337e-02 -3.949338287409189657e-02 -2.479118743246069845e-02 1.963283707370720027e-02
91 1.264813727628719998e-02 -4.464163650698899782e-02 -2.560657146566450160e-02 -4.009931749229690007e-02 -3.046396984243510131e-02 -4.515466207675319921e-02 7.809320188284639419e-02 -7.639450375000099436e-02 -7.212845460195599356e-02 1.134862324403770016e-02
92 4.534098333546320025e-02 -4.464163650698899782e-02 5.199589785376040191e-02 -5.387080026724189868e-02 6.310082451524179348e-02 6.476044801137270657e-02 -1.026610541524320026e-02 3.430885887772629900e-02 3.723201120896890010e-02 1.963283707370720027e-02
93 -2.004470878288880029e-02 -4.464163650698899782e-02 4.572166603000769880e-03 9.761551025715360652e-02 5.310804470794310353e-03 -2.072908205716959829e-02 6.336665066649820044e-02 -3.949338287409189657e-02 1.255315281338930007e-02 1.134862324403770016e-02
94 -4.910501639104519755e-02 -4.464163650698899782e-02 -6.440780612537699845e-02 -1.020709899795499975e-01 -2.944912678412469915e-03 -1.540555820674759969e-02 6.336665066649820044e-02 -4.724261825803279663e-02 -3.324878724762579674e-02 -5.492508739331759815e-02
95 -7.816532399920170238e-02 -4.464163650698899782e-02 -1.698407487461730050e-02 -1.255635194240680048e-02 -1.930069620102049918e-04 -1.352666743601040056e-02 7.072992627467229731e-02 -3.949338287409189657e-02 -4.118038518800790082e-02 -9.220404962683000083e-02
96 -7.090024709716259699e-02 -4.464163650698899782e-02 -5.794093368209150136e-02 -8.141376581713200000e-02 -4.559945128264750180e-02 -2.887094206369749880e-02 -4.340084565202689815e-02 -2.592261998182820038e-03 1.143797379512540100e-03 -5.219804415301099697e-03
97 5.623859868852180283e-02 5.068011873981870252e-02 9.961226972405269262e-03 4.941532054484590319e-02 -4.320865536613589623e-03 -1.227407358885230018e-02 -4.340084565202689815e-02 3.430885887772629900e-02 6.078775415074400001e-02 3.205915781821130212e-02
98 -2.730978568492789874e-02 -4.464163650698899782e-02 8.864150836571099701e-02 -2.518021116424929914e-02 2.182223876920789951e-02 4.252690722431590187e-02 -3.235593223976569732e-02 3.430885887772629900e-02 2.863770518940129874e-03 7.762233388139309909e-02
99 1.750521923228520000e-03 5.068011873981870252e-02 -5.128142061927360405e-03 -1.255635194240680048e-02 -1.532848840222260020e-02 -1.383981589779990050e-02 8.142083605192099172e-03 -3.949338287409189657e-02 -6.080248196314420352e-03 -6.735140813782170000e-02
100 -1.882016527791040067e-03 -4.464163650698899782e-02 -6.440780612537699845e-02 1.154374291374709975e-02 2.732605020201240090e-02 3.751653183568340322e-02 -1.394774321933030074e-02 3.430885887772629900e-02 1.178390038357590014e-02 -5.492508739331759815e-02
101 1.628067572730669890e-02 -4.464163650698899782e-02 1.750591148957160101e-02 -2.288496402361559975e-02 6.034891879883950289e-02 4.440579799505309927e-02 3.023191042971450082e-02 -2.592261998182820038e-03 3.723201120896890010e-02 -1.077697500466389974e-03
102 1.628067572730669890e-02 5.068011873981870252e-02 -4.500718879552070145e-02 6.318680331979099896e-02 1.081461590359879960e-02 -3.744320408500199904e-04 6.336665066649820044e-02 -3.949338287409189657e-02 -3.075120986455629965e-02 3.620126473304600273e-02
103 -9.269547780327989928e-02 -4.464163650698899782e-02 2.828403222838059977e-02 -1.599922263614299983e-02 3.695772020942030001e-02 2.499059336410210108e-02 5.600337505832399948e-02 -3.949338287409189657e-02 -5.145307980263110273e-03 -1.077697500466389974e-03
104 5.987113713954139715e-02 5.068011873981870252e-02 4.121777711495139968e-02 1.154374291374709975e-02 4.108557878402369773e-02 7.071026878537380045e-02 -3.603757004385269719e-02 3.430885887772629900e-02 -1.090443584737709956e-02 -3.007244590430930078e-02
105 -2.730978568492789874e-02 -4.464163650698899782e-02 6.492964274033119487e-02 -2.227739861197989939e-03 -2.496015840963049931e-02 -1.728444897748479883e-02 2.286863482154040048e-02 -3.949338287409189657e-02 -6.117659509433449883e-02 -6.320930122298699938e-02
106 2.354575262934580082e-02 5.068011873981870252e-02 -3.207344390894990155e-02 -4.009931749229690007e-02 -3.183992270063620150e-02 -2.166852744253820046e-02 -1.394774321933030074e-02 -2.592261998182820038e-03 -1.090443584737709956e-02 1.963283707370720027e-02
107 -9.632801625429950054e-02 -4.464163650698899782e-02 -7.626373893806680238e-02 -4.354218818603310115e-02 -4.559945128264750180e-02 -3.482076283769860309e-02 8.142083605192099172e-03 -3.949338287409189657e-02 -5.947269741072230137e-02 -8.391983579716059960e-02
108 2.717829108036539862e-02 -4.464163650698899782e-02 4.984027370599859730e-02 -5.501842382034440038e-02 -2.944912678412469915e-03 4.064801645357869753e-02 -5.812739686837520292e-02 5.275941931568080279e-02 -5.295879323920039961e-02 -5.219804415301099697e-03
109 1.991321417832630017e-02 5.068011873981870252e-02 4.552902541047500196e-02 2.990571983224480160e-02 -6.211088558106100249e-02 -5.580170977759729700e-02 -7.285394808472339667e-02 2.692863470254440103e-02 4.560080841412490066e-02 4.034337164788070335e-02
110 3.807590643342410180e-02 5.068011873981870252e-02 -9.439390357450949676e-03 2.362754385640800005e-03 1.182945896190920002e-03 3.751653183568340322e-02 -5.444575906428809897e-02 5.017634085436720182e-02 -2.595242443518940012e-02 1.066170822852360034e-01
111 4.170844488444359899e-02 5.068011873981870252e-02 -3.207344390894990155e-02 -2.288496402361559975e-02 -4.972730985725089953e-02 -4.014428668812060341e-02 3.023191042971450082e-02 -3.949338287409189657e-02 -1.260973855604090033e-01 1.549073015887240078e-02
112 1.991321417832630017e-02 -4.464163650698899782e-02 4.572166603000769880e-03 -2.632783471735180084e-02 2.319819162740899970e-02 1.027261565999409987e-02 6.704828847058519337e-02 -3.949338287409189657e-02 -2.364455757213410059e-02 -4.664087356364819692e-02
113 -8.543040090124079389e-02 -4.464163650698899782e-02 2.073934771121430098e-02 -2.632783471735180084e-02 5.310804470794310353e-03 1.966706951368000014e-02 -2.902829807069099918e-03 -2.592261998182820038e-03 -2.364455757213410059e-02 3.064409414368320182e-03
114 1.991321417832630017e-02 5.068011873981870252e-02 1.427247526792889930e-02 6.318680331979099896e-02 1.494247447820220079e-02 2.029336643725910064e-02 -4.708248345611389801e-02 3.430885887772629900e-02 4.666077235681449775e-02 9.004865462589720093e-02
115 2.354575262934580082e-02 -4.464163650698899782e-02 1.101977498433290015e-01 6.318680331979099896e-02 1.356652162000110060e-02 -3.294187206696139875e-02 -2.499265663159149983e-02 2.065544415363990138e-02 9.924022573398999514e-02 2.377494398854190089e-02
116 -3.094232413594750000e-02 5.068011873981870252e-02 1.338730381358059929e-03 -5.670610554934250001e-03 6.447677737344290061e-02 4.941617338368559792e-02 -4.708248345611389801e-02 1.081111006295440019e-01 8.379676636552239877e-02 3.064409414368320182e-03
117 4.897352178648269744e-02 5.068011873981870252e-02 5.846277029704580186e-02 7.007254470726349826e-02 1.356652162000110060e-02 2.060651489904859884e-02 -2.131101882750449997e-02 3.430885887772629900e-02 2.200405045615050001e-02 2.791705090337660150e-02
118 5.987113713954139715e-02 -4.464163650698899782e-02 -2.129532317014089932e-02 8.728689817594480205e-02 4.521343735862710239e-02 3.156671106168230240e-02 -4.708248345611389801e-02 7.120997975363539678e-02 7.912108138965789905e-02 1.356118306890790048e-01
119 -5.637009329308430294e-02 5.068011873981870252e-02 -1.051720243133190055e-02 2.531522568869210010e-02 2.319819162740899970e-02 4.002171952999959703e-02 -3.971920784793980114e-02 3.430885887772629900e-02 2.061233072136409855e-02 5.691179930721949887e-02
120 1.628067572730669890e-02 -4.464163650698899782e-02 -4.716281294328249912e-02 -2.227739861197989939e-03 -1.945634697682600139e-02 -4.296262284422640298e-02 3.391354823380159783e-02 -3.949338287409189657e-02 2.736770754260900093e-02 2.791705090337660150e-02
121 -4.910501639104519755e-02 -4.464163650698899782e-02 4.572166603000769880e-03 1.154374291374709975e-02 -3.734373413344069942e-02 -1.853704282464289921e-02 -1.762938102341739949e-02 -2.592261998182820038e-03 -3.980959436433750137e-02 -2.178823207463989955e-02
122 6.350367559056099842e-02 -4.464163650698899782e-02 1.750591148957160101e-02 2.187235499495579841e-02 8.062710187196569719e-03 2.154596028441720101e-02 -3.603757004385269719e-02 3.430885887772629900e-02 1.990842087631829876e-02 1.134862324403770016e-02
123 4.897352178648269744e-02 5.068011873981870252e-02 8.109682384854470516e-02 2.187235499495579841e-02 4.383748450042589812e-02 6.413415108779360607e-02 -5.444575906428809897e-02 7.120997975363539678e-02 3.243322577960189995e-02 4.862758547755009764e-02
124 5.383060374248070309e-03 5.068011873981870252e-02 3.475090467166599972e-02 -1.080116308095460057e-03 1.525377602983150060e-01 1.987879896572929961e-01 -6.180903467246220279e-02 1.852344432601940039e-01 1.556684454070180086e-02 7.348022696655839847e-02
125 -5.514554978810590376e-03 -4.464163650698899782e-02 2.397278393285700096e-02 8.100872220010799790e-03 -3.459182841703849903e-02 -3.889169284096249957e-02 2.286863482154040048e-02 -3.949338287409189657e-02 -1.599826775813870117e-02 -1.350401824497050006e-02
126 -5.514554978810590376e-03 5.068011873981870252e-02 -8.361578283570040432e-03 -2.227739861197989939e-03 -3.321587555883730170e-02 -6.363042132233559522e-02 -3.603757004385269719e-02 -2.592261998182820038e-03 8.058546423866649877e-02 7.206516329203029904e-03
127 -8.906293935226029801e-02 -4.464163650698899782e-02 -6.117436990373419786e-02 -2.632783471735180084e-02 -5.523112129005539744e-02 -5.454911593043910295e-02 4.127682384197570165e-02 -7.639450375000099436e-02 -9.393564550871469354e-02 -5.492508739331759815e-02
128 3.444336798240450054e-02 5.068011873981870252e-02 -1.894705840284650021e-03 -1.255635194240680048e-02 3.833367306762140020e-02 1.371724873967889932e-02 7.809320188284639419e-02 -3.949338287409189657e-02 4.551890466127779880e-03 -9.634615654166470144e-02
129 -5.273755484206479882e-02 -4.464163650698899782e-02 -6.225218197761509670e-02 -2.632783471735180084e-02 -5.696818394814720174e-03 -5.071658967693000106e-03 3.023191042971450082e-02 -3.949338287409189657e-02 -3.075120986455629965e-02 -7.149351505265640061e-02
130 9.015598825267629943e-03 -4.464163650698899782e-02 1.642809941569069870e-02 4.658001526274530187e-03 9.438663045397699403e-03 1.058576412178359981e-02 -2.867429443567860031e-02 3.430885887772629900e-02 3.896836603088559697e-02 1.190434030297399942e-01
131 -6.363517019512339445e-02 5.068011873981870252e-02 9.618619288287730273e-02 1.045012516446259948e-01 -2.944912678412469915e-03 -4.758510505903469807e-03 -6.584467611156170040e-03 -2.592261998182820038e-03 2.269202256674450122e-02 7.348022696655839847e-02
132 -9.632801625429950054e-02 -4.464163650698899782e-02 -6.979686649478139548e-02 -6.764228304218700139e-02 -1.945634697682600139e-02 -1.070833127990459925e-02 1.550535921336619952e-02 -3.949338287409189657e-02 -4.687948284421659950e-02 -7.977772888232589898e-02
133 1.628067572730669890e-02 5.068011873981870252e-02 -2.129532317014089932e-02 -9.113481248670509197e-03 3.420581449301800248e-02 4.785043107473799934e-02 7.788079970179680352e-04 -2.592261998182820038e-03 -1.290794225416879923e-02 2.377494398854190089e-02
134 -4.183993948900609910e-02 5.068011873981870252e-02 -5.362968538656789907e-02 -4.009931749229690007e-02 -8.412613131227909824e-02 -7.177228132886340206e-02 -2.902829807069099918e-03 -3.949338287409189657e-02 -7.212845460195599356e-02 -3.007244590430930078e-02
135 -7.453278554818210111e-02 -4.464163650698899782e-02 4.337340126271319735e-02 -3.321357610482440076e-02 1.219056876180000040e-02 2.518648827290310109e-04 6.336665066649820044e-02 -3.949338287409189657e-02 -2.712864555432650121e-02 -4.664087356364819692e-02
136 -5.514554978810590376e-03 -4.464163650698899782e-02 5.630714614928399725e-02 -3.665644679856060184e-02 -4.835135699904979933e-02 -4.296262284422640298e-02 -7.285394808472339667e-02 3.799897096531720114e-02 5.078151336297320045e-02 5.691179930721949887e-02
137 -9.269547780327989928e-02 -4.464163650698899782e-02 -8.165279930747129655e-02 -5.731367096097819691e-02 -6.073493272285990230e-02 -6.801449978738899338e-02 4.864009945014990260e-02 -7.639450375000099436e-02 -6.648814822283539983e-02 -2.178823207463989955e-02
138 5.383060374248070309e-03 -4.464163650698899782e-02 4.984027370599859730e-02 9.761551025715360652e-02 -1.532848840222260020e-02 -1.634500359211620013e-02 -6.584467611156170040e-03 -2.592261998182820038e-03 1.703713241477999851e-02 -1.350401824497050006e-02
139 3.444336798240450054e-02 5.068011873981870252e-02 1.112755619172099975e-01 7.695828609473599757e-02 -3.183992270063620150e-02 -3.388131745233000092e-02 -2.131101882750449997e-02 -2.592261998182820038e-03 2.801650652326400162e-02 7.348022696655839847e-02
140 2.354575262934580082e-02 -4.464163650698899782e-02 6.169620651868849837e-02 5.285819123858220142e-02 -3.459182841703849903e-02 -4.891244361822749687e-02 -2.867429443567860031e-02 -2.592261998182820038e-03 5.472400334817909689e-02 -5.219804415301099697e-03
141 4.170844488444359899e-02 5.068011873981870252e-02 1.427247526792889930e-02 4.252957915737339695e-02 -3.046396984243510131e-02 -1.313877426218630021e-03 -4.340084565202689815e-02 -2.592261998182820038e-03 -3.324878724762579674e-02 1.549073015887240078e-02
142 -2.730978568492789874e-02 -4.464163650698899782e-02 4.768464955823679963e-02 -4.698505887976939938e-02 3.420581449301800248e-02 5.724488492842390308e-02 -8.021722369289760457e-02 1.302517731550900115e-01 4.506616833626150148e-02 1.314697237742440128e-01
143 4.170844488444359899e-02 5.068011873981870252e-02 1.211685112016709989e-02 3.908670846363720280e-02 5.484510736603499803e-02 4.440579799505309927e-02 4.460445801105040325e-03 -2.592261998182820038e-03 4.560080841412490066e-02 -1.077697500466389974e-03
144 -3.094232413594750000e-02 -4.464163650698899782e-02 5.649978676881649634e-03 -9.113481248670509197e-03 1.907033305280559851e-02 6.827982580309210209e-03 7.441156407875940126e-02 -3.949338287409189657e-02 -4.118038518800790082e-02 -4.249876664881350324e-02
145 3.081082953138499989e-02 5.068011873981870252e-02 4.660683748435590079e-02 -1.599922263614299983e-02 2.044628591100669870e-02 5.066876723084379891e-02 -5.812739686837520292e-02 7.120997975363539678e-02 6.209315616505399656e-03 7.206516329203029904e-03
146 -4.183993948900609910e-02 -4.464163650698899782e-02 1.285205550993039902e-01 6.318680331979099896e-02 -3.321587555883730170e-02 -3.262872360517189707e-02 1.182372140927919965e-02 -3.949338287409189657e-02 -1.599826775813870117e-02 -5.078298047848289754e-02
147 -3.094232413594750000e-02 5.068011873981870252e-02 5.954058237092670069e-02 1.215130832538269907e-03 1.219056876180000040e-02 3.156671106168230240e-02 -4.340084565202689815e-02 3.430885887772629900e-02 1.482271084126630077e-02 7.206516329203029904e-03
148 -5.637009329308430294e-02 -4.464163650698899782e-02 9.295275666123460623e-02 -1.944209332987930153e-02 1.494247447820220079e-02 2.342485105515439842e-02 -2.867429443567860031e-02 2.545258986750810123e-02 2.605608963368469949e-02 4.034337164788070335e-02
149 -6.000263174410389727e-02 5.068011873981870252e-02 1.535028734180979987e-02 -1.944209332987930153e-02 3.695772020942030001e-02 4.816357953652750101e-02 1.918699701745330000e-02 -2.592261998182820038e-03 -3.075120986455629965e-02 -1.077697500466389974e-03
150 -4.910501639104519755e-02 5.068011873981870252e-02 -5.128142061927360405e-03 -4.698505887976939938e-02 -2.083229983502719873e-02 -2.041593359538010008e-02 -6.917231028063640375e-02 7.120997975363539678e-02 6.123790751970099866e-02 -3.835665973397880263e-02
151 2.354575262934580082e-02 -4.464163650698899782e-02 7.031870310973570293e-02 2.531522568869210010e-02 -3.459182841703849903e-02 -1.446611282137899926e-02 -3.235593223976569732e-02 -2.592261998182820038e-03 -1.919704761394450121e-02 -9.361911330135799444e-03
152 1.750521923228520000e-03 -4.464163650698899782e-02 -4.050329988046450294e-03 -5.670610554934250001e-03 -8.448724111216979540e-03 -2.386056667506489953e-02 5.232173725423699961e-02 -3.949338287409189657e-02 -8.944018957797799166e-03 -1.350401824497050006e-02
153 -3.457486258696700065e-02 5.068011873981870252e-02 -8.168937664037369826e-04 7.007254470726349826e-02 3.970962592582259754e-02 6.695248724389940564e-02 -6.549067247654929980e-02 1.081111006295440019e-01 2.671425763351279944e-02 7.348022696655839847e-02
154 4.170844488444359899e-02 5.068011873981870252e-02 -4.392937672163980262e-02 6.318680331979099896e-02 -4.320865536613589623e-03 1.622243643399520069e-02 -1.394774321933030074e-02 -2.592261998182820038e-03 -3.452371533034950118e-02 1.134862324403770016e-02
155 6.713621404158050254e-02 5.068011873981870252e-02 2.073934771121430098e-02 -5.670610554934250001e-03 2.044628591100669870e-02 2.624318721126020146e-02 -2.902829807069099918e-03 -2.592261998182820038e-03 8.640282933063080789e-03 3.064409414368320182e-03
156 -2.730978568492789874e-02 5.068011873981870252e-02 6.061839444480759953e-02 4.941532054484590319e-02 8.511607024645979902e-02 8.636769187485039689e-02 -2.902829807069099918e-03 3.430885887772629900e-02 3.781447882634390162e-02 4.862758547755009764e-02
157 -1.641217033186929963e-02 -4.464163650698899782e-02 -1.051720243133190055e-02 1.215130832538269907e-03 -3.734373413344069942e-02 -3.576020822306719832e-02 1.182372140927919965e-02 -3.949338287409189657e-02 -2.139368094035999993e-02 -3.421455281914410201e-02
158 -1.882016527791040067e-03 5.068011873981870252e-02 -3.315125598283080038e-02 -1.829446977677679984e-02 3.145390877661580209e-02 4.284005568610550069e-02 -1.394774321933030074e-02 1.991742173612169944e-02 1.022564240495780000e-02 2.791705090337660150e-02
159 -1.277963188084970010e-02 -4.464163650698899782e-02 -6.548561819925780014e-02 -6.993753018282070077e-02 1.182945896190920002e-03 1.684873335757430118e-02 -2.902829807069099918e-03 -7.020396503291909812e-03 -3.075120986455629965e-02 -5.078298047848289754e-02
160 -5.514554978810590376e-03 -4.464163650698899782e-02 4.337340126271319735e-02 8.728689817594480205e-02 1.356652162000110060e-02 7.141131042098750048e-03 -1.394774321933030074e-02 -2.592261998182820038e-03 4.234489544960749752e-02 -1.764612515980519894e-02
161 -9.147093429830140468e-03 -4.464163650698899782e-02 -6.225218197761509670e-02 -7.452802442965950069e-02 -2.358420555142939912e-02 -1.321351897422090062e-02 4.460445801105040325e-03 -3.949338287409189657e-02 -3.581672810154919867e-02 -4.664087356364819692e-02
162 -4.547247794002570037e-02 5.068011873981870252e-02 6.385183066645029604e-02 7.007254470726349826e-02 1.332744202834990066e-01 1.314610703725430096e-01 -3.971920784793980114e-02 1.081111006295440019e-01 7.573758845754760549e-02 8.590654771106250032e-02
163 -5.273755484206479882e-02 -4.464163650698899782e-02 3.043965637614240091e-02 -7.452802442965950069e-02 -2.358420555142939912e-02 -1.133462820348369975e-02 -2.902829807069099918e-03 -2.592261998182820038e-03 -3.075120986455629965e-02 -1.077697500466389974e-03
164 1.628067572730669890e-02 5.068011873981870252e-02 7.247432725749750060e-02 7.695828609473599757e-02 -8.448724111216979540e-03 5.575388733151089883e-03 -6.584467611156170040e-03 -2.592261998182820038e-03 -2.364455757213410059e-02 6.105390622205419948e-02
165 4.534098333546320025e-02 -4.464163650698899782e-02 -1.913969902237900103e-02 2.187235499495579841e-02 2.732605020201240090e-02 -1.352666743601040056e-02 1.001830287073690040e-01 -3.949338287409189657e-02 1.776347786711730131e-02 -1.350401824497050006e-02
166 -4.183993948900609910e-02 -4.464163650698899782e-02 -6.656343027313869898e-02 -4.698505887976939938e-02 -3.734373413344069942e-02 -4.327577130601600180e-02 4.864009945014990260e-02 -3.949338287409189657e-02 -5.615757309500619965e-02 -1.350401824497050006e-02
167 -5.637009329308430294e-02 5.068011873981870252e-02 -6.009655782985329903e-02 -3.665644679856060184e-02 -8.825398988688250290e-02 -7.083283594349480683e-02 -1.394774321933030074e-02 -3.949338287409189657e-02 -7.814091066906959926e-02 -1.046303703713340055e-01
168 7.076875249260000666e-02 -4.464163650698899782e-02 6.924089103585480409e-02 3.793908501382069892e-02 2.182223876920789951e-02 1.504458729887179960e-03 -3.603757004385269719e-02 3.910600459159439823e-02 7.763278919555950675e-02 1.066170822852360034e-01
169 1.750521923228520000e-03 5.068011873981870252e-02 5.954058237092670069e-02 -2.227739861197989939e-03 6.172487165704060308e-02 6.319470570242499696e-02 -5.812739686837520292e-02 1.081111006295440019e-01 6.898221163630259556e-02 1.273276168594099922e-01
170 -1.882016527791040067e-03 -4.464163650698899782e-02 -2.668438353954540043e-02 4.941532054484590319e-02 5.897296594063840269e-02 -1.603185513032660131e-02 -4.708248345611389801e-02 7.120997975363539678e-02 1.335989800130079896e-01 1.963283707370720027e-02
171 2.354575262934580082e-02 5.068011873981870252e-02 -2.021751109626000048e-02 -3.665644679856060184e-02 -1.395253554402150001e-02 -1.509240974495799914e-02 5.968501286241110343e-02 -3.949338287409189657e-02 -9.643322289178400675e-02 -1.764612515980519894e-02
172 -2.004470878288880029e-02 -4.464163650698899782e-02 -4.608500086940160029e-02 -9.862811928581330378e-02 -7.587041416307230279e-02 -5.987263978086120042e-02 -1.762938102341739949e-02 -3.949338287409189657e-02 -5.140053526058249722e-02 -4.664087356364819692e-02
173 4.170844488444359899e-02 5.068011873981870252e-02 7.139651518361660176e-02 8.100872220010799790e-03 3.833367306762140020e-02 1.590928797220559840e-02 -1.762938102341739949e-02 3.430885887772629900e-02 7.341007804911610368e-02 8.590654771106250032e-02
174 -6.363517019512339445e-02 5.068011873981870252e-02 -7.949717515970949888e-02 -5.670610554934250001e-03 -7.174255558846899528e-02 -6.644875747844139480e-02 -1.026610541524320026e-02 -3.949338287409189657e-02 -1.811826730789670159e-02 -5.492508739331759815e-02
175 1.628067572730669890e-02 5.068011873981870252e-02 9.961226972405269262e-03 -4.354218818603310115e-02 -9.650970703608929835e-02 -9.463211903949929338e-02 -3.971920784793980114e-02 -3.949338287409189657e-02 1.703713241477999851e-02 7.206516329203029904e-03
176 6.713621404158050254e-02 -4.464163650698899782e-02 -3.854031635223530150e-02 -2.632783471735180084e-02 -3.183992270063620150e-02 -2.636575436938120090e-02 8.142083605192099172e-03 -3.949338287409189657e-02 -2.712864555432650121e-02 3.064409414368320182e-03
177 4.534098333546320025e-02 5.068011873981870252e-02 1.966153563733339868e-02 3.908670846363720280e-02 2.044628591100669870e-02 2.593003874947069978e-02 8.142083605192099172e-03 -2.592261998182820038e-03 -3.303712578676999863e-03 1.963283707370720027e-02
178 4.897352178648269744e-02 -4.464163650698899782e-02 2.720622015449970094e-02 -2.518021116424929914e-02 2.319819162740899970e-02 1.841447566652189977e-02 -6.180903467246220279e-02 8.006624876385350087e-02 7.222365081991240221e-02 3.205915781821130212e-02
179 4.170844488444359899e-02 -4.464163650698899782e-02 -8.361578283570040432e-03 -2.632783471735180084e-02 2.457414448561009990e-02 1.622243643399520069e-02 7.072992627467229731e-02 -3.949338287409189657e-02 -4.836172480289190057e-02 -3.007244590430930078e-02
180 -2.367724723390840155e-02 -4.464163650698899782e-02 -1.590626280073640167e-02 -1.255635194240680048e-02 2.044628591100669870e-02 4.127431337715779802e-02 -4.340084565202689815e-02 3.430885887772629900e-02 1.407245251576850001e-02 -9.361911330135799444e-03
181 -3.820740103798660192e-02 5.068011873981870252e-02 4.572166603000769880e-03 3.564383776990089764e-02 -1.120062982761920074e-02 5.888537194940629722e-03 -4.708248345611389801e-02 3.430885887772629900e-02 1.630495279994180133e-02 -1.077697500466389974e-03
182 4.897352178648269744e-02 -4.464163650698899782e-02 -4.285156464775889684e-02 -5.387080026724189868e-02 4.521343735862710239e-02 5.004247030726469841e-02 3.391354823380159783e-02 -2.592261998182820038e-03 -2.595242443518940012e-02 -6.320930122298699938e-02
183 4.534098333546320025e-02 5.068011873981870252e-02 5.649978676881649634e-03 5.630106193231849965e-02 6.447677737344290061e-02 8.918602803095619647e-02 -3.971920784793980114e-02 7.120997975363539678e-02 1.556684454070180086e-02 -9.361911330135799444e-03
184 4.534098333546320025e-02 5.068011873981870252e-02 -3.530688013059259805e-02 6.318680331979099896e-02 -4.320865536613589623e-03 -1.627025888008149911e-03 -1.026610541524320026e-02 -2.592261998182820038e-03 1.556684454070180086e-02 5.691179930721949887e-02
185 1.628067572730669890e-02 -4.464163650698899782e-02 2.397278393285700096e-02 -2.288496402361559975e-02 -2.496015840963049931e-02 -2.605260590759169922e-02 -3.235593223976569732e-02 -2.592261998182820038e-03 3.723201120896890010e-02 3.205915781821130212e-02
186 -7.453278554818210111e-02 5.068011873981870252e-02 -1.806188694849819934e-02 8.100872220010799790e-03 -1.945634697682600139e-02 -2.480001206043359885e-02 -6.549067247654929980e-02 3.430885887772629900e-02 6.731721791468489591e-02 -1.764612515980519894e-02
187 -8.179786245022120650e-02 5.068011873981870252e-02 4.229558918883229851e-02 -1.944209332987930153e-02 3.970962592582259754e-02 5.755803339021339782e-02 -6.917231028063640375e-02 1.081111006295440019e-01 4.718616788601970313e-02 -3.835665973397880263e-02
188 -6.726770864614299572e-02 -4.464163650698899782e-02 -5.470749746044879791e-02 -2.632783471735180084e-02 -7.587041416307230279e-02 -8.210618056791800512e-02 4.864009945014990260e-02 -7.639450375000099436e-02 -8.682899321629239386e-02 -1.046303703713340055e-01
189 5.383060374248070309e-03 -4.464163650698899782e-02 -2.972517914165530208e-03 4.941532054484590319e-02 7.410844738085080319e-02 7.071026878537380045e-02 4.495846164606279866e-02 -2.592261998182820038e-03 -1.498586820292070049e-03 -9.361911330135799444e-03
190 -1.882016527791040067e-03 -4.464163650698899782e-02 -6.656343027313869898e-02 1.215130832538269907e-03 -2.944912678412469915e-03 3.070201038834840124e-03 1.182372140927919965e-02 -2.592261998182820038e-03 -2.028874775162960165e-02 -2.593033898947460017e-02
191 9.015598825267629943e-03 -4.464163650698899782e-02 -1.267282657909369996e-02 2.875809638242839833e-02 -1.808039411862490120e-02 -5.071658967693000106e-03 -4.708248345611389801e-02 3.430885887772629900e-02 2.337484127982079885e-02 -5.219804415301099697e-03
192 -5.514554978810590376e-03 5.068011873981870252e-02 -4.177375257387799801e-02 -4.354218818603310115e-02 -7.999827273767569358e-02 -7.615635979391689736e-02 -3.235593223976569732e-02 -3.949338287409189657e-02 1.022564240495780000e-02 -9.361911330135799444e-03
193 5.623859868852180283e-02 5.068011873981870252e-02 -3.099563183506899924e-02 8.100872220010799790e-03 1.907033305280559851e-02 2.123281182262769934e-02 3.391354823380159783e-02 -3.949338287409189657e-02 -2.952762274177360077e-02 -5.906719430815229877e-02
194 9.015598825267629943e-03 5.068011873981870252e-02 -5.128142061927360405e-03 -6.419941234845069622e-02 6.998058880624739853e-02 8.386250418053420308e-02 -3.971920784793980114e-02 7.120997975363539678e-02 3.953987807202419963e-02 1.963283707370720027e-02
195 -6.726770864614299572e-02 -4.464163650698899782e-02 -5.901874575597240019e-02 3.220096707616459941e-02 -5.110326271545199972e-02 -4.953874054180659736e-02 -1.026610541524320026e-02 -3.949338287409189657e-02 2.007840549823790115e-03 2.377494398854190089e-02
196 2.717829108036539862e-02 5.068011873981870252e-02 2.505059600673789980e-02 1.498661360748330083e-02 2.595009734381130070e-02 4.847672799831700269e-02 -3.971920784793980114e-02 3.430885887772629900e-02 7.837142301823850701e-03 2.377494398854190089e-02
197 -2.367724723390840155e-02 -4.464163650698899782e-02 -4.608500086940160029e-02 -3.321357610482440076e-02 3.282986163481690228e-02 3.626393798852529937e-02 3.759518603788870178e-02 -2.592261998182820038e-03 -3.324878724762579674e-02 1.134862324403770016e-02
198 4.897352178648269744e-02 5.068011873981870252e-02 3.494354529119849794e-03 7.007254470726349826e-02 -8.448724111216979540e-03 1.340410027788939938e-02 -5.444575906428809897e-02 3.430885887772629900e-02 1.331596790892770020e-02 3.620126473304600273e-02
199 -5.273755484206479882e-02 -4.464163650698899782e-02 5.415152200152219958e-02 -2.632783471735180084e-02 -5.523112129005539744e-02 -3.388131745233000092e-02 -1.394774321933030074e-02 -3.949338287409189657e-02 -7.408887149153539631e-02 -5.906719430815229877e-02
200 4.170844488444359899e-02 -4.464163650698899782e-02 -4.500718879552070145e-02 3.449621432008449784e-02 4.383748450042589812e-02 -1.571870666853709964e-02 3.759518603788870178e-02 -1.440062067847370023e-02 8.989869327767099905e-02 7.206516329203029904e-03
201 5.623859868852180283e-02 -4.464163650698899782e-02 -5.794093368209150136e-02 -7.965857695567990157e-03 5.209320164963270050e-02 4.910302492189610318e-02 5.600337505832399948e-02 -2.141183364489639834e-02 -2.832024254799870092e-02 4.448547856271539702e-02
202 -3.457486258696700065e-02 5.068011873981870252e-02 -5.578530953432969675e-02 -1.599922263614299983e-02 -9.824676969418109224e-03 -7.889995123798789270e-03 3.759518603788870178e-02 -3.949338287409189657e-02 -5.295879323920039961e-02 2.791705090337660150e-02
203 8.166636784565869944e-02 5.068011873981870252e-02 1.338730381358059929e-03 3.564383776990089764e-02 1.263946559924939983e-01 9.106491880169340081e-02 1.918699701745330000e-02 3.430885887772629900e-02 8.449528221240310000e-02 -3.007244590430930078e-02
204 -1.882016527791040067e-03 5.068011873981870252e-02 3.043965637614240091e-02 5.285819123858220142e-02 3.970962592582259754e-02 5.661858800484489973e-02 -3.971920784793980114e-02 7.120997975363539678e-02 2.539313491544940155e-02 2.791705090337660150e-02
205 1.107266754538149961e-01 5.068011873981870252e-02 6.727790750762559745e-03 2.875809638242839833e-02 -2.771206412603280031e-02 -7.263698200219739949e-03 -4.708248345611389801e-02 3.430885887772629900e-02 2.007840549823790115e-03 7.762233388139309909e-02
206 -3.094232413594750000e-02 -4.464163650698899782e-02 4.660683748435590079e-02 1.498661360748330083e-02 -1.670444126042380101e-02 -4.703355284749029946e-02 7.788079970179680352e-04 -2.592261998182820038e-03 6.345592137206540473e-02 -2.593033898947460017e-02
207 1.750521923228520000e-03 5.068011873981870252e-02 2.612840808061879863e-02 -9.113481248670509197e-03 2.457414448561009990e-02 3.845597722105199845e-02 -2.131101882750449997e-02 3.430885887772629900e-02 9.436409146079870192e-03 3.064409414368320182e-03
208 9.015598825267629943e-03 -4.464163650698899782e-02 4.552902541047500196e-02 2.875809638242839833e-02 1.219056876180000040e-02 -1.383981589779990050e-02 2.655027262562750096e-02 -3.949338287409189657e-02 4.613233103941480340e-02 3.620126473304600273e-02
209 3.081082953138499989e-02 -4.464163650698899782e-02 4.013996504107050084e-02 7.695828609473599757e-02 1.769438019460449832e-02 3.782968029747289795e-02 -2.867429443567860031e-02 3.430885887772629900e-02 -1.498586820292070049e-03 1.190434030297399942e-01
210 3.807590643342410180e-02 5.068011873981870252e-02 -1.806188694849819934e-02 6.662967401352719310e-02 -5.110326271545199972e-02 -1.665815205390569834e-02 -7.653558588881050062e-02 3.430885887772629900e-02 -1.190068480150809939e-02 -1.350401824497050006e-02
211 9.015598825267629943e-03 -4.464163650698899782e-02 1.427247526792889930e-02 1.498661360748330083e-02 5.484510736603499803e-02 4.722413415115889884e-02 7.072992627467229731e-02 -3.949338287409189657e-02 -3.324878724762579674e-02 -5.906719430815229877e-02
212 9.256398319871740610e-02 -4.464163650698899782e-02 3.690652881942779739e-02 2.187235499495579841e-02 -2.496015840963049931e-02 -1.665815205390569834e-02 7.788079970179680352e-04 -3.949338287409189657e-02 -2.251217192966049885e-02 -2.178823207463989955e-02
213 6.713621404158050254e-02 -4.464163650698899782e-02 3.494354529119849794e-03 3.564383776990089764e-02 4.934129593323050011e-02 3.125356259989280072e-02 7.072992627467229731e-02 -3.949338287409189657e-02 -6.092541861022970299e-04 1.963283707370720027e-02
214 1.750521923228520000e-03 -4.464163650698899782e-02 -7.087467856866229432e-02 -2.288496402361559975e-02 -1.568959820211340015e-03 -1.000728964429089965e-03 2.655027262562750096e-02 -3.949338287409189657e-02 -2.251217192966049885e-02 7.206516329203029904e-03
215 3.081082953138499989e-02 -4.464163650698899782e-02 -3.315125598283080038e-02 -2.288496402361559975e-02 -4.697540414084860200e-02 -8.116673518254939601e-02 1.038646665114559969e-01 -7.639450375000099436e-02 -3.980959436433750137e-02 -5.492508739331759815e-02
216 2.717829108036539862e-02 5.068011873981870252e-02 9.403056873511560221e-02 9.761551025715360652e-02 -3.459182841703849903e-02 -3.200242668159279658e-02 -4.340084565202689815e-02 -2.592261998182820038e-03 3.664579779339879884e-02 1.066170822852360034e-01
217 1.264813727628719998e-02 5.068011873981870252e-02 3.582871674554689856e-02 4.941532054484590319e-02 5.346915450783389784e-02 7.415490186505870052e-02 -6.917231028063640375e-02 1.450122215054540087e-01 4.560080841412490066e-02 4.862758547755009764e-02
218 7.440129094361959405e-02 -4.464163650698899782e-02 3.151746845002330322e-02 1.010583809508899950e-01 4.658939021682820258e-02 3.689023491210430272e-02 1.550535921336619952e-02 -2.592261998182820038e-03 3.365681290238470291e-02 4.448547856271539702e-02
219 -4.183993948900609910e-02 -4.464163650698899782e-02 -6.548561819925780014e-02 -4.009931749229690007e-02 -5.696818394814720174e-03 1.434354566325799982e-02 -4.340084565202689815e-02 3.430885887772629900e-02 7.026862549151949647e-03 -1.350401824497050006e-02
220 -8.906293935226029801e-02 -4.464163650698899782e-02 -4.177375257387799801e-02 -1.944209332987930153e-02 -6.623874415566440021e-02 -7.427746902317970690e-02 8.142083605192099172e-03 -3.949338287409189657e-02 1.143797379512540100e-03 -3.007244590430930078e-02
221 2.354575262934580082e-02 5.068011873981870252e-02 -3.961812842611620034e-02 -5.670610554934250001e-03 -4.835135699904979933e-02 -3.325502052875090042e-02 1.182372140927919965e-02 -3.949338287409189657e-02 -1.016435479455120028e-01 -6.735140813782170000e-02
222 -4.547247794002570037e-02 -4.464163650698899782e-02 -3.854031635223530150e-02 -2.632783471735180084e-02 -1.532848840222260020e-02 8.781618063081050515e-04 -3.235593223976569732e-02 -2.592261998182820038e-03 1.143797379512540100e-03 -3.835665973397880263e-02
223 -2.367724723390840155e-02 5.068011873981870252e-02 -2.560657146566450160e-02 4.252957915737339695e-02 -5.385516843185429725e-02 -4.765984977106939996e-02 -2.131101882750449997e-02 -3.949338287409189657e-02 1.143797379512540100e-03 1.963283707370720027e-02
224 -9.996055470531900466e-02 -4.464163650698899782e-02 -2.345094731790270046e-02 -6.419941234845069622e-02 -5.798302700645770191e-02 -6.018578824265070210e-02 1.182372140927919965e-02 -3.949338287409189657e-02 -1.811826730789670159e-02 -5.078298047848289754e-02
225 -2.730978568492789874e-02 -4.464163650698899782e-02 -6.656343027313869898e-02 -1.123996020607579971e-01 -4.972730985725089953e-02 -4.139688053527879746e-02 7.788079970179680352e-04 -3.949338287409189657e-02 -3.581672810154919867e-02 -9.361911330135799444e-03
226 3.081082953138499989e-02 5.068011873981870252e-02 3.259528052390420205e-02 4.941532054484590319e-02 -4.009563984984299695e-02 -4.358891976780549654e-02 -6.917231028063640375e-02 3.430885887772629900e-02 6.301661511474640487e-02 3.064409414368320182e-03
227 -1.035930931563389945e-01 5.068011873981870252e-02 -4.608500086940160029e-02 -2.632783471735180084e-02 -2.496015840963049931e-02 -2.480001206043359885e-02 3.023191042971450082e-02 -3.949338287409189657e-02 -3.980959436433750137e-02 -5.492508739331759815e-02
228 6.713621404158050254e-02 5.068011873981870252e-02 -2.991781976118810041e-02 5.744868538213489945e-02 -1.930069620102049918e-04 -1.571870666853709964e-02 7.441156407875940126e-02 -5.056371913686460301e-02 -3.845911230135379971e-02 7.206516329203029904e-03
229 -5.273755484206479882e-02 -4.464163650698899782e-02 -1.267282657909369996e-02 -6.075654165471439799e-02 -1.930069620102049918e-04 8.080576427467340075e-03 1.182372140927919965e-02 -2.592261998182820038e-03 -2.712864555432650121e-02 -5.078298047848289754e-02
230 -2.730978568492789874e-02 5.068011873981870252e-02 -1.590626280073640167e-02 -2.977070541108809906e-02 3.934851612593179802e-03 -6.875805026395569565e-04 4.127682384197570165e-02 -3.949338287409189657e-02 -2.364455757213410059e-02 1.134862324403770016e-02
231 -3.820740103798660192e-02 5.068011873981870252e-02 7.139651518361660176e-02 -5.731367096097819691e-02 1.539137131565160022e-01 1.558866503921270130e-01 7.788079970179680352e-04 7.194800217115350505e-02 5.027649338998960160e-02 6.933812005172369786e-02
232 9.015598825267629943e-03 -4.464163650698899782e-02 -3.099563183506899924e-02 2.187235499495579841e-02 8.062710187196569719e-03 8.706873351046409346e-03 4.460445801105040325e-03 -2.592261998182820038e-03 9.436409146079870192e-03 1.134862324403770016e-02
233 1.264813727628719998e-02 5.068011873981870252e-02 2.609183074771409820e-04 -1.140872838930430053e-02 3.970962592582259754e-02 5.724488492842390308e-02 -3.971920784793980114e-02 5.608052019451260223e-02 2.405258322689299982e-02 3.205915781821130212e-02
234 6.713621404158050254e-02 -4.464163650698899782e-02 3.690652881942779739e-02 -5.042792957350569760e-02 -2.358420555142939912e-02 -3.450761437590899733e-02 4.864009945014990260e-02 -3.949338287409189657e-02 -2.595242443518940012e-02 -3.835665973397880263e-02
235 4.534098333546320025e-02 -4.464163650698899782e-02 3.906215296718960200e-02 4.597244985110970211e-02 6.686757328995440036e-03 -2.417371513685449835e-02 8.142083605192099172e-03 -1.255556463467829946e-02 6.432823302367089713e-02 5.691179930721949887e-02
236 6.713621404158050254e-02 5.068011873981870252e-02 -1.482845072685549936e-02 5.859630917623830093e-02 -5.935897986465880211e-02 -3.450761437590899733e-02 -6.180903467246220279e-02 1.290620876969899959e-02 -5.145307980263110273e-03 4.862758547755009764e-02
237 2.717829108036539862e-02 -4.464163650698899782e-02 6.727790750762559745e-03 3.564383776990089764e-02 7.961225881365530110e-02 7.071026878537380045e-02 1.550535921336619952e-02 3.430885887772629900e-02 4.067226371449769728e-02 1.134862324403770016e-02
238 5.623859868852180283e-02 -4.464163650698899782e-02 -6.871905442090049665e-02 -6.878990659528949614e-02 -1.930069620102049918e-04 -1.000728964429089965e-03 4.495846164606279866e-02 -3.764832683029650101e-02 -4.836172480289190057e-02 -1.077697500466389974e-03
239 3.444336798240450054e-02 5.068011873981870252e-02 -9.439390357450949676e-03 5.974393262605470073e-02 -3.596778127523959923e-02 -7.576846662009279788e-03 -7.653558588881050062e-02 7.120997975363539678e-02 1.100810104587249955e-02 -2.178823207463989955e-02
240 2.354575262934580082e-02 -4.464163650698899782e-02 1.966153563733339868e-02 -1.255635194240680048e-02 8.374011738825870577e-02 3.876912568284150012e-02 6.336665066649820044e-02 -2.592261998182820038e-03 6.604820616309839409e-02 4.862758547755009764e-02
241 4.897352178648269744e-02 5.068011873981870252e-02 7.462995140525929827e-02 6.662967401352719310e-02 -9.824676969418109224e-03 -2.253322811587220049e-03 -4.340084565202689815e-02 3.430885887772629900e-02 3.365681290238470291e-02 1.963283707370720027e-02
242 3.081082953138499989e-02 5.068011873981870252e-02 -8.361578283570040432e-03 4.658001526274530187e-03 1.494247447820220079e-02 2.749578105841839898e-02 8.142083605192099172e-03 -8.127430129569179762e-03 -2.952762274177360077e-02 5.691179930721949887e-02
243 -1.035930931563389945e-01 5.068011873981870252e-02 -2.345094731790270046e-02 -2.288496402361559975e-02 -8.687803702868139577e-02 -6.770135132559949864e-02 -1.762938102341739949e-02 -3.949338287409189657e-02 -7.814091066906959926e-02 -7.149351505265640061e-02
244 1.628067572730669890e-02 5.068011873981870252e-02 -4.608500086940160029e-02 1.154374291374709975e-02 -3.321587555883730170e-02 -1.603185513032660131e-02 -1.026610541524320026e-02 -2.592261998182820038e-03 -4.398540256559110156e-02 -4.249876664881350324e-02
245 -6.000263174410389727e-02 5.068011873981870252e-02 5.415152200152219958e-02 -1.944209332987930153e-02 -4.972730985725089953e-02 -4.891244361822749687e-02 2.286863482154040048e-02 -3.949338287409189657e-02 -4.398540256559110156e-02 -5.219804415301099697e-03
246 -2.730978568492789874e-02 -4.464163650698899782e-02 -3.530688013059259805e-02 -2.977070541108809906e-02 -5.660707414825649764e-02 -5.862004593370299943e-02 3.023191042971450082e-02 -3.949338287409189657e-02 -4.986846773523059828e-02 -1.294830118603420011e-01
247 4.170844488444359899e-02 -4.464163650698899782e-02 -3.207344390894990155e-02 -6.190416520781699683e-02 7.961225881365530110e-02 5.098191569263330059e-02 5.600337505832399948e-02 -9.972486173364639508e-03 4.506616833626150148e-02 -5.906719430815229877e-02
248 -8.179786245022120650e-02 -4.464163650698899782e-02 -8.165279930747129655e-02 -4.009931749229690007e-02 2.558898754392050119e-03 -1.853704282464289921e-02 7.072992627467229731e-02 -3.949338287409189657e-02 -1.090443584737709956e-02 -9.220404962683000083e-02
249 -4.183993948900609910e-02 -4.464163650698899782e-02 4.768464955823679963e-02 5.974393262605470073e-02 1.277706088506949944e-01 1.280164372928579986e-01 -2.499265663159149983e-02 1.081111006295440019e-01 6.389312063683939835e-02 4.034337164788070335e-02
250 -1.277963188084970010e-02 -4.464163650698899782e-02 6.061839444480759953e-02 5.285819123858220142e-02 4.796534307502930278e-02 2.937467182915549924e-02 -1.762938102341739949e-02 3.430885887772629900e-02 7.021129819331020649e-02 7.206516329203029904e-03
251 6.713621404158050254e-02 -4.464163650698899782e-02 5.630714614928399725e-02 7.351541540099980343e-02 -1.395253554402150001e-02 -3.920484130275200124e-02 -3.235593223976569732e-02 -2.592261998182820038e-03 7.573758845754760549e-02 3.620126473304600273e-02
252 -5.273755484206479882e-02 5.068011873981870252e-02 9.834181703063900326e-02 8.728689817594480205e-02 6.034891879883950289e-02 4.878987646010649742e-02 -5.812739686837520292e-02 1.081111006295440019e-01 8.449528221240310000e-02 4.034337164788070335e-02
253 5.383060374248070309e-03 -4.464163650698899782e-02 5.954058237092670069e-02 -5.616604740787570216e-02 2.457414448561009990e-02 5.286080646337049799e-02 -4.340084565202689815e-02 5.091436327188540029e-02 -4.219859706946029777e-03 -3.007244590430930078e-02
254 8.166636784565869944e-02 -4.464163650698899782e-02 3.367309259778510089e-02 8.100872220010799790e-03 5.209320164963270050e-02 5.661858800484489973e-02 -1.762938102341739949e-02 3.430885887772629900e-02 3.486419309615960277e-02 6.933812005172369786e-02
255 3.081082953138499989e-02 5.068011873981870252e-02 5.630714614928399725e-02 7.695828609473599757e-02 4.934129593323050011e-02 -1.227407358885230018e-02 -3.603757004385269719e-02 7.120997975363539678e-02 1.200533820015380060e-01 9.004865462589720093e-02
256 1.750521923228520000e-03 -4.464163650698899782e-02 -6.548561819925780014e-02 -5.670610554934250001e-03 -7.072771253015849857e-03 -1.947648821001150138e-02 4.127682384197570165e-02 -3.949338287409189657e-02 -3.303712578676999863e-03 7.206516329203029904e-03
257 -4.910501639104519755e-02 -4.464163650698899782e-02 1.608549173157310108e-01 -4.698505887976939938e-02 -2.908801698423390050e-02 -1.978963667180099958e-02 -4.708248345611389801e-02 3.430885887772629900e-02 2.801650652326400162e-02 1.134862324403770016e-02
258 -2.730978568492789874e-02 5.068011873981870252e-02 -5.578530953432969675e-02 2.531522568869210010e-02 -7.072771253015849857e-03 -2.354741821327540133e-02 5.232173725423699961e-02 -3.949338287409189657e-02 -5.145307980263110273e-03 -5.078298047848289754e-02
259 7.803382939463919532e-02 5.068011873981870252e-02 -2.452875939178359929e-02 -4.239456463293059946e-02 6.686757328995440036e-03 5.286080646337049799e-02 -6.917231028063640375e-02 8.080427118137170628e-02 -3.712834601047360072e-02 5.691179930721949887e-02
260 1.264813727628719998e-02 -4.464163650698899782e-02 -3.638469220447349689e-02 4.252957915737339695e-02 -1.395253554402150001e-02 1.293437758520510003e-02 -2.683347553363510038e-02 5.156973385758089994e-03 -4.398540256559110156e-02 7.206516329203029904e-03
261 4.170844488444359899e-02 -4.464163650698899782e-02 -8.361578283570040432e-03 -5.731367096097819691e-02 8.062710187196569719e-03 -3.137612975801370302e-02 1.517259579645879874e-01 -7.639450375000099436e-02 -8.023654024890179703e-02 -1.764612515980519894e-02
262 4.897352178648269744e-02 -4.464163650698899782e-02 -4.177375257387799801e-02 1.045012516446259948e-01 3.558176735121919981e-02 -2.573945744580210040e-02 1.774974225931970073e-01 -7.639450375000099436e-02 -1.290794225416879923e-02 1.549073015887240078e-02
263 -1.641217033186929963e-02 5.068011873981870252e-02 1.274427430254229943e-01 9.761551025715360652e-02 1.631842733640340160e-02 1.747503028115330106e-02 -2.131101882750449997e-02 3.430885887772629900e-02 3.486419309615960277e-02 3.064409414368320182e-03
264 -7.453278554818210111e-02 5.068011873981870252e-02 -7.734155101194770121e-02 -4.698505887976939938e-02 -4.697540414084860200e-02 -3.262872360517189707e-02 4.460445801105040325e-03 -3.949338287409189657e-02 -7.212845460195599356e-02 -1.764612515980519894e-02
265 3.444336798240450054e-02 5.068011873981870252e-02 2.828403222838059977e-02 -3.321357610482440076e-02 -4.559945128264750180e-02 -9.768885894535990141e-03 -5.076412126020100196e-02 -2.592261998182820038e-03 -5.947269741072230137e-02 -2.178823207463989955e-02
266 -3.457486258696700065e-02 5.068011873981870252e-02 -2.560657146566450160e-02 -1.714684618924559867e-02 1.182945896190920002e-03 -2.879619735166290186e-03 8.142083605192099172e-03 -1.550765430475099967e-02 1.482271084126630077e-02 4.034337164788070335e-02
267 -5.273755484206479882e-02 5.068011873981870252e-02 -6.225218197761509670e-02 1.154374291374709975e-02 -8.448724111216979540e-03 -3.669965360843580049e-02 1.222728555318910032e-01 -7.639450375000099436e-02 -8.682899321629239386e-02 3.064409414368320182e-03
268 5.987113713954139715e-02 -4.464163650698899782e-02 -8.168937664037369826e-04 -8.485663651086830517e-02 7.548440023905199359e-02 7.947842571548069390e-02 4.460445801105040325e-03 3.430885887772629900e-02 2.337484127982079885e-02 2.791705090337660150e-02
269 6.350367559056099842e-02 5.068011873981870252e-02 8.864150836571099701e-02 7.007254470726349826e-02 2.044628591100669870e-02 3.751653183568340322e-02 -5.076412126020100196e-02 7.120997975363539678e-02 2.930041326858690010e-02 7.348022696655839847e-02
270 9.015598825267629943e-03 -4.464163650698899782e-02 -3.207344390894990155e-02 -2.632783471735180084e-02 4.246153164222479792e-02 -1.039518281811509931e-02 1.590892335727620011e-01 -7.639450375000099436e-02 -1.190068480150809939e-02 -3.835665973397880263e-02
271 5.383060374248070309e-03 5.068011873981870252e-02 3.043965637614240091e-02 8.384402748220859403e-02 -3.734373413344069942e-02 -4.734670130927989828e-02 1.550535921336619952e-02 -3.949338287409189657e-02 8.640282933063080789e-03 1.549073015887240078e-02
272 3.807590643342410180e-02 5.068011873981870252e-02 8.883414898524360018e-03 4.252957915737339695e-02 -4.284754556624519733e-02 -2.104223051895920057e-02 -3.971920784793980114e-02 -2.592261998182820038e-03 -1.811826730789670159e-02 7.206516329203029904e-03
273 1.264813727628719998e-02 -4.464163650698899782e-02 6.727790750762559745e-03 -5.616604740787570216e-02 -7.587041416307230279e-02 -6.644875747844139480e-02 -2.131101882750449997e-02 -3.764832683029650101e-02 -1.811826730789670159e-02 -9.220404962683000083e-02
274 7.440129094361959405e-02 5.068011873981870252e-02 -2.021751109626000048e-02 4.597244985110970211e-02 7.410844738085080319e-02 3.281930490884039930e-02 -3.603757004385269719e-02 7.120997975363539678e-02 1.063542767417259977e-01 3.620126473304600273e-02
275 1.628067572730669890e-02 -4.464163650698899782e-02 -2.452875939178359929e-02 3.564383776990089764e-02 -7.072771253015849857e-03 -3.192768196955810076e-03 -1.394774321933030074e-02 -2.592261998182820038e-03 1.556684454070180086e-02 1.549073015887240078e-02
276 -5.514554978810590376e-03 5.068011873981870252e-02 -1.159501450521270051e-02 1.154374291374709975e-02 -2.220825269322829892e-02 -1.540555820674759969e-02 -2.131101882750449997e-02 -2.592261998182820038e-03 1.100810104587249955e-02 6.933812005172369786e-02
277 1.264813727628719998e-02 -4.464163650698899782e-02 2.612840808061879863e-02 6.318680331979099896e-02 1.250187031342930022e-01 9.169121572527250130e-02 6.336665066649820044e-02 -2.592261998182820038e-03 5.757285620242599822e-02 -2.178823207463989955e-02
278 -3.457486258696700065e-02 -4.464163650698899782e-02 -5.901874575597240019e-02 1.215130832538269907e-03 -5.385516843185429725e-02 -7.803525056465400456e-02 6.704828847058519337e-02 -7.639450375000099436e-02 -2.139368094035999993e-02 1.549073015887240078e-02
279 6.713621404158050254e-02 5.068011873981870252e-02 -3.638469220447349689e-02 -8.485663651086830517e-02 -7.072771253015849857e-03 1.966706951368000014e-02 -5.444575906428809897e-02 3.430885887772629900e-02 1.143797379512540100e-03 3.205915781821130212e-02
280 3.807590643342410180e-02 5.068011873981870252e-02 -2.452875939178359929e-02 4.658001526274530187e-03 -2.633611126783170012e-02 -2.636575436938120090e-02 1.550535921336619952e-02 -3.949338287409189657e-02 -1.599826775813870117e-02 -2.593033898947460017e-02
281 9.015598825267629943e-03 5.068011873981870252e-02 1.858372356345249984e-02 3.908670846363720280e-02 1.769438019460449832e-02 1.058576412178359981e-02 1.918699701745330000e-02 -2.592261998182820038e-03 1.630495279994180133e-02 -1.764612515980519894e-02
282 -9.269547780327989928e-02 5.068011873981870252e-02 -9.027529589851850111e-02 -5.731367096097819691e-02 -2.496015840963049931e-02 -3.043668437264510085e-02 -6.584467611156170040e-03 -2.592261998182820038e-03 2.405258322689299982e-02 3.064409414368320182e-03
283 7.076875249260000666e-02 -4.464163650698899782e-02 -5.128142061927360405e-03 -5.670610554934250001e-03 8.786797596286209655e-02 1.029645603496960049e-01 1.182372140927919965e-02 3.430885887772629900e-02 -8.944018957797799166e-03 2.791705090337660150e-02
284 -1.641217033186929963e-02 -4.464163650698899782e-02 -5.255187331268700024e-02 -3.321357610482440076e-02 -4.422349842444640161e-02 -3.638650514664620167e-02 1.918699701745330000e-02 -3.949338287409189657e-02 -6.832974362442149896e-02 -3.007244590430930078e-02
285 4.170844488444359899e-02 5.068011873981870252e-02 -2.237313524402180162e-02 2.875809638242839833e-02 -6.623874415566440021e-02 -4.515466207675319921e-02 -6.180903467246220279e-02 -2.592261998182820038e-03 2.863770518940129874e-03 -5.492508739331759815e-02
286 1.264813727628719998e-02 -4.464163650698899782e-02 -2.021751109626000048e-02 -1.599922263614299983e-02 1.219056876180000040e-02 2.123281182262769934e-02 -7.653558588881050062e-02 1.081111006295440019e-01 5.988072306548120061e-02 -2.178823207463989955e-02
287 -3.820740103798660192e-02 -4.464163650698899782e-02 -5.470749746044879791e-02 -7.797089512339580586e-02 -3.321587555883730170e-02 -8.649025903297140327e-02 1.406810445523269948e-01 -7.639450375000099436e-02 -1.919704761394450121e-02 -5.219804415301099697e-03
288 4.534098333546320025e-02 -4.464163650698899782e-02 -6.205954135808240159e-03 -1.599922263614299983e-02 1.250187031342930022e-01 1.251981011367520047e-01 1.918699701745330000e-02 3.430885887772629900e-02 3.243322577960189995e-02 -5.219804415301099697e-03
289 7.076875249260000666e-02 5.068011873981870252e-02 -1.698407487461730050e-02 2.187235499495579841e-02 4.383748450042589812e-02 5.630543954305530091e-02 3.759518603788870178e-02 -2.592261998182820038e-03 -7.020931272868760620e-02 -1.764612515980519894e-02
290 -7.453278554818210111e-02 5.068011873981870252e-02 5.522933407540309841e-02 -4.009931749229690007e-02 5.346915450783389784e-02 5.317395492515999966e-02 -4.340084565202689815e-02 7.120997975363539678e-02 6.123790751970099866e-02 -3.421455281914410201e-02
291 5.987113713954139715e-02 5.068011873981870252e-02 7.678557555302109594e-02 2.531522568869210010e-02 1.182945896190920002e-03 1.684873335757430118e-02 -5.444575906428809897e-02 3.430885887772629900e-02 2.993564839653250001e-02 4.448547856271539702e-02
292 7.440129094361959405e-02 -4.464163650698899782e-02 1.858372356345249984e-02 6.318680331979099896e-02 6.172487165704060308e-02 4.284005568610550069e-02 8.142083605192099172e-03 -2.592261998182820038e-03 5.803912766389510147e-02 -5.906719430815229877e-02
293 9.015598825267629943e-03 -4.464163650698899782e-02 -2.237313524402180162e-02 -3.206595255172180192e-02 -4.972730985725089953e-02 -6.864079671096809387e-02 7.809320188284639419e-02 -7.085933561861459951e-02 -6.291294991625119570e-02 -3.835665973397880263e-02
294 -7.090024709716259699e-02 -4.464163650698899782e-02 9.295275666123460623e-02 1.269136646684959971e-02 2.044628591100669870e-02 4.252690722431590187e-02 7.788079970179680352e-04 3.598276718899090076e-04 -5.454415271109520208e-02 -1.077697500466389974e-03
295 2.354575262934580082e-02 5.068011873981870252e-02 -3.099563183506899924e-02 -5.670610554934250001e-03 -1.670444126042380101e-02 1.778817874294279927e-02 -3.235593223976569732e-02 -2.592261998182820038e-03 -7.408887149153539631e-02 -3.421455281914410201e-02
296 -5.273755484206479882e-02 5.068011873981870252e-02 3.906215296718960200e-02 -4.009931749229690007e-02 -5.696818394814720174e-03 -1.290037051243130006e-02 1.182372140927919965e-02 -3.949338287409189657e-02 1.630495279994180133e-02 3.064409414368320182e-03
297 6.713621404158050254e-02 -4.464163650698899782e-02 -6.117436990373419786e-02 -4.009931749229690007e-02 -2.633611126783170012e-02 -2.448686359864400003e-02 3.391354823380159783e-02 -3.949338287409189657e-02 -5.615757309500619965e-02 -5.906719430815229877e-02
298 1.750521923228520000e-03 -4.464163650698899782e-02 -8.361578283570040432e-03 -6.419941234845069622e-02 -3.871968699164179961e-02 -2.448686359864400003e-02 4.460445801105040325e-03 -3.949338287409189657e-02 -6.468302246445030435e-02 -5.492508739331759815e-02
299 2.354575262934580082e-02 5.068011873981870252e-02 -3.746250427835440266e-02 -4.698505887976939938e-02 -9.100589560328480043e-02 -7.553006287033779687e-02 -3.235593223976569732e-02 -3.949338287409189657e-02 -3.075120986455629965e-02 -1.350401824497050006e-02
300 3.807590643342410180e-02 5.068011873981870252e-02 -1.375063865297449991e-02 -1.599922263614299983e-02 -3.596778127523959923e-02 -2.198167590432769866e-02 -1.394774321933030074e-02 -2.592261998182820038e-03 -2.595242443518940012e-02 -1.077697500466389974e-03
301 1.628067572730669890e-02 -4.464163650698899782e-02 7.355213933137849658e-02 -4.124694104539940176e-02 -4.320865536613589623e-03 -1.352666743601040056e-02 -1.394774321933030074e-02 -1.116217163146459961e-03 4.289568789252869857e-02 4.448547856271539702e-02
302 -1.882016527791040067e-03 5.068011873981870252e-02 -2.452875939178359929e-02 5.285819123858220142e-02 2.732605020201240090e-02 3.000096875273459973e-02 3.023191042971450082e-02 -2.592261998182820038e-03 -2.139368094035999993e-02 3.620126473304600273e-02
303 1.264813727628719998e-02 -4.464163650698899782e-02 3.367309259778510089e-02 3.334859052598110329e-02 3.007795591841460128e-02 2.718263259662880016e-02 -2.902829807069099918e-03 8.847085473348980864e-03 3.119299070280229930e-02 2.791705090337660150e-02
304 7.440129094361959405e-02 -4.464163650698899782e-02 3.475090467166599972e-02 9.417263956341730136e-02 5.759701308243719842e-02 2.029336643725910064e-02 2.286863482154040048e-02 -2.592261998182820038e-03 7.380214692004880006e-02 -2.178823207463989955e-02
305 4.170844488444359899e-02 5.068011873981870252e-02 -3.854031635223530150e-02 5.285819123858220142e-02 7.686035309725310072e-02 1.164299442066459994e-01 -3.971920784793980114e-02 7.120997975363539678e-02 -2.251217192966049885e-02 -1.350401824497050006e-02
306 -9.147093429830140468e-03 5.068011873981870252e-02 -3.961812842611620034e-02 -4.009931749229690007e-02 -8.448724111216979540e-03 1.622243643399520069e-02 -6.549067247654929980e-02 7.120997975363539678e-02 1.776347786711730131e-02 -6.735140813782170000e-02
307 9.015598825267629943e-03 5.068011873981870252e-02 -1.894705840284650021e-03 2.187235499495579841e-02 -3.871968699164179961e-02 -2.480001206043359885e-02 -6.584467611156170040e-03 -3.949338287409189657e-02 -3.980959436433750137e-02 -1.350401824497050006e-02
308 6.713621404158050254e-02 5.068011873981870252e-02 -3.099563183506899924e-02 4.658001526274530187e-03 2.457414448561009990e-02 3.563764106494619888e-02 -2.867429443567860031e-02 3.430885887772629900e-02 2.337484127982079885e-02 8.176444079622779970e-02
309 1.750521923228520000e-03 -4.464163650698899782e-02 -4.608500086940160029e-02 -3.321357610482440076e-02 -7.311850844667000526e-02 -8.147988364433890462e-02 4.495846164606279866e-02 -6.938329078357829971e-02 -6.117659509433449883e-02 -7.977772888232589898e-02
310 -9.147093429830140468e-03 5.068011873981870252e-02 1.338730381358059929e-03 -2.227739861197989939e-03 7.961225881365530110e-02 7.008397186179469995e-02 3.391354823380159783e-02 -2.592261998182820038e-03 2.671425763351279944e-02 8.176444079622779970e-02
311 -5.514554978810590376e-03 -4.464163650698899782e-02 6.492964274033119487e-02 3.564383776990089764e-02 -1.568959820211340015e-03 1.496984258683710031e-02 -1.394774321933030074e-02 7.288388806489919797e-04 -1.811826730789670159e-02 3.205915781821130212e-02
312 9.619652164973699349e-02 -4.464163650698899782e-02 4.013996504107050084e-02 -5.731367096097819691e-02 4.521343735862710239e-02 6.068951800810880315e-02 -2.131101882750449997e-02 3.615391492152170150e-02 1.255315281338930007e-02 2.377494398854190089e-02
313 -7.453278554818210111e-02 -4.464163650698899782e-02 -2.345094731790270046e-02 -5.670610554934250001e-03 -2.083229983502719873e-02 -1.415296435958940044e-02 1.550535921336619952e-02 -3.949338287409189657e-02 -3.845911230135379971e-02 -3.007244590430930078e-02
314 5.987113713954139715e-02 5.068011873981870252e-02 5.307370992764130074e-02 5.285819123858220142e-02 3.282986163481690228e-02 1.966706951368000014e-02 -1.026610541524320026e-02 3.430885887772629900e-02 5.520503808961670089e-02 -1.077697500466389974e-03
315 -2.367724723390840155e-02 -4.464163650698899782e-02 4.013996504107050084e-02 -1.255635194240680048e-02 -9.824676969418109224e-03 -1.000728964429089965e-03 -2.902829807069099918e-03 -2.592261998182820038e-03 -1.190068480150809939e-02 -3.835665973397880263e-02
316 9.015598825267629943e-03 -4.464163650698899782e-02 -2.021751109626000048e-02 -5.387080026724189868e-02 3.145390877661580209e-02 2.060651489904859884e-02 5.600337505832399948e-02 -3.949338287409189657e-02 -1.090443584737709956e-02 -1.077697500466389974e-03
317 1.628067572730669890e-02 5.068011873981870252e-02 1.427247526792889930e-02 1.215130832538269907e-03 1.182945896190920002e-03 -2.135537898074869878e-02 -3.235593223976569732e-02 3.430885887772629900e-02 7.496833602773420036e-02 4.034337164788070335e-02
318 1.991321417832630017e-02 -4.464163650698899782e-02 -3.422906805671169922e-02 5.515343848250200270e-02 6.722868308984519814e-02 7.415490186505870052e-02 -6.584467611156170040e-03 3.283281404268990206e-02 2.472532334280450050e-02 6.933812005172369786e-02
319 8.893144474769780483e-02 -4.464163650698899782e-02 6.727790750762559745e-03 2.531522568869210010e-02 3.007795591841460128e-02 8.706873351046409346e-03 6.336665066649820044e-02 -3.949338287409189657e-02 9.436409146079870192e-03 3.205915781821130212e-02
320 1.991321417832630017e-02 -4.464163650698899782e-02 4.572166603000769880e-03 4.597244985110970211e-02 -1.808039411862490120e-02 -5.454911593043910295e-02 6.336665066649820044e-02 -3.949338287409189657e-02 2.866072031380889965e-02 6.105390622205419948e-02
321 -2.367724723390840155e-02 -4.464163650698899782e-02 3.043965637614240091e-02 -5.670610554934250001e-03 8.236416453005759863e-02 9.200436418706199604e-02 -1.762938102341739949e-02 7.120997975363539678e-02 3.304707235493409972e-02 3.064409414368320182e-03
322 9.619652164973699349e-02 -4.464163650698899782e-02 5.199589785376040191e-02 7.925353333865589600e-02 5.484510736603499803e-02 3.657708645031480105e-02 -7.653558588881050062e-02 1.413221094178629955e-01 9.864637430492799453e-02 6.105390622205419948e-02
323 2.354575262934580082e-02 5.068011873981870252e-02 6.169620651868849837e-02 6.203917986997459916e-02 2.457414448561009990e-02 -3.607335668485669999e-02 -9.126213710515880539e-02 1.553445353507079962e-01 1.333957338374689994e-01 8.176444079622779970e-02
324 7.076875249260000666e-02 5.068011873981870252e-02 -7.283766209689159811e-03 4.941532054484590319e-02 6.034891879883950289e-02 -4.445362044113949918e-03 -5.444575906428809897e-02 1.081111006295440019e-01 1.290194116001679991e-01 5.691179930721949887e-02
325 3.081082953138499989e-02 -4.464163650698899782e-02 5.649978676881649634e-03 1.154374291374709975e-02 7.823630595545419397e-02 7.791268340653299818e-02 -4.340084565202689815e-02 1.081111006295440019e-01 6.604820616309839409e-02 1.963283707370720027e-02
326 -1.882016527791040067e-03 -4.464163650698899782e-02 5.415152200152219958e-02 -6.649465948908450663e-02 7.273249452264969606e-02 5.661858800484489973e-02 -4.340084565202689815e-02 8.486339447772170419e-02 8.449528221240310000e-02 4.862758547755009764e-02
327 4.534098333546320025e-02 5.068011873981870252e-02 -8.361578283570040432e-03 -3.321357610482440076e-02 -7.072771253015849857e-03 1.191310268097639903e-03 -3.971920784793980114e-02 3.430885887772629900e-02 2.993564839653250001e-02 2.791705090337660150e-02
328 7.440129094361959405e-02 -4.464163650698899782e-02 1.145089981388529993e-01 2.875809638242839833e-02 2.457414448561009990e-02 2.499059336410210108e-02 1.918699701745330000e-02 -2.592261998182820038e-03 -6.092541861022970299e-04 -5.219804415301099697e-03
329 -3.820740103798660192e-02 -4.464163650698899782e-02 6.708526688809300642e-02 -6.075654165471439799e-02 -2.908801698423390050e-02 -2.323426975148589965e-02 -1.026610541524320026e-02 -2.592261998182820038e-03 -1.498586820292070049e-03 1.963283707370720027e-02
330 -1.277963188084970010e-02 5.068011873981870252e-02 -5.578530953432969675e-02 -2.227739861197989939e-03 -2.771206412603280031e-02 -2.918409052548700047e-02 1.918699701745330000e-02 -3.949338287409189657e-02 -1.705210460474350029e-02 4.448547856271539702e-02
331 9.015598825267629943e-03 5.068011873981870252e-02 3.043965637614240091e-02 4.252957915737339695e-02 -2.944912678412469915e-03 3.689023491210430272e-02 -6.549067247654929980e-02 7.120997975363539678e-02 -2.364455757213410059e-02 1.549073015887240078e-02
332 8.166636784565869944e-02 5.068011873981870252e-02 -2.560657146566450160e-02 -3.665644679856060184e-02 -7.036660273026780488e-02 -4.640725592391130305e-02 -3.971920784793980114e-02 -2.592261998182820038e-03 -4.118038518800790082e-02 -5.219804415301099697e-03
333 3.081082953138499989e-02 -4.464163650698899782e-02 1.048086894739250069e-01 7.695828609473599757e-02 -1.120062982761920074e-02 -1.133462820348369975e-02 -5.812739686837520292e-02 3.430885887772629900e-02 5.710418744784390155e-02 3.620126473304600273e-02
334 2.717829108036539862e-02 5.068011873981870252e-02 -6.205954135808240159e-03 2.875809638242839833e-02 -1.670444126042380101e-02 -1.627025888008149911e-03 -5.812739686837520292e-02 3.430885887772629900e-02 2.930041326858690010e-02 3.205915781821130212e-02
335 -6.000263174410389727e-02 5.068011873981870252e-02 -4.716281294328249912e-02 -2.288496402361559975e-02 -7.174255558846899528e-02 -5.768060054833450134e-02 -6.584467611156170040e-03 -3.949338287409189657e-02 -6.291294991625119570e-02 -5.492508739331759815e-02
336 5.383060374248070309e-03 -4.464163650698899782e-02 -4.824062501716339796e-02 -1.255635194240680048e-02 1.182945896190920002e-03 -6.637401276640669812e-03 6.336665066649820044e-02 -3.949338287409189657e-02 -5.140053526058249722e-02 -5.906719430815229877e-02
337 -2.004470878288880029e-02 -4.464163650698899782e-02 8.540807214406830050e-02 -3.665644679856060184e-02 9.199583453746550121e-02 8.949917649274570508e-02 -6.180903467246220279e-02 1.450122215054540087e-01 8.094791351127560153e-02 5.276969239238479825e-02
338 1.991321417832630017e-02 5.068011873981870252e-02 -1.267282657909369996e-02 7.007254470726349826e-02 -1.120062982761920074e-02 7.141131042098750048e-03 -3.971920784793980114e-02 3.430885887772629900e-02 5.384369968545729690e-03 3.064409414368320182e-03
339 -6.363517019512339445e-02 -4.464163650698899782e-02 -3.315125598283080038e-02 -3.321357610482440076e-02 1.182945896190920002e-03 2.405114797873349891e-02 -2.499265663159149983e-02 -2.592261998182820038e-03 -2.251217192966049885e-02 -5.906719430815229877e-02
340 2.717829108036539862e-02 -4.464163650698899782e-02 -7.283766209689159811e-03 -5.042792957350569760e-02 7.548440023905199359e-02 5.661858800484489973e-02 3.391354823380159783e-02 -2.592261998182820038e-03 4.344317225278129802e-02 1.549073015887240078e-02
341 -1.641217033186929963e-02 -4.464163650698899782e-02 -1.375063865297449991e-02 1.320442171945160059e-01 -9.824676969418109224e-03 -3.819065120534880214e-03 1.918699701745330000e-02 -3.949338287409189657e-02 -3.581672810154919867e-02 -3.007244590430930078e-02
342 3.081082953138499989e-02 5.068011873981870252e-02 5.954058237092670069e-02 5.630106193231849965e-02 -2.220825269322829892e-02 1.191310268097639903e-03 -3.235593223976569732e-02 -2.592261998182820038e-03 -2.479118743246069845e-02 -1.764612515980519894e-02
343 5.623859868852180283e-02 5.068011873981870252e-02 2.181715978509519982e-02 5.630106193231849965e-02 -7.072771253015849857e-03 1.810132720473240156e-02 -3.235593223976569732e-02 -2.592261998182820038e-03 -2.364455757213410059e-02 2.377494398854190089e-02
344 -2.004470878288880029e-02 -4.464163650698899782e-02 1.858372356345249984e-02 9.072976886968099619e-02 3.934851612593179802e-03 8.706873351046409346e-03 3.759518603788870178e-02 -3.949338287409189657e-02 -5.780006567561250114e-02 7.206516329203029904e-03
345 -1.072256316073579990e-01 -4.464163650698899782e-02 -1.159501450521270051e-02 -4.009931749229690007e-02 4.934129593323050011e-02 6.444729954958319795e-02 -1.394774321933030074e-02 3.430885887772629900e-02 7.026862549151949647e-03 -3.007244590430930078e-02
346 8.166636784565869944e-02 5.068011873981870252e-02 -2.972517914165530208e-03 -3.321357610482440076e-02 4.246153164222479792e-02 5.787118185200299664e-02 -1.026610541524320026e-02 3.430885887772629900e-02 -6.092541861022970299e-04 -1.077697500466389974e-03
347 5.383060374248070309e-03 5.068011873981870252e-02 1.750591148957160101e-02 3.220096707616459941e-02 1.277706088506949944e-01 1.273901403692790091e-01 -2.131101882750449997e-02 7.120997975363539678e-02 6.257518145805600340e-02 1.549073015887240078e-02
348 3.807590643342410180e-02 5.068011873981870252e-02 -2.991781976118810041e-02 -7.452802442965950069e-02 -1.257658268582039982e-02 -1.258722205064180012e-02 4.460445801105040325e-03 -2.592261998182820038e-03 3.711738233435969789e-03 -3.007244590430930078e-02
349 3.081082953138499989e-02 -4.464163650698899782e-02 -2.021751109626000048e-02 -5.670610554934250001e-03 -4.320865536613589623e-03 -2.949723898727649868e-02 7.809320188284639419e-02 -3.949338287409189657e-02 -1.090443584737709956e-02 -1.077697500466389974e-03
350 1.750521923228520000e-03 5.068011873981870252e-02 -5.794093368209150136e-02 -4.354218818603310115e-02 -9.650970703608929835e-02 -4.703355284749029946e-02 -9.862541271333299941e-02 3.430885887772629900e-02 -6.117659509433449883e-02 -7.149351505265640061e-02
351 -2.730978568492789874e-02 5.068011873981870252e-02 6.061839444480759953e-02 1.079441223383619947e-01 1.219056876180000040e-02 -1.759759743927430051e-02 -2.902829807069099918e-03 -2.592261998182820038e-03 7.021129819331020649e-02 1.356118306890790048e-01
352 -8.543040090124079389e-02 5.068011873981870252e-02 -4.069594049999709917e-02 -3.321357610482440076e-02 -8.137422559587689785e-02 -6.958024209633670298e-02 -6.584467611156170040e-03 -3.949338287409189657e-02 -5.780006567561250114e-02 -4.249876664881350324e-02
353 1.264813727628719998e-02 5.068011873981870252e-02 -7.195249064254319316e-02 -4.698505887976939938e-02 -5.110326271545199972e-02 -9.713730673381550107e-02 1.185912177278039964e-01 -7.639450375000099436e-02 -2.028874775162960165e-02 -3.835665973397880263e-02
354 -5.273755484206479882e-02 -4.464163650698899782e-02 -5.578530953432969675e-02 -3.665644679856060184e-02 8.924392882106320368e-02 -3.192768196955810076e-03 8.142083605192099172e-03 3.430885887772629900e-02 1.323726493386760128e-01 3.064409414368320182e-03
355 -2.367724723390840155e-02 5.068011873981870252e-02 4.552902541047500196e-02 2.187235499495579841e-02 1.098832216940800049e-01 8.887287956916670173e-02 7.788079970179680352e-04 3.430885887772629900e-02 7.419253669003070262e-02 6.105390622205419948e-02
356 -7.453278554818210111e-02 5.068011873981870252e-02 -9.439390357450949676e-03 1.498661360748330083e-02 -3.734373413344069942e-02 -2.166852744253820046e-02 -1.394774321933030074e-02 -2.592261998182820038e-03 -3.324878724762579674e-02 1.134862324403770016e-02
357 -5.514554978810590376e-03 5.068011873981870252e-02 -3.315125598283080038e-02 -1.599922263614299983e-02 8.062710187196569719e-03 1.622243643399520069e-02 1.550535921336619952e-02 -2.592261998182820038e-03 -2.832024254799870092e-02 -7.563562196749110123e-02
358 -6.000263174410389727e-02 5.068011873981870252e-02 4.984027370599859730e-02 1.842948430121960079e-02 -1.670444126042380101e-02 -3.012353591085559917e-02 -1.762938102341739949e-02 -2.592261998182820038e-03 4.976865992074899769e-02 -5.906719430815229877e-02
359 -2.004470878288880029e-02 -4.464163650698899782e-02 -8.488623552911400694e-02 -2.632783471735180084e-02 -3.596778127523959923e-02 -3.419446591411950259e-02 4.127682384197570165e-02 -5.167075276314189725e-02 -8.238148325810279449e-02 -4.664087356364819692e-02
360 3.807590643342410180e-02 5.068011873981870252e-02 5.649978676881649634e-03 3.220096707616459941e-02 6.686757328995440036e-03 1.747503028115330106e-02 -2.499265663159149983e-02 3.430885887772629900e-02 1.482271084126630077e-02 6.105390622205419948e-02
361 1.628067572730669890e-02 -4.464163650698899782e-02 2.073934771121430098e-02 2.187235499495579841e-02 -1.395253554402150001e-02 -1.321351897422090062e-02 -6.584467611156170040e-03 -2.592261998182820038e-03 1.331596790892770020e-02 4.034337164788070335e-02
362 4.170844488444359899e-02 -4.464163650698899782e-02 -7.283766209689159811e-03 2.875809638242839833e-02 -4.284754556624519733e-02 -4.828614669464850045e-02 5.232173725423699961e-02 -7.639450375000099436e-02 -7.212845460195599356e-02 2.377494398854190089e-02
363 1.991321417832630017e-02 5.068011873981870252e-02 1.048086894739250069e-01 7.007254470726349826e-02 -3.596778127523959923e-02 -2.667890283117069911e-02 -2.499265663159149983e-02 -2.592261998182820038e-03 3.711738233435969789e-03 4.034337164788070335e-02
364 -4.910501639104519755e-02 5.068011873981870252e-02 -2.452875939178359929e-02 6.750727943574620551e-05 -4.697540414084860200e-02 -2.824464514011839830e-02 -6.549067247654929980e-02 2.840467953758080144e-02 1.919903307856710151e-02 1.134862324403770016e-02
365 1.750521923228520000e-03 5.068011873981870252e-02 -6.205954135808240159e-03 -1.944209332987930153e-02 -9.824676969418109224e-03 4.949091809572019746e-03 -3.971920784793980114e-02 3.430885887772629900e-02 1.482271084126630077e-02 9.833286845556660216e-02
366 3.444336798240450054e-02 -4.464163650698899782e-02 -3.854031635223530150e-02 -1.255635194240680048e-02 9.438663045397699403e-03 5.262240271361550044e-03 -6.584467611156170040e-03 -2.592261998182820038e-03 3.119299070280229930e-02 9.833286845556660216e-02
367 -4.547247794002570037e-02 5.068011873981870252e-02 1.371430516903520136e-01 -1.599922263614299983e-02 4.108557878402369773e-02 3.187985952347179713e-02 -4.340084565202689815e-02 7.120997975363539678e-02 7.102157794598219775e-02 4.862758547755009764e-02
368 -9.147093429830140468e-03 5.068011873981870252e-02 1.705552259806600024e-01 1.498661360748330083e-02 3.007795591841460128e-02 3.375875029420900147e-02 -2.131101882750449997e-02 3.430885887772629900e-02 3.365681290238470291e-02 3.205915781821130212e-02
369 -1.641217033186929963e-02 5.068011873981870252e-02 2.416542455238970041e-03 1.498661360748330083e-02 2.182223876920789951e-02 -1.008203435632550049e-02 -2.499265663159149983e-02 3.430885887772629900e-02 8.553312118743899850e-02 8.176444079622779970e-02
370 -9.147093429830140468e-03 -4.464163650698899782e-02 3.798434089330870317e-02 -4.009931749229690007e-02 -2.496015840963049931e-02 -3.819065120534880214e-03 -4.340084565202689815e-02 1.585829843977170153e-02 -5.145307980263110273e-03 2.791705090337660150e-02
371 1.991321417832630017e-02 -4.464163650698899782e-02 -5.794093368209150136e-02 -5.731367096097819691e-02 -1.568959820211340015e-03 -1.258722205064180012e-02 7.441156407875940126e-02 -3.949338287409189657e-02 -6.117659509433449883e-02 -7.563562196749110123e-02
372 5.260606023750229870e-02 5.068011873981870252e-02 -9.439390357450949676e-03 4.941532054484590319e-02 5.071724879143160031e-02 -1.916333974822199970e-02 -1.394774321933030074e-02 3.430885887772629900e-02 1.193439942037869961e-01 -1.764612515980519894e-02
373 -2.730978568492789874e-02 5.068011873981870252e-02 -2.345094731790270046e-02 -1.599922263614299983e-02 1.356652162000110060e-02 1.277780335431030062e-02 2.655027262562750096e-02 -2.592261998182820038e-03 -1.090443584737709956e-02 -2.178823207463989955e-02
374 -7.453278554818210111e-02 -4.464163650698899782e-02 -1.051720243133190055e-02 -5.670610554934250001e-03 -6.623874415566440021e-02 -5.705430362475540085e-02 -2.902829807069099918e-03 -3.949338287409189657e-02 -4.257210492279420166e-02 -1.077697500466389974e-03
375 -1.072256316073579990e-01 -4.464163650698899782e-02 -3.422906805671169922e-02 -6.764228304218700139e-02 -6.348683843926219983e-02 -7.051968748170529822e-02 8.142083605192099172e-03 -3.949338287409189657e-02 -6.092541861022970299e-04 -7.977772888232589898e-02
376 4.534098333546320025e-02 5.068011873981870252e-02 -2.972517914165530208e-03 1.079441223383619947e-01 3.558176735121919981e-02 2.248540566978590033e-02 2.655027262562750096e-02 -2.592261998182820038e-03 2.801650652326400162e-02 1.963283707370720027e-02
377 -1.882016527791040067e-03 -4.464163650698899782e-02 6.816307896197400240e-02 -5.670610554934250001e-03 1.195148917014880047e-01 1.302084765253850029e-01 -2.499265663159149983e-02 8.670845052151719690e-02 4.613233103941480340e-02 -1.077697500466389974e-03
378 1.991321417832630017e-02 5.068011873981870252e-02 9.961226972405269262e-03 1.842948430121960079e-02 1.494247447820220079e-02 4.471894645684260094e-02 -6.180903467246220279e-02 7.120997975363539678e-02 9.436409146079870192e-03 -6.320930122298699938e-02
379 1.628067572730669890e-02 5.068011873981870252e-02 2.416542455238970041e-03 -5.670610554934250001e-03 -5.696818394814720174e-03 1.089891258357309975e-02 -5.076412126020100196e-02 3.430885887772629900e-02 2.269202256674450122e-02 -3.835665973397880263e-02
380 -1.882016527791040067e-03 -4.464163650698899782e-02 -3.854031635223530150e-02 2.187235499495579841e-02 -1.088932827598989989e-01 -1.156130659793979942e-01 2.286863482154040048e-02 -7.639450375000099436e-02 -4.687948284421659950e-02 2.377494398854190089e-02
381 1.628067572730669890e-02 -4.464163650698899782e-02 2.612840808061879863e-02 5.859630917623830093e-02 -6.073493272285990230e-02 -4.421521669138449989e-02 -1.394774321933030074e-02 -3.395821474270550172e-02 -5.140053526058249722e-02 -2.593033898947460017e-02
382 -7.090024709716259699e-02 5.068011873981870252e-02 -8.919748382463760228e-02 -7.452802442965950069e-02 -4.284754556624519733e-02 -2.573945744580210040e-02 -3.235593223976569732e-02 -2.592261998182820038e-03 -1.290794225416879923e-02 -5.492508739331759815e-02
383 4.897352178648269744e-02 -4.464163650698899782e-02 6.061839444480759953e-02 -2.288496402361559975e-02 -2.358420555142939912e-02 -7.271172671423199729e-02 -4.340084565202689815e-02 -2.592261998182820038e-03 1.041376113589790042e-01 3.620126473304600273e-02
384 5.383060374248070309e-03 5.068011873981870252e-02 -2.884000768730720157e-02 -9.113481248670509197e-03 -3.183992270063620150e-02 -2.887094206369749880e-02 8.142083605192099172e-03 -3.949338287409189657e-02 -1.811826730789670159e-02 7.206516329203029904e-03
385 3.444336798240450054e-02 5.068011873981870252e-02 -2.991781976118810041e-02 4.658001526274530187e-03 9.337178739566659447e-02 8.699398879842949739e-02 3.391354823380159783e-02 -2.592261998182820038e-03 2.405258322689299982e-02 -3.835665973397880263e-02
386 2.354575262934580082e-02 5.068011873981870252e-02 -1.913969902237900103e-02 4.941532054484590319e-02 -6.348683843926219983e-02 -6.112523362801929733e-02 4.460445801105040325e-03 -3.949338287409189657e-02 -2.595242443518940012e-02 -1.350401824497050006e-02
387 1.991321417832630017e-02 -4.464163650698899782e-02 -4.069594049999709917e-02 -1.599922263614299983e-02 -8.448724111216979540e-03 -1.759759743927430051e-02 5.232173725423699961e-02 -3.949338287409189657e-02 -3.075120986455629965e-02 3.064409414368320182e-03
388 -4.547247794002570037e-02 -4.464163650698899782e-02 1.535028734180979987e-02 -7.452802442965950069e-02 -4.972730985725089953e-02 -1.728444897748479883e-02 -2.867429443567860031e-02 -2.592261998182820038e-03 -1.043648208321659998e-01 -7.563562196749110123e-02
389 5.260606023750229870e-02 5.068011873981870252e-02 -2.452875939178359929e-02 5.630106193231849965e-02 -7.072771253015849857e-03 -5.071658967693000106e-03 -2.131101882750449997e-02 -2.592261998182820038e-03 2.671425763351279944e-02 -3.835665973397880263e-02
390 -5.514554978810590376e-03 5.068011873981870252e-02 1.338730381358059929e-03 -8.485663651086830517e-02 -1.120062982761920074e-02 -1.665815205390569834e-02 4.864009945014990260e-02 -3.949338287409189657e-02 -4.118038518800790082e-02 -8.806194271199530021e-02
391 9.015598825267629943e-03 5.068011873981870252e-02 6.924089103585480409e-02 5.974393262605470073e-02 1.769438019460449832e-02 -2.323426975148589965e-02 -4.708248345611389801e-02 3.430885887772629900e-02 1.032922649115240038e-01 7.348022696655839847e-02
392 -2.367724723390840155e-02 -4.464163650698899782e-02 -6.979686649478139548e-02 -6.419941234845069622e-02 -5.935897986465880211e-02 -5.047818592717519953e-02 1.918699701745330000e-02 -3.949338287409189657e-02 -8.913686007934769340e-02 -5.078298047848289754e-02
393 -4.183993948900609910e-02 5.068011873981870252e-02 -2.991781976118810041e-02 -2.227739861197989939e-03 2.182223876920789951e-02 3.657708645031480105e-02 1.182372140927919965e-02 -2.592261998182820038e-03 -4.118038518800790082e-02 6.519601313688899724e-02
394 -7.453278554818210111e-02 -4.464163650698899782e-02 -4.608500086940160029e-02 -4.354218818603310115e-02 -2.908801698423390050e-02 -2.323426975148589965e-02 1.550535921336619952e-02 -3.949338287409189657e-02 -3.980959436433750137e-02 -2.178823207463989955e-02
395 3.444336798240450054e-02 -4.464163650698899782e-02 1.858372356345249984e-02 5.630106193231849965e-02 1.219056876180000040e-02 -5.454911593043910295e-02 -6.917231028063640375e-02 7.120997975363539678e-02 1.300806095217529879e-01 7.206516329203029904e-03
396 -6.000263174410389727e-02 -4.464163650698899782e-02 1.338730381358059929e-03 -2.977070541108809906e-02 -7.072771253015849857e-03 -2.166852744253820046e-02 1.182372140927919965e-02 -2.592261998182820038e-03 3.181521750079859684e-02 -5.492508739331759815e-02
397 -8.543040090124079389e-02 5.068011873981870252e-02 -3.099563183506899924e-02 -2.288496402361559975e-02 -6.348683843926219983e-02 -5.423596746864960128e-02 1.918699701745330000e-02 -3.949338287409189657e-02 -9.643322289178400675e-02 -3.421455281914410201e-02
398 5.260606023750229870e-02 -4.464163650698899782e-02 -4.050329988046450294e-03 -3.091832896419060075e-02 -4.697540414084860200e-02 -5.830689747191349775e-02 -1.394774321933030074e-02 -2.583996815000549896e-02 3.605579008983190309e-02 2.377494398854190089e-02
399 1.264813727628719998e-02 -4.464163650698899782e-02 1.535028734180979987e-02 -3.321357610482440076e-02 4.108557878402369773e-02 3.219300798526129881e-02 -2.902829807069099918e-03 -2.592261998182820038e-03 4.506616833626150148e-02 -6.735140813782170000e-02
400 5.987113713954139715e-02 5.068011873981870252e-02 2.289497185897609866e-02 4.941532054484590319e-02 1.631842733640340160e-02 1.183835796894170019e-02 -1.394774321933030074e-02 -2.592261998182820038e-03 3.953987807202419963e-02 1.963283707370720027e-02
401 -2.367724723390840155e-02 -4.464163650698899782e-02 4.552902541047500196e-02 9.072976886968099619e-02 -1.808039411862490120e-02 -3.544705976127759950e-02 7.072992627467229731e-02 -3.949338287409189657e-02 -3.452371533034950118e-02 -9.361911330135799444e-03
402 1.628067572730669890e-02 -4.464163650698899782e-02 -4.500718879552070145e-02 -5.731367096097819691e-02 -3.459182841703849903e-02 -5.392281900686000246e-02 7.441156407875940126e-02 -7.639450375000099436e-02 -4.257210492279420166e-02 4.034337164788070335e-02
403 1.107266754538149961e-01 5.068011873981870252e-02 -3.315125598283080038e-02 -2.288496402361559975e-02 -4.320865536613589623e-03 2.029336643725910064e-02 -6.180903467246220279e-02 7.120997975363539678e-02 1.556684454070180086e-02 4.448547856271539702e-02
404 -2.004470878288880029e-02 -4.464163650698899782e-02 9.726400495675820157e-02 -5.670610554934250001e-03 -5.696818394814720174e-03 -2.386056667506489953e-02 -2.131101882750449997e-02 -2.592261998182820038e-03 6.168584882386619894e-02 4.034337164788070335e-02
405 -1.641217033186929963e-02 -4.464163650698899782e-02 5.415152200152219958e-02 7.007254470726349826e-02 -3.321587555883730170e-02 -2.793149667832890010e-02 8.142083605192099172e-03 -3.949338287409189657e-02 -2.712864555432650121e-02 -9.361911330135799444e-03
406 4.897352178648269744e-02 5.068011873981870252e-02 1.231314947298999957e-01 8.384402748220859403e-02 -1.047654241852959967e-01 -1.008950882752900069e-01 -6.917231028063640375e-02 -2.592261998182820038e-03 3.664579779339879884e-02 -3.007244590430930078e-02
407 -5.637009329308430294e-02 -4.464163650698899782e-02 -8.057498723359039772e-02 -8.485663651086830517e-02 -3.734373413344069942e-02 -3.701280207022530216e-02 3.391354823380159783e-02 -3.949338287409189657e-02 -5.615757309500619965e-02 -1.377672256900120129e-01
408 2.717829108036539862e-02 -4.464163650698899782e-02 9.295275666123460623e-02 -5.272317671413939699e-02 8.062710187196569719e-03 3.970857106821010230e-02 -2.867429443567860031e-02 2.102445536239900062e-02 -4.836172480289190057e-02 1.963283707370720027e-02
409 6.350367559056099842e-02 -4.464163650698899782e-02 -5.039624916492520257e-02 1.079441223383619947e-01 3.145390877661580209e-02 1.935392105189049847e-02 -1.762938102341739949e-02 2.360753382371260159e-02 5.803912766389510147e-02 4.034337164788070335e-02
410 -5.273755484206479882e-02 5.068011873981870252e-02 -1.159501450521270051e-02 5.630106193231849965e-02 5.622106022423609822e-02 7.290230801790049953e-02 -3.971920784793980114e-02 7.120997975363539678e-02 3.056648739841480097e-02 -5.219804415301099697e-03
411 -9.147093429830140468e-03 5.068011873981870252e-02 -2.776219561342629927e-02 8.100872220010799790e-03 4.796534307502930278e-02 3.720338337389379746e-02 -2.867429443567860031e-02 3.430885887772629900e-02 6.604820616309839409e-02 -4.249876664881350324e-02
412 5.383060374248070309e-03 -4.464163650698899782e-02 5.846277029704580186e-02 -4.354218818603310115e-02 -7.311850844667000526e-02 -7.239857825244250256e-02 1.918699701745330000e-02 -7.639450375000099436e-02 -5.140053526058249722e-02 -2.593033898947460017e-02
413 7.440129094361959405e-02 -4.464163650698899782e-02 8.540807214406830050e-02 6.318680331979099896e-02 1.494247447820220079e-02 1.309095181609989944e-02 1.550535921336619952e-02 -2.592261998182820038e-03 6.209315616505399656e-03 8.590654771106250032e-02
414 -5.273755484206479882e-02 -4.464163650698899782e-02 -8.168937664037369826e-04 -2.632783471735180084e-02 1.081461590359879960e-02 7.141131042098750048e-03 4.864009945014990260e-02 -3.949338287409189657e-02 -3.581672810154919867e-02 1.963283707370720027e-02
415 8.166636784565869944e-02 5.068011873981870252e-02 6.727790750762559745e-03 -4.522987001831730094e-03 1.098832216940800049e-01 1.170562411302250028e-01 -3.235593223976569732e-02 9.187460744414439884e-02 5.472400334817909689e-02 7.206516329203029904e-03
416 -5.514554978810590376e-03 -4.464163650698899782e-02 8.883414898524360018e-03 -5.042792957350569760e-02 2.595009734381130070e-02 4.722413415115889884e-02 -4.340084565202689815e-02 7.120997975363539678e-02 1.482271084126630077e-02 3.064409414368320182e-03
417 -2.730978568492789874e-02 -4.464163650698899782e-02 8.001901177466380632e-02 9.876313370696999938e-02 -2.944912678412469915e-03 1.810132720473240156e-02 -1.762938102341739949e-02 3.311917341962639788e-03 -2.952762274177360077e-02 3.620126473304600273e-02
418 -5.273755484206479882e-02 -4.464163650698899782e-02 7.139651518361660176e-02 -7.452802442965950069e-02 -1.532848840222260020e-02 -1.313877426218630021e-03 4.460445801105040325e-03 -2.141183364489639834e-02 -4.687948284421659950e-02 3.064409414368320182e-03
419 9.015598825267629943e-03 -4.464163650698899782e-02 -2.452875939178359929e-02 -2.632783471735180084e-02 9.887559882847110626e-02 9.419640341958869512e-02 7.072992627467229731e-02 -2.592261998182820038e-03 -2.139368094035999993e-02 7.206516329203029904e-03
420 -2.004470878288880029e-02 -4.464163650698899782e-02 -5.470749746044879791e-02 -5.387080026724189868e-02 -6.623874415566440021e-02 -5.736745208654490252e-02 1.182372140927919965e-02 -3.949338287409189657e-02 -7.408887149153539631e-02 -5.219804415301099697e-03
421 2.354575262934580082e-02 -4.464163650698899782e-02 -3.638469220447349689e-02 6.750727943574620551e-05 1.182945896190920002e-03 3.469819567957759671e-02 -4.340084565202689815e-02 3.430885887772629900e-02 -3.324878724762579674e-02 6.105390622205419948e-02
422 3.807590643342410180e-02 5.068011873981870252e-02 1.642809941569069870e-02 2.187235499495579841e-02 3.970962592582259754e-02 4.503209491863210262e-02 -4.340084565202689815e-02 7.120997975363539678e-02 4.976865992074899769e-02 1.549073015887240078e-02
423 -7.816532399920170238e-02 5.068011873981870252e-02 7.786338762690199478e-02 5.285819123858220142e-02 7.823630595545419397e-02 6.444729954958319795e-02 2.655027262562750096e-02 -2.592261998182820038e-03 4.067226371449769728e-02 -9.361911330135799444e-03
424 9.015598825267629943e-03 5.068011873981870252e-02 -3.961812842611620034e-02 2.875809638242839833e-02 3.833367306762140020e-02 7.352860494147960002e-02 -7.285394808472339667e-02 1.081111006295440019e-01 1.556684454070180086e-02 -4.664087356364819692e-02
425 1.750521923228520000e-03 5.068011873981870252e-02 1.103903904628619932e-02 -1.944209332987930153e-02 -1.670444126042380101e-02 -3.819065120534880214e-03 -4.708248345611389801e-02 3.430885887772629900e-02 2.405258322689299982e-02 2.377494398854190089e-02
426 -7.816532399920170238e-02 -4.464163650698899782e-02 -4.069594049999709917e-02 -8.141376581713200000e-02 -1.006375656106929944e-01 -1.127947298232920004e-01 2.286863482154040048e-02 -7.639450375000099436e-02 -2.028874775162960165e-02 -5.078298047848289754e-02
427 3.081082953138499989e-02 5.068011873981870252e-02 -3.422906805671169922e-02 4.367720260718979675e-02 5.759701308243719842e-02 6.883137801463659611e-02 -3.235593223976569732e-02 5.755656502954899917e-02 3.546193866076970125e-02 8.590654771106250032e-02
428 -3.457486258696700065e-02 5.068011873981870252e-02 5.649978676881649634e-03 -5.670610554934250001e-03 -7.311850844667000526e-02 -6.269097593696699999e-02 -6.584467611156170040e-03 -3.949338287409189657e-02 -4.542095777704099890e-02 3.205915781821130212e-02
429 4.897352178648269744e-02 5.068011873981870252e-02 8.864150836571099701e-02 8.728689817594480205e-02 3.558176735121919981e-02 2.154596028441720101e-02 -2.499265663159149983e-02 3.430885887772629900e-02 6.604820616309839409e-02 1.314697237742440128e-01
430 -4.183993948900609910e-02 -4.464163650698899782e-02 -3.315125598283080038e-02 -2.288496402361559975e-02 4.658939021682820258e-02 4.158746183894729970e-02 5.600337505832399948e-02 -2.473293452372829840e-02 -2.595242443518940012e-02 -3.835665973397880263e-02
431 -9.147093429830140468e-03 -4.464163650698899782e-02 -5.686312160821060252e-02 -5.042792957350569760e-02 2.182223876920789951e-02 4.534524338042170144e-02 -2.867429443567860031e-02 3.430885887772629900e-02 -9.918957363154769225e-03 -1.764612515980519894e-02
432 7.076875249260000666e-02 5.068011873981870252e-02 -3.099563183506899924e-02 2.187235499495579841e-02 -3.734373413344069942e-02 -4.703355284749029946e-02 3.391354823380159783e-02 -3.949338287409189657e-02 -1.495647502491130078e-02 -1.077697500466389974e-03
433 9.015598825267629943e-03 -4.464163650698899782e-02 5.522933407540309841e-02 -5.670610554934250001e-03 5.759701308243719842e-02 4.471894645684260094e-02 -2.902829807069099918e-03 2.323852261495349888e-02 5.568354770267369691e-02 1.066170822852360034e-01
434 -2.730978568492789874e-02 -4.464163650698899782e-02 -6.009655782985329903e-02 -2.977070541108809906e-02 4.658939021682820258e-02 1.998021797546959896e-02 1.222728555318910032e-01 -3.949338287409189657e-02 -5.140053526058249722e-02 -9.361911330135799444e-03
435 1.628067572730669890e-02 -4.464163650698899782e-02 1.338730381358059929e-03 8.100872220010799790e-03 5.310804470794310353e-03 1.089891258357309975e-02 3.023191042971450082e-02 -3.949338287409189657e-02 -4.542095777704099890e-02 3.205915781821130212e-02
436 -1.277963188084970010e-02 -4.464163650698899782e-02 -2.345094731790270046e-02 -4.009931749229690007e-02 -1.670444126042380101e-02 4.635943347782499856e-03 -1.762938102341739949e-02 -2.592261998182820038e-03 -3.845911230135379971e-02 -3.835665973397880263e-02
437 -5.637009329308430294e-02 -4.464163650698899782e-02 -7.410811479030500470e-02 -5.042792957350569760e-02 -2.496015840963049931e-02 -4.703355284749029946e-02 9.281975309919469896e-02 -7.639450375000099436e-02 -6.117659509433449883e-02 -4.664087356364819692e-02
438 4.170844488444359899e-02 5.068011873981870252e-02 1.966153563733339868e-02 5.974393262605470073e-02 -5.696818394814720174e-03 -2.566471273376759888e-03 -2.867429443567860031e-02 -2.592261998182820038e-03 3.119299070280229930e-02 7.206516329203029904e-03
439 -5.514554978810590376e-03 5.068011873981870252e-02 -1.590626280073640167e-02 -6.764228304218700139e-02 4.934129593323050011e-02 7.916527725369119917e-02 -2.867429443567860031e-02 3.430885887772629900e-02 -1.811826730789670159e-02 4.448547856271539702e-02
440 4.170844488444359899e-02 5.068011873981870252e-02 -1.590626280073640167e-02 1.728186074811709910e-02 -3.734373413344069942e-02 -1.383981589779990050e-02 -2.499265663159149983e-02 -1.107951979964190078e-02 -4.687948284421659950e-02 1.549073015887240078e-02
441 -4.547247794002570037e-02 -4.464163650698899782e-02 3.906215296718960200e-02 1.215130832538269907e-03 1.631842733640340160e-02 1.528299104862660025e-02 -2.867429443567860031e-02 2.655962349378539894e-02 4.452837402140529671e-02 -2.593033898947460017e-02
442 -4.547247794002570037e-02 -4.464163650698899782e-02 -7.303030271642410587e-02 -8.141376581713200000e-02 8.374011738825870577e-02 2.780892952020790065e-02 1.738157847891100005e-01 -3.949338287409189657e-02 -4.219859706946029777e-03 3.064409414368320182e-03

View File

@@ -1 +0,0 @@
RUN echo "this is test"

View File

@@ -0,0 +1,442 @@
1.510000000000000000e+02
7.500000000000000000e+01
1.410000000000000000e+02
2.060000000000000000e+02
1.350000000000000000e+02
9.700000000000000000e+01
1.380000000000000000e+02
6.300000000000000000e+01
1.100000000000000000e+02
3.100000000000000000e+02
1.010000000000000000e+02
6.900000000000000000e+01
1.790000000000000000e+02
1.850000000000000000e+02
1.180000000000000000e+02
1.710000000000000000e+02
1.660000000000000000e+02
1.440000000000000000e+02
9.700000000000000000e+01
1.680000000000000000e+02
6.800000000000000000e+01
4.900000000000000000e+01
6.800000000000000000e+01
2.450000000000000000e+02
1.840000000000000000e+02
2.020000000000000000e+02
1.370000000000000000e+02
8.500000000000000000e+01
1.310000000000000000e+02
2.830000000000000000e+02
1.290000000000000000e+02
5.900000000000000000e+01
3.410000000000000000e+02
8.700000000000000000e+01
6.500000000000000000e+01
1.020000000000000000e+02
2.650000000000000000e+02
2.760000000000000000e+02
2.520000000000000000e+02
9.000000000000000000e+01
1.000000000000000000e+02
5.500000000000000000e+01
6.100000000000000000e+01
9.200000000000000000e+01
2.590000000000000000e+02
5.300000000000000000e+01
1.900000000000000000e+02
1.420000000000000000e+02
7.500000000000000000e+01
1.420000000000000000e+02
1.550000000000000000e+02
2.250000000000000000e+02
5.900000000000000000e+01
1.040000000000000000e+02
1.820000000000000000e+02
1.280000000000000000e+02
5.200000000000000000e+01
3.700000000000000000e+01
1.700000000000000000e+02
1.700000000000000000e+02
6.100000000000000000e+01
1.440000000000000000e+02
5.200000000000000000e+01
1.280000000000000000e+02
7.100000000000000000e+01
1.630000000000000000e+02
1.500000000000000000e+02
9.700000000000000000e+01
1.600000000000000000e+02
1.780000000000000000e+02
4.800000000000000000e+01
2.700000000000000000e+02
2.020000000000000000e+02
1.110000000000000000e+02
8.500000000000000000e+01
4.200000000000000000e+01
1.700000000000000000e+02
2.000000000000000000e+02
2.520000000000000000e+02
1.130000000000000000e+02
1.430000000000000000e+02
5.100000000000000000e+01
5.200000000000000000e+01
2.100000000000000000e+02
6.500000000000000000e+01
1.410000000000000000e+02
5.500000000000000000e+01
1.340000000000000000e+02
4.200000000000000000e+01
1.110000000000000000e+02
9.800000000000000000e+01
1.640000000000000000e+02
4.800000000000000000e+01
9.600000000000000000e+01
9.000000000000000000e+01
1.620000000000000000e+02
1.500000000000000000e+02
2.790000000000000000e+02
9.200000000000000000e+01
8.300000000000000000e+01
1.280000000000000000e+02
1.020000000000000000e+02
3.020000000000000000e+02
1.980000000000000000e+02
9.500000000000000000e+01
5.300000000000000000e+01
1.340000000000000000e+02
1.440000000000000000e+02
2.320000000000000000e+02
8.100000000000000000e+01
1.040000000000000000e+02
5.900000000000000000e+01
2.460000000000000000e+02
2.970000000000000000e+02
2.580000000000000000e+02
2.290000000000000000e+02
2.750000000000000000e+02
2.810000000000000000e+02
1.790000000000000000e+02
2.000000000000000000e+02
2.000000000000000000e+02
1.730000000000000000e+02
1.800000000000000000e+02
8.400000000000000000e+01
1.210000000000000000e+02
1.610000000000000000e+02
9.900000000000000000e+01
1.090000000000000000e+02
1.150000000000000000e+02
2.680000000000000000e+02
2.740000000000000000e+02
1.580000000000000000e+02
1.070000000000000000e+02
8.300000000000000000e+01
1.030000000000000000e+02
2.720000000000000000e+02
8.500000000000000000e+01
2.800000000000000000e+02
3.360000000000000000e+02
2.810000000000000000e+02
1.180000000000000000e+02
3.170000000000000000e+02
2.350000000000000000e+02
6.000000000000000000e+01
1.740000000000000000e+02
2.590000000000000000e+02
1.780000000000000000e+02
1.280000000000000000e+02
9.600000000000000000e+01
1.260000000000000000e+02
2.880000000000000000e+02
8.800000000000000000e+01
2.920000000000000000e+02
7.100000000000000000e+01
1.970000000000000000e+02
1.860000000000000000e+02
2.500000000000000000e+01
8.400000000000000000e+01
9.600000000000000000e+01
1.950000000000000000e+02
5.300000000000000000e+01
2.170000000000000000e+02
1.720000000000000000e+02
1.310000000000000000e+02
2.140000000000000000e+02
5.900000000000000000e+01
7.000000000000000000e+01
2.200000000000000000e+02
2.680000000000000000e+02
1.520000000000000000e+02
4.700000000000000000e+01
7.400000000000000000e+01
2.950000000000000000e+02
1.010000000000000000e+02
1.510000000000000000e+02
1.270000000000000000e+02
2.370000000000000000e+02
2.250000000000000000e+02
8.100000000000000000e+01
1.510000000000000000e+02
1.070000000000000000e+02
6.400000000000000000e+01
1.380000000000000000e+02
1.850000000000000000e+02
2.650000000000000000e+02
1.010000000000000000e+02
1.370000000000000000e+02
1.430000000000000000e+02
1.410000000000000000e+02
7.900000000000000000e+01
2.920000000000000000e+02
1.780000000000000000e+02
9.100000000000000000e+01
1.160000000000000000e+02
8.600000000000000000e+01
1.220000000000000000e+02
7.200000000000000000e+01
1.290000000000000000e+02
1.420000000000000000e+02
9.000000000000000000e+01
1.580000000000000000e+02
3.900000000000000000e+01
1.960000000000000000e+02
2.220000000000000000e+02
2.770000000000000000e+02
9.900000000000000000e+01
1.960000000000000000e+02
2.020000000000000000e+02
1.550000000000000000e+02
7.700000000000000000e+01
1.910000000000000000e+02
7.000000000000000000e+01
7.300000000000000000e+01
4.900000000000000000e+01
6.500000000000000000e+01
2.630000000000000000e+02
2.480000000000000000e+02
2.960000000000000000e+02
2.140000000000000000e+02
1.850000000000000000e+02
7.800000000000000000e+01
9.300000000000000000e+01
2.520000000000000000e+02
1.500000000000000000e+02
7.700000000000000000e+01
2.080000000000000000e+02
7.700000000000000000e+01
1.080000000000000000e+02
1.600000000000000000e+02
5.300000000000000000e+01
2.200000000000000000e+02
1.540000000000000000e+02
2.590000000000000000e+02
9.000000000000000000e+01
2.460000000000000000e+02
1.240000000000000000e+02
6.700000000000000000e+01
7.200000000000000000e+01
2.570000000000000000e+02
2.620000000000000000e+02
2.750000000000000000e+02
1.770000000000000000e+02
7.100000000000000000e+01
4.700000000000000000e+01
1.870000000000000000e+02
1.250000000000000000e+02
7.800000000000000000e+01
5.100000000000000000e+01
2.580000000000000000e+02
2.150000000000000000e+02
3.030000000000000000e+02
2.430000000000000000e+02
9.100000000000000000e+01
1.500000000000000000e+02
3.100000000000000000e+02
1.530000000000000000e+02
3.460000000000000000e+02
6.300000000000000000e+01
8.900000000000000000e+01
5.000000000000000000e+01
3.900000000000000000e+01
1.030000000000000000e+02
3.080000000000000000e+02
1.160000000000000000e+02
1.450000000000000000e+02
7.400000000000000000e+01
4.500000000000000000e+01
1.150000000000000000e+02
2.640000000000000000e+02
8.700000000000000000e+01
2.020000000000000000e+02
1.270000000000000000e+02
1.820000000000000000e+02
2.410000000000000000e+02
6.600000000000000000e+01
9.400000000000000000e+01
2.830000000000000000e+02
6.400000000000000000e+01
1.020000000000000000e+02
2.000000000000000000e+02
2.650000000000000000e+02
9.400000000000000000e+01
2.300000000000000000e+02
1.810000000000000000e+02
1.560000000000000000e+02
2.330000000000000000e+02
6.000000000000000000e+01
2.190000000000000000e+02
8.000000000000000000e+01
6.800000000000000000e+01
3.320000000000000000e+02
2.480000000000000000e+02
8.400000000000000000e+01
2.000000000000000000e+02
5.500000000000000000e+01
8.500000000000000000e+01
8.900000000000000000e+01
3.100000000000000000e+01
1.290000000000000000e+02
8.300000000000000000e+01
2.750000000000000000e+02
6.500000000000000000e+01
1.980000000000000000e+02
2.360000000000000000e+02
2.530000000000000000e+02
1.240000000000000000e+02
4.400000000000000000e+01
1.720000000000000000e+02
1.140000000000000000e+02
1.420000000000000000e+02
1.090000000000000000e+02
1.800000000000000000e+02
1.440000000000000000e+02
1.630000000000000000e+02
1.470000000000000000e+02
9.700000000000000000e+01
2.200000000000000000e+02
1.900000000000000000e+02
1.090000000000000000e+02
1.910000000000000000e+02
1.220000000000000000e+02
2.300000000000000000e+02
2.420000000000000000e+02
2.480000000000000000e+02
2.490000000000000000e+02
1.920000000000000000e+02
1.310000000000000000e+02
2.370000000000000000e+02
7.800000000000000000e+01
1.350000000000000000e+02
2.440000000000000000e+02
1.990000000000000000e+02
2.700000000000000000e+02
1.640000000000000000e+02
7.200000000000000000e+01
9.600000000000000000e+01
3.060000000000000000e+02
9.100000000000000000e+01
2.140000000000000000e+02
9.500000000000000000e+01
2.160000000000000000e+02
2.630000000000000000e+02
1.780000000000000000e+02
1.130000000000000000e+02
2.000000000000000000e+02
1.390000000000000000e+02
1.390000000000000000e+02
8.800000000000000000e+01
1.480000000000000000e+02
8.800000000000000000e+01
2.430000000000000000e+02
7.100000000000000000e+01
7.700000000000000000e+01
1.090000000000000000e+02
2.720000000000000000e+02
6.000000000000000000e+01
5.400000000000000000e+01
2.210000000000000000e+02
9.000000000000000000e+01
3.110000000000000000e+02
2.810000000000000000e+02
1.820000000000000000e+02
3.210000000000000000e+02
5.800000000000000000e+01
2.620000000000000000e+02
2.060000000000000000e+02
2.330000000000000000e+02
2.420000000000000000e+02
1.230000000000000000e+02
1.670000000000000000e+02
6.300000000000000000e+01
1.970000000000000000e+02
7.100000000000000000e+01
1.680000000000000000e+02
1.400000000000000000e+02
2.170000000000000000e+02
1.210000000000000000e+02
2.350000000000000000e+02
2.450000000000000000e+02
4.000000000000000000e+01
5.200000000000000000e+01
1.040000000000000000e+02
1.320000000000000000e+02
8.800000000000000000e+01
6.900000000000000000e+01
2.190000000000000000e+02
7.200000000000000000e+01
2.010000000000000000e+02
1.100000000000000000e+02
5.100000000000000000e+01
2.770000000000000000e+02
6.300000000000000000e+01
1.180000000000000000e+02
6.900000000000000000e+01
2.730000000000000000e+02
2.580000000000000000e+02
4.300000000000000000e+01
1.980000000000000000e+02
2.420000000000000000e+02
2.320000000000000000e+02
1.750000000000000000e+02
9.300000000000000000e+01
1.680000000000000000e+02
2.750000000000000000e+02
2.930000000000000000e+02
2.810000000000000000e+02
7.200000000000000000e+01
1.400000000000000000e+02
1.890000000000000000e+02
1.810000000000000000e+02
2.090000000000000000e+02
1.360000000000000000e+02
2.610000000000000000e+02
1.130000000000000000e+02
1.310000000000000000e+02
1.740000000000000000e+02
2.570000000000000000e+02
5.500000000000000000e+01
8.400000000000000000e+01
4.200000000000000000e+01
1.460000000000000000e+02
2.120000000000000000e+02
2.330000000000000000e+02
9.100000000000000000e+01
1.110000000000000000e+02
1.520000000000000000e+02
1.200000000000000000e+02
6.700000000000000000e+01
3.100000000000000000e+02
9.400000000000000000e+01
1.830000000000000000e+02
6.600000000000000000e+01
1.730000000000000000e+02
7.200000000000000000e+01
4.900000000000000000e+01
6.400000000000000000e+01
4.800000000000000000e+01
1.780000000000000000e+02
1.040000000000000000e+02
1.320000000000000000e+02
2.200000000000000000e+02
5.700000000000000000e+01
1 1.510000000000000000e+02
2 7.500000000000000000e+01
3 1.410000000000000000e+02
4 2.060000000000000000e+02
5 1.350000000000000000e+02
6 9.700000000000000000e+01
7 1.380000000000000000e+02
8 6.300000000000000000e+01
9 1.100000000000000000e+02
10 3.100000000000000000e+02
11 1.010000000000000000e+02
12 6.900000000000000000e+01
13 1.790000000000000000e+02
14 1.850000000000000000e+02
15 1.180000000000000000e+02
16 1.710000000000000000e+02
17 1.660000000000000000e+02
18 1.440000000000000000e+02
19 9.700000000000000000e+01
20 1.680000000000000000e+02
21 6.800000000000000000e+01
22 4.900000000000000000e+01
23 6.800000000000000000e+01
24 2.450000000000000000e+02
25 1.840000000000000000e+02
26 2.020000000000000000e+02
27 1.370000000000000000e+02
28 8.500000000000000000e+01
29 1.310000000000000000e+02
30 2.830000000000000000e+02
31 1.290000000000000000e+02
32 5.900000000000000000e+01
33 3.410000000000000000e+02
34 8.700000000000000000e+01
35 6.500000000000000000e+01
36 1.020000000000000000e+02
37 2.650000000000000000e+02
38 2.760000000000000000e+02
39 2.520000000000000000e+02
40 9.000000000000000000e+01
41 1.000000000000000000e+02
42 5.500000000000000000e+01
43 6.100000000000000000e+01
44 9.200000000000000000e+01
45 2.590000000000000000e+02
46 5.300000000000000000e+01
47 1.900000000000000000e+02
48 1.420000000000000000e+02
49 7.500000000000000000e+01
50 1.420000000000000000e+02
51 1.550000000000000000e+02
52 2.250000000000000000e+02
53 5.900000000000000000e+01
54 1.040000000000000000e+02
55 1.820000000000000000e+02
56 1.280000000000000000e+02
57 5.200000000000000000e+01
58 3.700000000000000000e+01
59 1.700000000000000000e+02
60 1.700000000000000000e+02
61 6.100000000000000000e+01
62 1.440000000000000000e+02
63 5.200000000000000000e+01
64 1.280000000000000000e+02
65 7.100000000000000000e+01
66 1.630000000000000000e+02
67 1.500000000000000000e+02
68 9.700000000000000000e+01
69 1.600000000000000000e+02
70 1.780000000000000000e+02
71 4.800000000000000000e+01
72 2.700000000000000000e+02
73 2.020000000000000000e+02
74 1.110000000000000000e+02
75 8.500000000000000000e+01
76 4.200000000000000000e+01
77 1.700000000000000000e+02
78 2.000000000000000000e+02
79 2.520000000000000000e+02
80 1.130000000000000000e+02
81 1.430000000000000000e+02
82 5.100000000000000000e+01
83 5.200000000000000000e+01
84 2.100000000000000000e+02
85 6.500000000000000000e+01
86 1.410000000000000000e+02
87 5.500000000000000000e+01
88 1.340000000000000000e+02
89 4.200000000000000000e+01
90 1.110000000000000000e+02
91 9.800000000000000000e+01
92 1.640000000000000000e+02
93 4.800000000000000000e+01
94 9.600000000000000000e+01
95 9.000000000000000000e+01
96 1.620000000000000000e+02
97 1.500000000000000000e+02
98 2.790000000000000000e+02
99 9.200000000000000000e+01
100 8.300000000000000000e+01
101 1.280000000000000000e+02
102 1.020000000000000000e+02
103 3.020000000000000000e+02
104 1.980000000000000000e+02
105 9.500000000000000000e+01
106 5.300000000000000000e+01
107 1.340000000000000000e+02
108 1.440000000000000000e+02
109 2.320000000000000000e+02
110 8.100000000000000000e+01
111 1.040000000000000000e+02
112 5.900000000000000000e+01
113 2.460000000000000000e+02
114 2.970000000000000000e+02
115 2.580000000000000000e+02
116 2.290000000000000000e+02
117 2.750000000000000000e+02
118 2.810000000000000000e+02
119 1.790000000000000000e+02
120 2.000000000000000000e+02
121 2.000000000000000000e+02
122 1.730000000000000000e+02
123 1.800000000000000000e+02
124 8.400000000000000000e+01
125 1.210000000000000000e+02
126 1.610000000000000000e+02
127 9.900000000000000000e+01
128 1.090000000000000000e+02
129 1.150000000000000000e+02
130 2.680000000000000000e+02
131 2.740000000000000000e+02
132 1.580000000000000000e+02
133 1.070000000000000000e+02
134 8.300000000000000000e+01
135 1.030000000000000000e+02
136 2.720000000000000000e+02
137 8.500000000000000000e+01
138 2.800000000000000000e+02
139 3.360000000000000000e+02
140 2.810000000000000000e+02
141 1.180000000000000000e+02
142 3.170000000000000000e+02
143 2.350000000000000000e+02
144 6.000000000000000000e+01
145 1.740000000000000000e+02
146 2.590000000000000000e+02
147 1.780000000000000000e+02
148 1.280000000000000000e+02
149 9.600000000000000000e+01
150 1.260000000000000000e+02
151 2.880000000000000000e+02
152 8.800000000000000000e+01
153 2.920000000000000000e+02
154 7.100000000000000000e+01
155 1.970000000000000000e+02
156 1.860000000000000000e+02
157 2.500000000000000000e+01
158 8.400000000000000000e+01
159 9.600000000000000000e+01
160 1.950000000000000000e+02
161 5.300000000000000000e+01
162 2.170000000000000000e+02
163 1.720000000000000000e+02
164 1.310000000000000000e+02
165 2.140000000000000000e+02
166 5.900000000000000000e+01
167 7.000000000000000000e+01
168 2.200000000000000000e+02
169 2.680000000000000000e+02
170 1.520000000000000000e+02
171 4.700000000000000000e+01
172 7.400000000000000000e+01
173 2.950000000000000000e+02
174 1.010000000000000000e+02
175 1.510000000000000000e+02
176 1.270000000000000000e+02
177 2.370000000000000000e+02
178 2.250000000000000000e+02
179 8.100000000000000000e+01
180 1.510000000000000000e+02
181 1.070000000000000000e+02
182 6.400000000000000000e+01
183 1.380000000000000000e+02
184 1.850000000000000000e+02
185 2.650000000000000000e+02
186 1.010000000000000000e+02
187 1.370000000000000000e+02
188 1.430000000000000000e+02
189 1.410000000000000000e+02
190 7.900000000000000000e+01
191 2.920000000000000000e+02
192 1.780000000000000000e+02
193 9.100000000000000000e+01
194 1.160000000000000000e+02
195 8.600000000000000000e+01
196 1.220000000000000000e+02
197 7.200000000000000000e+01
198 1.290000000000000000e+02
199 1.420000000000000000e+02
200 9.000000000000000000e+01
201 1.580000000000000000e+02
202 3.900000000000000000e+01
203 1.960000000000000000e+02
204 2.220000000000000000e+02
205 2.770000000000000000e+02
206 9.900000000000000000e+01
207 1.960000000000000000e+02
208 2.020000000000000000e+02
209 1.550000000000000000e+02
210 7.700000000000000000e+01
211 1.910000000000000000e+02
212 7.000000000000000000e+01
213 7.300000000000000000e+01
214 4.900000000000000000e+01
215 6.500000000000000000e+01
216 2.630000000000000000e+02
217 2.480000000000000000e+02
218 2.960000000000000000e+02
219 2.140000000000000000e+02
220 1.850000000000000000e+02
221 7.800000000000000000e+01
222 9.300000000000000000e+01
223 2.520000000000000000e+02
224 1.500000000000000000e+02
225 7.700000000000000000e+01
226 2.080000000000000000e+02
227 7.700000000000000000e+01
228 1.080000000000000000e+02
229 1.600000000000000000e+02
230 5.300000000000000000e+01
231 2.200000000000000000e+02
232 1.540000000000000000e+02
233 2.590000000000000000e+02
234 9.000000000000000000e+01
235 2.460000000000000000e+02
236 1.240000000000000000e+02
237 6.700000000000000000e+01
238 7.200000000000000000e+01
239 2.570000000000000000e+02
240 2.620000000000000000e+02
241 2.750000000000000000e+02
242 1.770000000000000000e+02
243 7.100000000000000000e+01
244 4.700000000000000000e+01
245 1.870000000000000000e+02
246 1.250000000000000000e+02
247 7.800000000000000000e+01
248 5.100000000000000000e+01
249 2.580000000000000000e+02
250 2.150000000000000000e+02
251 3.030000000000000000e+02
252 2.430000000000000000e+02
253 9.100000000000000000e+01
254 1.500000000000000000e+02
255 3.100000000000000000e+02
256 1.530000000000000000e+02
257 3.460000000000000000e+02
258 6.300000000000000000e+01
259 8.900000000000000000e+01
260 5.000000000000000000e+01
261 3.900000000000000000e+01
262 1.030000000000000000e+02
263 3.080000000000000000e+02
264 1.160000000000000000e+02
265 1.450000000000000000e+02
266 7.400000000000000000e+01
267 4.500000000000000000e+01
268 1.150000000000000000e+02
269 2.640000000000000000e+02
270 8.700000000000000000e+01
271 2.020000000000000000e+02
272 1.270000000000000000e+02
273 1.820000000000000000e+02
274 2.410000000000000000e+02
275 6.600000000000000000e+01
276 9.400000000000000000e+01
277 2.830000000000000000e+02
278 6.400000000000000000e+01
279 1.020000000000000000e+02
280 2.000000000000000000e+02
281 2.650000000000000000e+02
282 9.400000000000000000e+01
283 2.300000000000000000e+02
284 1.810000000000000000e+02
285 1.560000000000000000e+02
286 2.330000000000000000e+02
287 6.000000000000000000e+01
288 2.190000000000000000e+02
289 8.000000000000000000e+01
290 6.800000000000000000e+01
291 3.320000000000000000e+02
292 2.480000000000000000e+02
293 8.400000000000000000e+01
294 2.000000000000000000e+02
295 5.500000000000000000e+01
296 8.500000000000000000e+01
297 8.900000000000000000e+01
298 3.100000000000000000e+01
299 1.290000000000000000e+02
300 8.300000000000000000e+01
301 2.750000000000000000e+02
302 6.500000000000000000e+01
303 1.980000000000000000e+02
304 2.360000000000000000e+02
305 2.530000000000000000e+02
306 1.240000000000000000e+02
307 4.400000000000000000e+01
308 1.720000000000000000e+02
309 1.140000000000000000e+02
310 1.420000000000000000e+02
311 1.090000000000000000e+02
312 1.800000000000000000e+02
313 1.440000000000000000e+02
314 1.630000000000000000e+02
315 1.470000000000000000e+02
316 9.700000000000000000e+01
317 2.200000000000000000e+02
318 1.900000000000000000e+02
319 1.090000000000000000e+02
320 1.910000000000000000e+02
321 1.220000000000000000e+02
322 2.300000000000000000e+02
323 2.420000000000000000e+02
324 2.480000000000000000e+02
325 2.490000000000000000e+02
326 1.920000000000000000e+02
327 1.310000000000000000e+02
328 2.370000000000000000e+02
329 7.800000000000000000e+01
330 1.350000000000000000e+02
331 2.440000000000000000e+02
332 1.990000000000000000e+02
333 2.700000000000000000e+02
334 1.640000000000000000e+02
335 7.200000000000000000e+01
336 9.600000000000000000e+01
337 3.060000000000000000e+02
338 9.100000000000000000e+01
339 2.140000000000000000e+02
340 9.500000000000000000e+01
341 2.160000000000000000e+02
342 2.630000000000000000e+02
343 1.780000000000000000e+02
344 1.130000000000000000e+02
345 2.000000000000000000e+02
346 1.390000000000000000e+02
347 1.390000000000000000e+02
348 8.800000000000000000e+01
349 1.480000000000000000e+02
350 8.800000000000000000e+01
351 2.430000000000000000e+02
352 7.100000000000000000e+01
353 7.700000000000000000e+01
354 1.090000000000000000e+02
355 2.720000000000000000e+02
356 6.000000000000000000e+01
357 5.400000000000000000e+01
358 2.210000000000000000e+02
359 9.000000000000000000e+01
360 3.110000000000000000e+02
361 2.810000000000000000e+02
362 1.820000000000000000e+02
363 3.210000000000000000e+02
364 5.800000000000000000e+01
365 2.620000000000000000e+02
366 2.060000000000000000e+02
367 2.330000000000000000e+02
368 2.420000000000000000e+02
369 1.230000000000000000e+02
370 1.670000000000000000e+02
371 6.300000000000000000e+01
372 1.970000000000000000e+02
373 7.100000000000000000e+01
374 1.680000000000000000e+02
375 1.400000000000000000e+02
376 2.170000000000000000e+02
377 1.210000000000000000e+02
378 2.350000000000000000e+02
379 2.450000000000000000e+02
380 4.000000000000000000e+01
381 5.200000000000000000e+01
382 1.040000000000000000e+02
383 1.320000000000000000e+02
384 8.800000000000000000e+01
385 6.900000000000000000e+01
386 2.190000000000000000e+02
387 7.200000000000000000e+01
388 2.010000000000000000e+02
389 1.100000000000000000e+02
390 5.100000000000000000e+01
391 2.770000000000000000e+02
392 6.300000000000000000e+01
393 1.180000000000000000e+02
394 6.900000000000000000e+01
395 2.730000000000000000e+02
396 2.580000000000000000e+02
397 4.300000000000000000e+01
398 1.980000000000000000e+02
399 2.420000000000000000e+02
400 2.320000000000000000e+02
401 1.750000000000000000e+02
402 9.300000000000000000e+01
403 1.680000000000000000e+02
404 2.750000000000000000e+02
405 2.930000000000000000e+02
406 2.810000000000000000e+02
407 7.200000000000000000e+01
408 1.400000000000000000e+02
409 1.890000000000000000e+02
410 1.810000000000000000e+02
411 2.090000000000000000e+02
412 1.360000000000000000e+02
413 2.610000000000000000e+02
414 1.130000000000000000e+02
415 1.310000000000000000e+02
416 1.740000000000000000e+02
417 2.570000000000000000e+02
418 5.500000000000000000e+01
419 8.400000000000000000e+01
420 4.200000000000000000e+01
421 1.460000000000000000e+02
422 2.120000000000000000e+02
423 2.330000000000000000e+02
424 9.100000000000000000e+01
425 1.110000000000000000e+02
426 1.520000000000000000e+02
427 1.200000000000000000e+02
428 6.700000000000000000e+01
429 3.100000000000000000e+02
430 9.400000000000000000e+01
431 1.830000000000000000e+02
432 6.600000000000000000e+01
433 1.730000000000000000e+02
434 7.200000000000000000e+01
435 4.900000000000000000e+01
436 6.400000000000000000e+01
437 4.800000000000000000e+01
438 1.780000000000000000e+02
439 1.040000000000000000e+02
440 1.320000000000000000e+02
441 2.200000000000000000e+02
442 5.700000000000000000e+01

View File

@@ -20,12 +20,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Register Model and deploy as Webservice\n",
"# Register model and deploy as webservice\n",
"\n",
"This example shows how to deploy a Webservice in step-by-step fashion:\n",
"Following this notebook, you will:\n",
"\n",
" 1. Register Model\n",
" 2. Deploy Model as Webservice"
" - Learn how to register a model in your Azure Machine Learning Workspace.\n",
" - Deploy your model as a web service in an Azure Container Instance."
]
},
{
@@ -33,7 +33,8 @@
"metadata": {},
"source": [
"## Prerequisites\n",
"If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, make sure you go through the [configuration](../../../configuration.ipynb) Notebook first if you haven't."
"\n",
"If you are using an Azure Machine Learning Notebook VM, you are all set. Otherwise, make sure you go through the [configuration notebook](../../../configuration.ipynb) to install the Azure Machine Learning Python SDK and create a workspace."
]
},
{
@@ -42,19 +43,19 @@
"metadata": {},
"outputs": [],
"source": [
"# Check core SDK version number\n",
"import azureml.core\n",
"\n",
"print(\"SDK version:\", azureml.core.VERSION)"
"# Check core SDK version number.\n",
"print('SDK version:', azureml.core.VERSION)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Initialize Workspace\n",
"## Initialize workspace\n",
"\n",
"Initialize a workspace object from persisted configuration."
"Create a [Workspace](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.workspace%28class%29?view=azure-ml-py) object from your persisted configuration."
]
},
{
@@ -77,16 +78,37 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Register Model"
"## Register input and output datasets\n",
"\n",
"For this example, we have provided a small model (`sklearn_regression_model.pkl` in the notebook's directory) that was trained on scikit-learn's [diabetes dataset](https://scikit-learn.org/stable/datasets/index.html#diabetes-dataset). Here, you will register the data used to create this model in your workspace."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Dataset\n",
"\n",
"datastore = ws.get_default_datastore()\n",
"datastore.upload_files(files=['./features.csv', './labels.csv'],\n",
" target_path='sklearn_regression/',\n",
" overwrite=True)\n",
"\n",
"input_dataset = Dataset.Tabular.from_delimited_files(path=[(datastore, 'sklearn_regression/features.csv')])\n",
"output_dataset = Dataset.Tabular.from_delimited_files(path=[(datastore, 'sklearn_regression/labels.csv')])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can add tags and descriptions to your Models. Note you need to have a `sklearn_regression_model.pkl` file in the current directory. This file is generated by the 01 notebook. The below call registers that file as a Model with the same name `sklearn_regression_model.pkl` in the workspace.\n",
"## Register model\n",
"\n",
"Using tags, you can track useful information such as the name and version of the machine learning library used to train the model. Note that tags must be alphanumeric."
"Register a file or folder as a model by calling [Model.register()](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.model.model?view=azure-ml-py#register-workspace--model-path--model-name--tags-none--properties-none--description-none--datasets-none--model-framework-none--model-framework-version-none--child-paths-none-).\n",
"\n",
"In addition to the content of the model file itself, your registered model will also store model metadata -- model description, tags, and framework information -- that will be useful when managing and deploying models in your workspace. Using tags, for instance, you can categorize your models and apply filters when listing models in your workspace. Also, marking this model with the scikit-learn framework will simplify deploying it as a web service, as we'll see later."
]
},
{
@@ -99,29 +121,120 @@
},
"outputs": [],
"source": [
"from azureml.core.model import Model\n",
"from azureml.core import Model\n",
"from azureml.core.resource_configuration import ResourceConfiguration\n",
"\n",
"model = Model.register(model_path=\"sklearn_regression_model.pkl\",\n",
" model_name=\"sklearn_regression_model.pkl\",\n",
" tags={'area': \"diabetes\", 'type': \"regression\"},\n",
" description=\"Ridge regression model to predict diabetes\",\n",
" workspace=ws)"
"model = Model.register(workspace=ws,\n",
" model_name='my-sklearn-model', # Name of the registered model in your workspace.\n",
" model_path='./sklearn_regression_model.pkl', # Local file to upload and register as a model.\n",
" model_framework=Model.Framework.SCIKITLEARN, # Framework used to create the model.\n",
" model_framework_version='0.19.1', # Version of scikit-learn used to create the model.\n",
" sample_input_dataset=input_dataset,\n",
" sample_output_dataset=output_dataset,\n",
" resource_configuration=ResourceConfiguration(cpu=1, memory_in_gb=0.5),\n",
" description='Ridge regression model to predict diabetes progression.',\n",
" tags={'area': 'diabetes', 'type': 'regression'})\n",
"\n",
"print('Name:', model.name)\n",
"print('Version:', model.version)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create Environment"
"## Deploy model\n",
"\n",
"Deploy your model as a web service using [Model.deploy()](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.model.model?view=azure-ml-py#deploy-workspace--name--models--inference-config--deployment-config-none--deployment-target-none-). Web services take one or more models, load them in an environment, and run them on one of several supported deployment targets. For more information on all your options when deploying models, see the [next steps](#Next-steps) section at the end of this notebook.\n",
"\n",
"For this example, we will deploy your scikit-learn model to an Azure Container Instance (ACI)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can now create and/or use an Environment object when deploying a Webservice. The Environment can have been previously registered with your Workspace, or it will be registered with it as a part of the Webservice deployment. Only Environments that were created using azureml-defaults version 1.0.48 or later will work with this new handling however.\n",
"### Use a default environment (for supported models)\n",
"\n",
"More information can be found in our [using environments notebook](../training/using-environments/using-environments.ipynb)."
"The Azure Machine Learning service provides a default environment for supported model frameworks, including scikit-learn, based on the metadata you provided when registering your model. This is the easiest way to deploy your model.\n",
"\n",
"**Note**: This step can take several minutes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from azureml.core import Webservice\n",
"from azureml.exceptions import WebserviceException\n",
"\n",
"service_name = 'my-sklearn-service'\n",
"\n",
"# Remove any existing service under the same name.\n",
"try:\n",
" Webservice(ws, service_name).delete()\n",
"except WebserviceException:\n",
" pass\n",
"\n",
"service = Model.deploy(ws, service_name, [model])\n",
"service.wait_for_deployment(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After your model is deployed, perform a call to the web service using [service.run()](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.webservice%28class%29?view=azure-ml-py#run-input-)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"\n",
"input_payload = json.dumps({\n",
" 'data': [\n",
" [ 0.03807591, 0.05068012, 0.06169621, 0.02187235, -0.0442235,\n",
" -0.03482076, -0.04340085, -0.00259226, 0.01990842, -0.01764613]\n",
" ],\n",
" 'method': 'predict' # If you have a classification model, you can get probabilities by changing this to 'predict_proba'.\n",
"})\n",
"\n",
"output = service.run(input_payload)\n",
"\n",
"print(output)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When you are finished testing your service, clean up the deployment with [service.delete()](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.webservice%28class%29?view=azure-ml-py#delete--)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"service.delete()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Use a custom environment (for all models)\n",
"\n",
"If you want more control over how your model is run, if it uses another framework, or if it has special runtime requirements, you can instead specify your own environment and scoring method.\n",
"\n",
"Specify the model's runtime environment by creating an [Environment](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.environment%28class%29?view=azure-ml-py) object and providing the [CondaDependencies](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.conda_dependencies.condadependencies?view=azure-ml-py) needed by your model."
]
},
{
@@ -131,61 +244,42 @@
"outputs": [],
"source": [
"from azureml.core import Environment\n",
"from azureml.core.conda_dependencies import CondaDependencies\n",
"\n",
"env = Environment.from_conda_specification(name='deploytocloudenv', file_path='myenv.yml')\n",
"\n",
"# This is optional at this point\n",
"# env.register(workspace=ws)"
"environment = Environment('my-sklearn-environment')\n",
"environment.python.conda_dependencies = CondaDependencies.create(pip_packages=[\n",
" 'azureml-defaults',\n",
" 'inference-schema[numpy-support]',\n",
" 'joblib',\n",
" 'numpy',\n",
" 'scikit-learn'\n",
"])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create Inference Configuration\n",
"\n",
"There is now support for a source directory, you can upload an entire folder from your local machine as dependencies for the Webservice.\n",
"Note: in that case, your entry_script, conda_file, and extra_docker_file_steps paths are relative paths to the source_directory path.\n",
"\n",
"Sample code for using a source directory:\n",
"\n",
"```python\n",
"inference_config = InferenceConfig(source_directory=\"C:/abc\",\n",
" runtime= \"python\", \n",
" entry_script=\"x/y/score.py\",\n",
" conda_file=\"env/myenv.yml\", \n",
" extra_docker_file_steps=\"helloworld.txt\")\n",
"```\n",
"\n",
" - source_directory = holds source path as string, this entire folder gets added in image so its really easy to access any files within this folder or subfolder\n",
" - runtime = Which runtime to use for the image. Current supported runtimes are 'spark-py' and 'python\n",
" - entry_script = contains logic specific to initializing your model and running predictions\n",
" - conda_file = manages conda and python package dependencies.\n",
" - extra_docker_file_steps = optional: any extra steps you want to inject into docker file"
"When using a custom environment, you must also provide Python code for initializing and running your model. An example script is included with this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"create image"
]
},
"metadata": {},
"outputs": [],
"source": [
"from azureml.core.model import InferenceConfig\n",
"\n",
"inference_config = InferenceConfig(entry_script=\"score.py\", environment=env)"
"with open('score.py') as f:\n",
" print(f.read())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Deploy Model as Webservice on Azure Container Instance\n",
"Deploy your model in the custom environment by providing an [InferenceConfig](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.model.inferenceconfig?view=azure-ml-py) object to [Model.deploy()](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.model.model?view=azure-ml-py#deploy-workspace--name--models--inference-config--deployment-config-none--deployment-target-none-).\n",
"\n",
"Note that the service creation can take few minutes."
"**Note**: This step can take several minutes."
]
},
{
@@ -198,33 +292,31 @@
},
"outputs": [],
"source": [
"from azureml.core.webservice import AciWebservice, Webservice\n",
"from azureml.core import Webservice\n",
"from azureml.core.model import InferenceConfig\n",
"from azureml.exceptions import WebserviceException\n",
"\n",
"deployment_config = AciWebservice.deploy_configuration(cpu_cores=1, memory_gb=1)\n",
"aci_service_name = 'aciservice1'\n",
"service_name = 'my-custom-env-service'\n",
"\n",
"# Remove any existing service under the same name.\n",
"try:\n",
" # if you want to get existing service below is the command\n",
" # since aci name needs to be unique in subscription deleting existing aci if any\n",
" # we use aci_service_name to create azure aci\n",
" service = Webservice(ws, name=aci_service_name)\n",
" if service:\n",
" service.delete()\n",
"except WebserviceException as e:\n",
" print()\n",
" Webservice(ws, service_name).delete()\n",
"except WebserviceException:\n",
" pass\n",
"\n",
"service = Model.deploy(ws, aci_service_name, [model], inference_config, deployment_config)\n",
"inference_config = InferenceConfig(entry_script='score.py',\n",
" source_directory='.',\n",
" environment=environment)\n",
"\n",
"service.wait_for_deployment(True)\n",
"print(service.state)"
"service = Model.deploy(ws, service_name, [model], inference_config)\n",
"service.wait_for_deployment(show_output=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Test web service"
"After your model is deployed, make a call to the web service using [service.run()](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.webservice%28class%29?view=azure-ml-py#run-input-)."
]
},
{
@@ -234,32 +326,30 @@
"outputs": [],
"source": [
"import json\n",
"test_sample = json.dumps({'data': [\n",
" [1,2,3,4,5,6,7,8,9,10], \n",
" [10,9,8,7,6,5,4,3,2,1]\n",
"]})\n",
"\n",
"test_sample_encoded = bytes(test_sample, encoding='utf8')\n",
"prediction = service.run(input_data=test_sample_encoded)\n",
"print(prediction)"
"input_payload = json.dumps({\n",
" 'data': [\n",
" [ 0.03807591, 0.05068012, 0.06169621, 0.02187235, -0.0442235,\n",
" -0.03482076, -0.04340085, -0.00259226, 0.01990842, -0.01764613]\n",
" ]\n",
"})\n",
"\n",
"output = service.run(input_payload)\n",
"\n",
"print(output)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Delete ACI to clean up"
"When you are finished testing your service, clean up the deployment with [service.delete()](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.webservice%28class%29?view=azure-ml-py#delete--)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"deploy service",
"aci"
]
},
"metadata": {},
"outputs": [],
"source": [
"service.delete()"
@@ -269,7 +359,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Model Profiling\n",
"### Model profiling\n",
"\n",
"You can also take advantage of the profiling feature to estimate CPU and memory requirements for models.\n",
"\n",
@@ -285,7 +375,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Model Packaging\n",
"### Model packaging\n",
"\n",
"If you want to build a Docker image that encapsulates your model and its dependencies, you can use the model packaging option. The output image will be pushed to your workspace's ACR.\n",
"\n",
@@ -305,6 +395,19 @@
"package.save(\"./local_context_dir\")\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Next steps\n",
"\n",
" - To run a production-ready web service, see the [notebook on deployment to Azure Kubernetes Service](../production-deploy-to-aks/production-deploy-to-aks.ipynb).\n",
" - To run a local web service, see the [notebook on deployment to a local Docker container](../deploy-to-local/register-model-deploy-local.ipynb).\n",
" - For more information on datasets, see the [notebook on training with datasets](../../work-with-data/datasets-tutorial/train-with-datasets.ipynb).\n",
" - For more information on environments, see the [notebook on using environments](../../training/using-environments/using-environments.ipynb).\n",
" - For information on all the available deployment targets, see [&ldquo;How and where to deploy models&rdquo;](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-deploy-and-where#choose-a-compute-target)."
]
}
],
"metadata": {
@@ -313,6 +416,22 @@
"name": "aashishb"
}
],
"category": "deployment",
"compute": [
"None"
],
"datasets": [
"Diabetes"
],
"deployment": [
"Azure Container Instance"
],
"exclude_from_index": false,
"framework": [
"Scikit-learn"
],
"friendly_name": "Register model and deploy as webservice",
"index_order": 3,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -329,7 +448,14 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"star_tag": [
"featured"
],
"tags": [
"None"
],
"task": "Deploy a model with Azure Machine Learning"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -1,34 +1,38 @@
import pickle
import json
import joblib
import numpy as np
from sklearn.externals import joblib
from sklearn.linear_model import Ridge
from azureml.core.model import Model
import os
from inference_schema.schema_decorators import input_schema, output_schema
from inference_schema.parameter_types.numpy_parameter_type import NumpyParameterType
# The init() method is called once, when the web service starts up.
#
# Typically you would deserialize the model file, as shown here using joblib,
# and store it in a global variable so your run() method can access it later.
def init():
global model
# note here "sklearn_regression_model.pkl" is the name of the model registered under
# this is a different behavior than before when the code is run locally, even though the code is the same.
model_path = Model.get_model_path('sklearn_regression_model.pkl')
# deserialize the model file back into a sklearn model
# The AZUREML_MODEL_DIR environment variable indicates
# a directory containing the model file you registered.
model_filename = 'sklearn_regression_model.pkl'
model_path = os.path.join(os.environ['AZUREML_MODEL_DIR'], model_filename)
model = joblib.load(model_path)
input_sample = np.array([[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]])
output_sample = np.array([3726.995])
@input_schema('data', NumpyParameterType(input_sample))
@output_schema(NumpyParameterType(output_sample))
# The run() method is called each time a request is made to the scoring API.
#
# Shown here are the optional input_schema and output_schema decorators
# from the inference-schema pip package. Using these decorators on your
# run() method parses and validates the incoming payload against
# the example input you provide here. This will also generate a Swagger
# API document for your web service.
@input_schema('data', NumpyParameterType(np.array([[0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0]])))
@output_schema(NumpyParameterType(np.array([4429.929236457418])))
def run(data):
try:
result = model.predict(data)
# you can return any datatype as long as it is JSON-serializable
return result.tolist()
except Exception as e:
error = str(e)
return error
# Use the model object loaded by init().
result = model.predict(data)
# You can return any JSON-serializable object.
return result.tolist()

View File

@@ -86,7 +86,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"You can add tags and descriptions to your models. we are using `sklearn_regression_model.pkl` file in the current directory as a model with the same name `sklearn_regression_model.pkl` in the workspace.\n",
"You can add tags and descriptions to your models. we are using `sklearn_regression_model.pkl` file in the current directory as a model with the name `sklearn_regression_model_local_adv` in the workspace.\n",
"\n",
"Using tags, you can track useful information such as the name and version of the machine learning library used to train the model, framework, category, target customer etc. Note that tags must be alphanumeric."
]
@@ -104,7 +104,7 @@
"from azureml.core.model import Model\n",
"\n",
"model = Model.register(model_path=\"sklearn_regression_model.pkl\",\n",
" model_name=\"sklearn_regression_model.pkl\",\n",
" model_name=\"sklearn_regression_model_local_adv\",\n",
" tags={'area': \"diabetes\", 'type': \"regression\"},\n",
" description=\"Ridge regression model to predict diabetes\",\n",
" workspace=ws)"
@@ -137,7 +137,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Show `score.py`. Note that the `sklearn_regression_model.pkl` in the `get_model_path` call is referring to a model named `sklearn_regression_model.pkl` registered under the workspace. It is NOT referencing the local file."
"Show `score.py`. "
]
},
{
@@ -147,6 +147,7 @@
"outputs": [],
"source": [
"%%writefile C:/abc/x/y/score.py\n",
"import os\n",
"import pickle\n",
"import json\n",
"import numpy as np\n",
@@ -159,9 +160,10 @@
"\n",
"def init():\n",
" global model\n",
" # note here \"sklearn_regression_model.pkl\" is the name of the model registered under\n",
" # this is a different behavior than before when the code is run locally, even though the code is the same.\n",
" model_path = Model.get_model_path('sklearn_regression_model.pkl')\n",
" # AZUREML_MODEL_DIR is an environment variable created during deployment. Join this path with the filename of the model file.\n",
" # It holds the path to the directory that contains the deployed model (./azureml-models/$MODEL_NAME/$VERSION)\n",
" # If there are multiple models, this value is the path to the directory containing all deployed models (./azureml-models)\n",
" model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'sklearn_regression_model.pkl')\n",
" # deserialize the model file back into a sklearn model\n",
" model = joblib.load(model_path)\n",
" global name\n",
@@ -373,21 +375,22 @@
"outputs": [],
"source": [
"%%writefile C:/abc/x/y/score.py\n",
"import os\n",
"import pickle\n",
"import json\n",
"import numpy as np\n",
"from sklearn.externals import joblib\n",
"from sklearn.linear_model import Ridge\n",
"from azureml.core.model import Model\n",
"\n",
"from inference_schema.schema_decorators import input_schema, output_schema\n",
"from inference_schema.parameter_types.numpy_parameter_type import NumpyParameterType\n",
"\n",
"def init():\n",
" global model\n",
" # note here \"sklearn_regression_model.pkl\" is the name of the model registered under\n",
" # this is a different behavior than before when the code is run locally, even though the code is the same.\n",
" model_path = Model.get_model_path('sklearn_regression_model.pkl')\n",
" # AZUREML_MODEL_DIR is an environment variable created during deployment.\n",
" # It is the path to the model folder (./azureml-models/$MODEL_NAME/$VERSION)\n",
" # For multiple models, it points to the folder containing all deployed models (./azureml-models)\n",
" model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'sklearn_regression_model.pkl')\n",
" # deserialize the model file back into a sklearn model\n",
" model = joblib.load(model_path)\n",
" global name, from_location\n",
@@ -480,7 +483,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
"version": "3.6.8"
}
},
"nbformat": 4,

View File

@@ -82,7 +82,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"You can add tags and descriptions to your models. we are using `sklearn_regression_model.pkl` file in the current directory as a model with the same name `sklearn_regression_model.pkl` in the workspace.\n",
"You can add tags and descriptions to your models. we are using `sklearn_regression_model.pkl` file in the current directory as a model with the name `sklearn_regression_model_local` in the workspace.\n",
"\n",
"Using tags, you can track useful information such as the name and version of the machine learning library used to train the model, framework, category, target customer etc. Note that tags must be alphanumeric."
]
@@ -100,7 +100,7 @@
"from azureml.core.model import Model\n",
"\n",
"model = Model.register(model_path=\"sklearn_regression_model.pkl\",\n",
" model_name=\"sklearn_regression_model.pkl\",\n",
" model_name=\"sklearn_regression_model_local\",\n",
" tags={'area': \"diabetes\", 'type': \"regression\"},\n",
" description=\"Ridge regression model to predict diabetes\",\n",
" workspace=ws)"
@@ -254,21 +254,22 @@
"outputs": [],
"source": [
"%%writefile score.py\n",
"import os\n",
"import pickle\n",
"import json\n",
"import numpy as np\n",
"from sklearn.externals import joblib\n",
"from sklearn.linear_model import Ridge\n",
"from azureml.core.model import Model\n",
"\n",
"from inference_schema.schema_decorators import input_schema, output_schema\n",
"from inference_schema.parameter_types.numpy_parameter_type import NumpyParameterType\n",
"\n",
"def init():\n",
" global model\n",
" # note here \"sklearn_regression_model.pkl\" is the name of the model registered under\n",
" # this is a different behavior than before when the code is run locally, even though the code is the same.\n",
" model_path = Model.get_model_path('sklearn_regression_model.pkl')\n",
" # AZUREML_MODEL_DIR is an environment variable created during deployment.\n",
" # It is the path to the model folder (./azureml-models/$MODEL_NAME/$VERSION)\n",
" # For multiple models, it points to the folder containing all deployed models (./azureml-models)\n",
" model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'sklearn_regression_model.pkl')\n",
" # deserialize the model file back into a sklearn model\n",
" model = joblib.load(model_path)\n",
"\n",
@@ -338,6 +339,20 @@
"name": "keriehm"
}
],
"category": "tutorial",
"compute": [
"local"
],
"datasets": [],
"deployment": [
"Local"
],
"exclude_from_index": false,
"framework": [
"None"
],
"friendly_name": "Register a model and deploy locally",
"index_order": 1,
"kernelspec": {
"display_name": "Python 3.6",
"language": "python",
@@ -353,8 +368,13 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
"version": "3.6.8"
},
"star_tag": [],
"tags": [
"None"
],
"task": "Deployment"
},
"nbformat": 4,
"nbformat_minor": 2

View File

@@ -1,9 +1,9 @@
import os
import pickle
import json
import numpy as np
from sklearn.externals import joblib
from sklearn.linear_model import Ridge
from azureml.core.model import Model
from inference_schema.schema_decorators import input_schema, output_schema
from inference_schema.parameter_types.numpy_parameter_type import NumpyParameterType
@@ -11,9 +11,10 @@ from inference_schema.parameter_types.numpy_parameter_type import NumpyParameter
def init():
global model
# note here "sklearn_regression_model.pkl" is the name of the model registered under
# this is a different behavior than before when the code is run locally, even though the code is the same.
model_path = Model.get_model_path('sklearn_regression_model.pkl')
# AZUREML_MODEL_DIR is an environment variable created during deployment.
# It is the path to the model folder (./azureml-models/$MODEL_NAME/$VERSION)
# For multiple models, it points to the folder containing all deployed models (./azureml-models)
model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'sklearn_regression_model.pkl')
# deserialize the model file back into a sklearn model
model = joblib.load(model_path)

Some files were not shown because too many files have changed in this diff Show More