diff --git a/sdk/python/jobs/automl-standalone-jobs/automl-forecasting-task-energy-demand/mlflow-model-local-inference-test.ipynb b/sdk/python/jobs/automl-standalone-jobs/automl-forecasting-task-energy-demand/mlflow-model-local-inference-test.ipynb
index 6d18fbf711a..cd23f719301 100644
--- a/sdk/python/jobs/automl-standalone-jobs/automl-forecasting-task-energy-demand/mlflow-model-local-inference-test.ipynb
+++ b/sdk/python/jobs/automl-standalone-jobs/automl-forecasting-task-energy-demand/mlflow-model-local-inference-test.ipynb
@@ -5,103 +5,52 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# Load the MLFlow model locally and try predictions\n",
+ "# MLflow model local inference example\n",
"\n",
- "## Prerequisites\n",
+ "Test the model locally by loading it and generating predictions.\n",
"\n",
- "1. You need to have run successfully the training notebook related to this model, available in this same folder, where at the end of the notebook, after training the model, it downloads the 'artifacts' with the MLFlow model folder (\"./artifact_downloads/outputs/mlflow-model\").\n",
- "\n",
- "2. Create a conda environment with the 'conda.yaml' file provided within the \"mlflow-model\" folder, doing like the following:\n",
- "\n",
- " 1. (base) /> conda env create --file conda.yaml --name automl-model-classification-env\n",
- " \n",
- " 1. (base) /> conda activate automl-model-classification-env\n",
- " \n",
- " 1. (automl-model-classification-env) /> conda install jupyter nb_conda\n",
- "\n",
- "3. Run Jupyter and make sure you are using the related 'automl-model-classif-env' Kernel.\n",
- "\n",
- "4. Run this notebook."
+ "---"
]
},
{
- "attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
- "If the MLFlow model files were downloaded successfully by the training notebook, you should see the files here."
+ "## Prerequisites"
]
},
{
- "cell_type": "code",
- "execution_count": 1,
+ "cell_type": "markdown",
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "['conda.yaml', 'MLmodel', 'model.pkl', 'requirements.txt']"
- ]
- },
- "execution_count": 1,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
"source": [
- "import os\n",
- "\n",
- "# Show the contents of the MLFlow model folder\n",
- "os.listdir(\"./artifact_downloads/outputs/mlflow-model\")\n",
- "\n",
- "# You should see a list of files such as the following:\n",
- "# ['conda.yaml', 'MLmodel', 'model.pkl', 'requirements.txt']"
+ "1. **Model**
\n",
+ " We will need the MLflow model, which is downloaded at the end of the training notebook. Follow any training notebook to get the model. The MLflow model is usually downloaded to the folder: `./artifact_downloads/outputs/mlflow-model`.\n",
+ "2. **Environment**
\n",
+ " We will need environment to load the model. Please run the following commands to create the environment (the conda file is usually downloaded to: `./artifact_downloads/outputs/mlflow-model/conda.yaml`):\n",
+ " - `conda env create --file `\n",
+ " - `conda activate project_environment`\n",
+ "3. **Register environment as kernel**
\n",
+ " - Please run the following command to register the environment as a kernel: `python -m ipykernel install --user --name project_environment --display-name \"model-inference\"`\n",
+ " - Refresh kernel and then select the newly created kernel named `model-inference` in kernel drop down.\n",
+ "\n",
+ "Now we are good to run this notebook in the newly created kernel."
]
},
{
- "attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Load the test data into a Pandas DataFrame\n",
- "\n",
- "Load a test dataset (bank_marketing_test_data.csv) into a Pandas DataFrame in order to try some predictions with it."
+ "## Load the test data into a Pandas DataFrame"
]
},
{
"cell_type": "code",
- "execution_count": 21,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "((875, 3), (875,))"
- ]
- },
- "execution_count": 21,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "import pandas as pd\n",
- "\n",
- "test_df = pd.read_csv(\n",
- " \"./data/test-mltable-folder/nyc_energy_test_clean.csv\"\n",
- ").reset_index(drop=True)\n",
- "y_actual = test_df.pop(\"demand\").values\n",
- "\n",
- "test_df.shape, y_actual.shape"
- ]
- },
- {
- "attachments": {},
- "cell_type": "markdown",
+ "execution_count": null,
"metadata": {},
+ "outputs": [],
"source": [
- "To use TabularDataset created in V1 sdk as a test data on the batch end point inference we need to convert it to V2 Input.\n",
- "To run the following cell, remove `\"\"\"` at start and end."
+ "test_data_path = \"./data/test-mltable-folder/nyc_energy_test_clean.csv\"\n",
+ "label_column_name = \"demand\""
]
},
{
@@ -110,543 +59,71 @@
"metadata": {},
"outputs": [],
"source": [
- "\"\"\"\n",
- "from mltable import load\n",
- "filedataset_asset = ml_client.data.get(name=\"nyc_energy_test\",version=1)\n",
- "test_df = load(f\"azureml:/{filedataset_asset.id}\").to_pandas_dataframe().reset_index(drop=True)\n",
- "y_actual = test_df.pop(\"demand\").values\n",
+ "import pandas as pd\n",
+ "\n",
+ "test_df = pd.read_csv(test_data_path).reset_index(drop=True)\n",
+ "y_actual = test_df.pop(label_column_name).values\n",
"\n",
- "test_df.shape, y_actual.shape\n",
- "\"\"\""
+ "test_df.shape, y_actual.shape"
]
},
{
- "attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Load the best model in memory\n",
- "\n",
- "Load the model using MLflow flavor. Check MLmodel under the downloaded folder (artifact_downloads/outputs/mlflow-model).\n",
- "For this particular example (and for AutoML tabular scenario except for forecast tcn which has Pytorch flavor), MLmodel file will describe two flavors, sklearn and python_function.\n",
- "We show how to load model using sklearn for forecast models, which predict with .forecast() and .forecast_quantiles().\n",
- "For more information on MLflow flavors, visit: https://www.mlflow.org/docs/latest/models.html#storage-format\n",
- "\n",
- "Loading the models locally assume that you are running the notebook in an environment compatible with the model. The list of dependencies that is expected by the model is specified in the MLflow model produced by AutoML (in the 'conda.yaml' file within the mlflow-model folder).\n",
- "\n",
- "Load the model using MLFlow PyFunc:"
+ "## Load the MLflow model"
]
},
{
- "cell_type": "code",
- "execution_count": 22,
+ "cell_type": "markdown",
"metadata": {},
- "outputs": [],
"source": [
- "import mlflow.pyfunc\n",
- "import mlflow.sklearn"
+ "- `MLmodel` file (`./artifact_downloads/outputs/mlflow-model/MLmodel`) generally describes the following two flavors for AutoML tabular scenario, except forecast TCN that has Pytorch flavor:\n",
+ " - sklearn\n",
+ " - python_function\n",
+ "- We show how to load model using sklearn for forecasting, which generates prediction using either `forecast` or `forecast_quantiles` method.\n",
+ "\n",
+ "For more information on MLflow flavors, please visit [this link](https://www.mlflow.org/docs/latest/models.html#storage-format)."
]
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
- "# Get the MLFlow model from the downloaded MLFlow model files\n",
- "\n",
- "model = mlflow.sklearn.load_model(\"./artifact_downloads/outputs/mlflow-model\")"
+ "mlflow_dir = \"./artifact_downloads/outputs/mlflow-model\""
]
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": 22,
"metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "C:\\ProgramData\\Miniconda3\\envs\\automl-model-classif-env\\lib\\site-packages\\azureml\\automl\\runtime\\shared\\model_wrappers.py:4074: UserWarning: Actual values are present for all times in the input dataframe - there is nothing to forecast. Please set 'y' values to np.NaN for times where you need a forecast.\n",
- " warnings.warn(error.error_message)\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "(array([ nan, nan, nan, nan, nan, nan,\n",
- " nan, nan, nan, nan, nan, nan,\n",
- " 5216.917, 4968.842, 4706.283, 4477.242, 4314.367, 4233.333,\n",
- " 4207.042, 4254.458, 4367.075, 4519.1 , 4776.7 , 5057.075,\n",
- " 5269.592, 5426.208, 5511.033, 5557.25 , 5526.233, 5502.408,\n",
- " 5522.642, 5584.158, 5643.492, 5725.4 , 5720.867, 5578.958,\n",
- " 5330.483, 4996.2 , 4696.283, 4487.033, 4357.758, 4293.558,\n",
- " 4327.783, 4560.142, 5088.309, 5641.708, 6023.925, 6285.1 ,\n",
- " 6442.95 , 6468.317, 6396.35 , 6341.342, 6293.525, 6241.8 ,\n",
- " 6240.008, 6224.3 , 6061.483, 6069.358, 6047.717, 5831.95 ,\n",
- " 5481.925, 5046.367, 4661.783, 4416.808, 4280.475, 4204.833,\n",
- " 4233.867, 4481.325, 5003.483, 5579.408, 5942.25 , 6171.858,\n",
- " 6287.692, 6384.317, 6411.85 , 6425.308, 6392.992, 6387.5 ,\n",
- " 6384.6 , 6428.933, 6358.325, 6292.675, 6172.633, 5922.9 ,\n",
- " 5554.017, 5114.008, 4720.575, 4472.2 , 4317.442, 4263.092,\n",
- " 4284. , 4495.783, 5016.842, 5579.608, 5924.008, 6161.3 ,\n",
- " 6201.483, 6155.008, 6117.475, 6088.475, 6043.267, 6037.017,\n",
- " 6049.417, 6038.383, 5929.558, 5933.917, 5946.617, 5757.333,\n",
- " 5439.375, 5048.967, 4677.975, 4438.342, 4292.475, 4233.642,\n",
- " 4257.975, 4492.092, 4999.792, 5543.767, 5862.833, 6085.575,\n",
- " 6136.508, 6153.5 , 6113.967, 6097.05 , 6081.55 , 6105.117,\n",
- " 6167.542, 6191.883, 6135.792, 6109.375, 6002.883, 5796. ,\n",
- " 5469.592, 5074.558, 4690.233, 4446.7 , 4316.658, 4259.725,\n",
- " 4289.125, 4513.717, 5034.75 , 5607.842, 5985.35 , 6278.925,\n",
- " 6408.258, 6474.283, 6513.508, 6503.817, 6488.75 , 6506.875,\n",
- " 6506.617, 6495.583, 6390.075, 6320.242, 6154.183, 5912.775,\n",
- " 5662.15 , 5309.208, 4939.208, 4701.6 , 4543.967, 4444.892,\n",
- " 4405.083, 4448.675, 4604.375, 4849.483, 5151.517, 5413.308,\n",
- " 5576.975, 5631.35 , 5657.683, 5610.242, 5567.325, 5523.908,\n",
- " 5473.933, 5467. , 5478.633, 5547.2 , 5587.542, 5487.125,\n",
- " 5294.958, 5051.942, 4755.275, 4526.217, 4364.408, 4273.467,\n",
- " 4236.825, 4263.533, 4373.767, 4504.783, 4708.058, 4915.575,\n",
- " 5075.442, 5171.242, 5176.575, 5157.258, 5117.425, 5106.55 ,\n",
- " 5104.367, 5145.092, 5178.983, 5322.133, 5465.283, 5355.083,\n",
- " 5116.458, 4801.375, 4489.075, 4281.383, 4149.492, 4096.525,\n",
- " 4138.55 , 4376.033, 4868.967, 5391.225, 5744. , 5961.375,\n",
- " 6007.808, 6029.092, 6022.575, 6018.8 , 5985.95 , 5972.083,\n",
- " 5987.833, 5982.792, 5932.108, 5951.267, 5912.167, 5688.892,\n",
- " 5320.35 , 4906.658, 4524.858, 4298.258, 4166.867, 4128.975,\n",
- " 4138.858, 4349.117, 4870.958, 5430.142, 5800.633, 6067.517,\n",
- " 6160.808, 6210.742, 6201.6 , 6223.625, 6198.675, 6206.608,\n",
- " 6177.367, 6153.975, 6052.417, 6036.325, 5947.683, 5726.327,\n",
- " 5382.133, 4939.55 , 4554.658, 4305.517, 4166.95 , 4102.433,\n",
- " 4128.008, 4354.408, 4882.367, 5449.55 , 5791.033, 6012.258,\n",
- " 6087.058, 6122.292, 6114.667, 6057.733, 6005.467, 5998.917,\n",
- " 6041.492, 6028.833, 5894.117, 5893.733, 5890.233, 5696.9 ,\n",
- " 5356.325, 4960.075, 4566.517, 4321.417, 4167.167, 4104.442,\n",
- " 4129.283, 4352.367, 4909.633, 5487.258, 5897.683, 6166.275,\n",
- " 6328.592, 6382.417, 6442.042, 6425.992, 6338.8 , 6361.125,\n",
- " 6459.067, 6395.308, 6116.342, 6043.025, 6006.167, 5791.35 ,\n",
- " 5471.025, 5026.808, 4656.758, 4388.133, 4218.925, 4157.2 ,\n",
- " 4160.683, 4397.475, 4895.433, 5436.917, 5838.242, 6097.258,\n",
- " 6197.908, 6220.517, 6215.283, 6173.817, 6125.092, 6151.533,\n",
- " 6163.55 , 6147.2 , 6018.292, 5974.975, 5904.725, 5736.342,\n",
- " 5480.917, 5134.8 , 4785.95 , 4542.15 , 4382.675, 4287.892,\n",
- " 4249.717, 4300.908, 4460.308, 4667.05 , 4929.183, 5139.692,\n",
- " 5281.175, 5347. , 5345.667, 5305.875, 5229.042, 5188.308,\n",
- " 5155.158, 5158.883, 5182.908, 5266.708, 5366.225, 5287.608,\n",
- " 5126.208, 4863.75 , 4601.2 , 4374.558, 4217.183, 4114.225,\n",
- " 4063.667, 4092.167, 4191.992, 4328.358, 4539.108, 4747.308,\n",
- " 4900.3 , 4991.367, 5015.35 , 5008.425, 5013.2 , 4995.1 ,\n",
- " 5008.458, 5030.725, 5075.308, 5200.575, 5337.825, 5253.092,\n",
- " 5041.783, 4729.192, 4431.433, 4224.175, 4088.833, 4034.842,\n",
- " 4052.333, 4245.7 , 4687.067, 5178.275, 5562.45 , 5829.975,\n",
- " 5931.867, 6020.783, 6057.442, 6083.525, 6083.542, 6092.3 ,\n",
- " 6127.1 , 6099.425, 5917.3 , 5824.825, 5824.108, 5632.192,\n",
- " 5327.783, 4929.317, 4556.967, 4308.975, 4153.983, 4081.908,\n",
- " 4080.983, 4254.708, 4685.283, 5190.158, 5611.992, 5887.55 ,\n",
- " 6013.317, 6117.767, 6218.667, 6296.133, 6299.617, 6318.083,\n",
- " 6344.542, 6308.892, 6049.667, 5944.9 , 5903.475, 5700.775,\n",
- " 5391.9 , 4998.183, 4638.375, 4401.358, 4226.375, 4135.733,\n",
- " 4130.517, 4302.583, 4727.45 , 5230.158, 5700.992, 6006.708,\n",
- " 6156.725, 6257.2 , 6285.167, 6277.375, 6250.517, 6272.233,\n",
- " 6296.775, 6309.1 , 6108.858, 5977.892, 5934.3 , 5731.842,\n",
- " 5395.592, 4992.525, 4590.9 , 4295.608, 4123.2 , 4027.375,\n",
- " 4025.55 , 4189.625, 4591.292, 5077.025, 5501.525, 5729.025,\n",
- " 5848.783, 5868.617, 5880.692, 5879.658, 5876.867, 5894.808,\n",
- " 5924.383, 5903.2 , 5752.625, 5661.8 , 5631.75 , 5455.258,\n",
- " 5183.675, 4819.967, 4469.092, 4223.567, 4060.217, 3989.325,\n",
- " 3982.075, 4133.367, 4493.567, 4920.625, 5285.9 , 5536.492,\n",
- " 5618.033, 5658.342, 5704.8 , 5677.392, 5665.8 , 5650.642,\n",
- " 5677.567, 5647.458, 5514.283, 5445.392, 5440.783, 5289.958,\n",
- " 5070.917, 4759.792, 4453.517, 4227.417, 4076.425, 3988.342,\n",
- " 3961.85 , 3991.408, 4110.008, 4306. , 4550.467, 4784.842,\n",
- " 4950.058, 5046.008, 5079.175, 5059.633, 5026.825, 5015.575,\n",
- " 5014.283, 5054.258, 5098.118, 5172.575, 5194.408, 5092.15 ,\n",
- " 4936.025, 4704.617, 4442.392, 4223.942, 4073.467, 3967.342,\n",
- " 3922.742, 3950.383, 4014.108, 4172.717, 4419.675, 4681.667,\n",
- " 4915.517, 5114.375, 5232.875, 5308.142, 5358.2 , 5382.092,\n",
- " 5387.483, 5379.667, 5436.1 , 5477.558, 5581.3 , 5519.067,\n",
- " 5281.842, 4997.009, 4696.6 , 4480.225, 4338.658, 4263.125,\n",
- " 4276.917, 4473.217, 4885.583, 5433.733, 5885.792, 6108.417,\n",
- " 6165.442, 6203.033, 6234.083, 6242.217, 6234.925, 6237.325,\n",
- " 6263.958, 6214.708, 6030.192, 5892.342, 5832.108, 5623.092,\n",
- " 5324.617, 4911.692, 4501.333, 4249.75 , 4088.975, 4008.85 ,\n",
- " 4014.858, 4198.083, 4606.433, 5095.233, 5513.883, 5744.808,\n",
- " 5838.95 , 5896.358, 5938.008, 5971.217, 5970.767, 5972.783,\n",
- " 5969.808, 5929.283, 5771.55 , 5687.958, 5727.775, 5557.133,\n",
- " 5236.275, 4821.483, 4446.183, 4188.733, 4040.917, 3967.975,\n",
- " 3981.758, 4173.975, 4669.783, 5207.625, 5590.108, 5844.492,\n",
- " 5927.4 , 5947.017, 5952.808, 5953.5 , 5925.708, 5953.117,\n",
- " 6061.042, 6108.508, 6004.267, 5911.717, 5828.675, 5626.133,\n",
- " 5292.325, 4867.267, 4479.642, 4226.392, 4081.892, 4009.608,\n",
- " 4021.75 , 4221.425, 4726.083, 5325.683, 5733.233, 5952.092,\n",
- " 6033.517, 6044.858, 6038.392, 6038.625, 6044.417, 6057.8 ,\n",
- " 6108.158, 6096.692, 5923.667, 5827.458, 5768.667, 5561.092,\n",
- " 5243.983, 4856.792, 4461.025, 4215.533, 4085.833, 4011.283,\n",
- " 4015.767, 4203.875, 4687.358, 5265.208, 5638.458, 5898.05 ,\n",
- " 6019.475, 6065.267, 6048.708, 6057.225, 6009.417, 6004.367,\n",
- " 5997.45 , 5972.667, 5825.108, 5759.925, 5695.658, 5519.492,\n",
- " 5261.992, 4570.083, 4318.967, 4149.383, 4057.783, 4026.4 ,\n",
- " 4077.258, 4201.1 , 4450.133, 4734.658, 5006.433, 5165.933,\n",
- " 5227.875, 5272.383, 5274.3 , 5283.442, 5249.275, 5250.308,\n",
- " 5271.517, 5262.7 , 5282.05 , 5328.983, 5216.592, 5043. ,\n",
- " 4780.733, 4492.008, 4259.667, 4091.183, 3999.958, 3957.408,\n",
- " 3990.033, 4055.133, 4203.283, 4439.55 , 4643.158, 4808.358,\n",
- " 4930.292, 4949.792, 4968.142, 4977.417, 4969.792, 4975.117,\n",
- " 5012.208, 5047.425, 5125.183, 5297.492, 5222.683, 4977.017,\n",
- " 4652.242, 4345.833, 4124.542, 4004.325, 3944.992, 3975.308,\n",
- " 4207.475, 4681.383, 5238.917, 5596.583, 5801.408, 5909.858,\n",
- " 5950.542, 5990.2 , 5982.217, 5962.075, 5968.55 , 5987.242,\n",
- " 5968.392, 5838.892, 5800.083, 5769.533, 5559.958, 5232.45 ,\n",
- " 4804.725, 4437.458, 4204.95 , 4067.783, 4000.233, 4023.758,\n",
- " 4237.767, 4729.225, 5306.825, 5709.75 , 5948.5 , 6052.442,\n",
- " 6116.658, 6130.992, 6149.925, 6113.6 , 6118.075, 6160. ,\n",
- " 6179.483, 6063.692, 5977.625, 5906.167, 5687.375, 5338.333,\n",
- " 4898.758, 4500.167, 4264.883, 4113.792, 4045.15 , 4049.967,\n",
- " 4253.808, 4773.967, 5359.75 , 5756.825, 5975.608, 6077.158,\n",
- " 6125.618, 6109.983, 6122.417, 6107.717, 6115.292, 6033.067,\n",
- " 5960.75 , 5895.233, 5653.333, 5329.917, 4914.725, 4509.875,\n",
- " 4248.592, 4110.45 , 4047.092, 4042.65 , 4242.767, 4752.867,\n",
- " 5374.742, 5783.717, 6061.567, 6104.433, 6180.292, 6237.827,\n",
- " 6242.367, 6231.442, 6264.533, 6266.1 , 6233.008, 6053.592,\n",
- " 5954.35 , 5867.942, 5653.05 , 5313.292, 4914.083, 4511.792,\n",
- " 4259.592, 4109.833, 4042.667, 4062.667, 4253.95 , 4749.142,\n",
- " 5330.5 , 5770.292, 6084.2 , 6260.642, 6424.983, 6544.6 ,\n",
- " 6638.05 , 6674.858, 6732.575, 6776.7 , 6711.95 , 6432.117,\n",
- " 6219. , 6127.767, 5936.567, 5646.283, 5275.175, 4894.267,\n",
- " 4633.217, 4452.317, 4350.992, 4294.667, 4327.142, 4447.575,\n",
- " 4698.792, 5066.208, 5394.775, 5761.125, 6017.458, 6116.375,\n",
- " 6170.817, 6213.333, 6268.008, 6276.95 , 6211.217, 6155.167,\n",
- " 6088.033, 6117.8 , 6015.442, 5784.908, 5454.85 , 5068.067,\n",
- " 4742.225, 4499.775, 4345.483, 4249.583, 4228.875, 4219.942,\n",
- " 4345.725, 4574.8 , 4810.742, 5000.792, 5115.392, 5185.317,\n",
- " 5170.55 , 5129.883, 5121.292, 5135.025, 5152.583, 5198.733,\n",
- " 5223.075, 5288.958, 5190.033, 4935.9 , 4610.158]),\n",
- " _automl_target_col_WASNULL \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 0.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 0.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 0.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 0.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 0.00 \n",
- " \n",
- " horizon_origin \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 1.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 1.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 1.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 1.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 1.00 \n",
- " \n",
- " precip \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 0.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 0.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 0.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 0.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 0.00 \n",
- " \n",
- " precip_WASNULL \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 0.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 0.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 0.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 0.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 0.00 \n",
- " \n",
- " temp \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 53.83 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 52.71 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 52.52 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 52.78 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 51.94 \n",
- " \n",
- " temp_WASNULL \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 0.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 0.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 0.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 0.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 0.00 \n",
- " \n",
- " _automl_target_col_lag12H \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 4345.73 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 4574.80 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 4810.74 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 5000.79 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 5115.39 \n",
- " \n",
- " _automl_target_col_min_window4H \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 5121.29 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 5135.02 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 5152.58 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 5190.03 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 4935.90 \n",
- " \n",
- " _automl_target_col_max_window4H \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 5198.73 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 5223.07 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 5288.96 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 5288.96 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 5288.96 \n",
- " \n",
- " _automl_target_col_mean_window4H \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 5151.91 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 5177.35 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 5215.84 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 5225.20 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 5159.49 \n",
- " \n",
- " ... \\\n",
- " timeStamp _automl_dummy_grain_col origin ... \n",
- " 2017-03-25 10:00:00 NaN NaT ... \n",
- " 2017-03-25 11:00:00 NaN NaT ... \n",
- " 2017-03-25 12:00:00 NaN NaT ... \n",
- " 2017-03-25 13:00:00 NaN NaT ... \n",
- " 2017-03-25 14:00:00 NaN NaT ... \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 ... \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 ... \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 ... \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 ... \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 ... \n",
- " \n",
- " _automl_quarter \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 2.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 2.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 2.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 2.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 2.00 \n",
- " \n",
- " _automl_month \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 4.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 4.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 4.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 4.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 4.00 \n",
- " \n",
- " _automl_day \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 30.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 30.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 30.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 30.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 30.00 \n",
- " \n",
- " _automl_hour \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 19.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 20.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 21.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 22.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 23.00 \n",
- " \n",
- " _automl_am_pm \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 1.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 1.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 1.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 1.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 1.00 \n",
- " \n",
- " _automl_hour12 \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 7.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 8.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 9.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 10.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 11.00 \n",
- " \n",
- " _automl_wday \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 6.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 6.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 6.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 6.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 6.00 \n",
- " \n",
- " _automl_qday \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 30.00 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 30.00 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 30.00 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 30.00 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 30.00 \n",
- " \n",
- " _automl_week \\\n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT \n",
- " 2017-03-25 11:00:00 NaN NaT \n",
- " 2017-03-25 12:00:00 NaN NaT \n",
- " 2017-03-25 13:00:00 NaN NaT \n",
- " 2017-03-25 14:00:00 NaN NaT \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 17 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 17 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 17 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 17 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 17 \n",
- " \n",
- " _automl_target_col \n",
- " timeStamp _automl_dummy_grain_col origin \n",
- " 2017-03-25 10:00:00 NaN NaT nan \n",
- " 2017-03-25 11:00:00 NaN NaT nan \n",
- " 2017-03-25 12:00:00 NaN NaT nan \n",
- " 2017-03-25 13:00:00 NaN NaT nan \n",
- " 2017-03-25 14:00:00 NaN NaT nan \n",
- " ... ... \n",
- " 2017-04-30 19:00:00 _automl_dummy_grain_col 2017-04-30 18:00:00 5223.07 \n",
- " 2017-04-30 20:00:00 _automl_dummy_grain_col 2017-04-30 19:00:00 5288.96 \n",
- " 2017-04-30 21:00:00 _automl_dummy_grain_col 2017-04-30 20:00:00 5190.03 \n",
- " 2017-04-30 22:00:00 _automl_dummy_grain_col 2017-04-30 21:00:00 4935.90 \n",
- " 2017-04-30 23:00:00 _automl_dummy_grain_col 2017-04-30 22:00:00 4610.16 \n",
- " \n",
- " [875 rows x 22 columns])"
- ]
- },
- "execution_count": 26,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "outputs": [],
"source": [
- "# Forecasting models predict with .forecast() or .forecast_quantiles(), not with .predict()\n",
- "\n",
- "y_preds = model.forecast(test_df, ignore_data_errors=True)\n",
- "\n",
- "y_preds\n",
+ "import mlflow.pyfunc\n",
+ "import mlflow.sklearn\n",
"\n",
- "# Original forecasting with .forecast_quantiles(X_test)\n",
- "# https://github.com/Azure/azureml-examples/blob/main/python-sdk/tutorials/automl-with-azureml/forecasting-energy-demand/forecasting_script.py"
+ "model = mlflow.sklearn.load_model(mlflow_dir)"
]
},
{
- "attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
- "# Next Steps\n",
- "You can see further examples of other AutoML tasks such as Image-Classification, Image-Object-Detection, NLP-Text-Classification, Time-Series-Forcasting, etc."
+ "## Generate predictions"
]
},
{
- "attachments": {},
- "cell_type": "markdown",
+ "cell_type": "code",
+ "execution_count": null,
"metadata": {},
- "source": []
+ "outputs": [],
+ "source": [
+ "# Forecasting models generates prediction with .forecast() or .forecast_quantiles(), not with .predict()\n",
+ "y_preds = model.forecast(test_df, ignore_data_errors=True)\n",
+ "y_preds"
+ ]
}
],
"metadata": {