# Scoring a time series model #

After you save an AutoAI time series pipeline as a model, you can deploy and score the model to forecast new values\.

## Deploying a time series model ##

After you save a model to a project, follow the steps to deploy the model:

<!-- <ol> -->

1.  Find the model in the project asset list\.
2.  Promote the model to a deployment space\.
3.  Promote payload data to the deployment space\.
4.  From the deployment space, create a deployment\.

<!-- </ol> -->

## Scoring considerations ##

To this point, deploying a time series model follows the same steps as deploying a classification or regression model\. However, because of the way predictions are structured and generated in a time series model, your input must match your model structure\. For example, the way you structure your payload depends on whether you are predicting a single result (univariate) or multiple results (multivariate)\.

Note these high\-level considerations:

<!-- <ul> -->

 *  To get the first forecast window row or rows after the last row in your data, send an empty payload\.
 *  To get the next value, send the result from the empty payload request as your next scoring request, and so on\.
 *  You can send multiple rows as input, to build trends and predict the next value after a trend\.
 *  If you have multiple prediction columns, you need to include a value for each of them in your scoring request

<!-- </ul> -->

## Scoring an online deployment ##

If you create an online deployment, you can pass the payload data by using an input form or by submitting JSON code\. This example shows how to structure the JSON code to generate predictions\.

### Predicting a single value ###

In the simplest case, given this sample data, you are trying to forecast the next step of `value1` with a forecast window of 1, meaning each prediction will be a single step (row)\.

<!-- <table> -->

| timestamp         | value1 |
| ----------------- | ------ |
| 2015\-02026 21:42 | 2      |
| 2015\-02026 21:47 | 4      |
| 2015\-02026 21:52 | 6      |
| 2015\-02026 21:57 | 8      |
| 2015\-02026 22:02 | 10     |

<!-- </table ""> -->

You must pass a blank entry as the input data to request the first prediction, which is structured like this:

    {
      "input_data": [
        {
          "fields": 
            "value1"
          ],
          "values": ]
        }
      ]
    }

The output that is returned predicts the next step in the model:

    {
        "predictions": [
            {
                "fields": 
                    "prediction"
                ],
                "values": 
                    
                        12
                    ]
                ]
            }
        ]
    }

The next input passes the result of the previous output to predict the next step:

    {
      "input_data": [
        {
          "fields": 
            "value1"
          ],
          "values": 
              12]
              ]
        }
      ]
    }

### Predicting multiple values ###

In this case, you are predicting two targets, `value1` and `value2`\.

<!-- <table> -->

| timestamp         | value1 | value2 |
| ----------------- | ------ | ------ |
| 2015\-02026 21:42 | 2      | 1      |
| 2015\-02026 21:47 | 4      | 3      |
| 2015\-02026 21:52 | 6      | 5      |
| 2015\-02026 21:57 | 8      | 7      |
| 2015\-02026 22:02 | 10     | 9      |

<!-- </table ""> -->

The input data must still pass a blank entry to request the first prediction\. The next input would be structured like this:

    {
      "input_data": [
        {
          "fields": 
            "value1",
            "value2"
          ],
          "values": 
              2, 1],
              ]
        }
      ]
    }

## Predicting based on new observations ##

If instead of predicting the next row based on the prior step you want to enter new observations, enter the input data like this for a univariate model:

    {
      "input_data": [
        {
          "fields": 
            "value1"
          ],
          "values": 
              2],
              4],
              6]
              ]
        }
      ]
    }

Enter new observations like this for a multivariate model:

    {
      "input_data": [
        {
          "fields": 
            "value1",
            "value2"
          ],
          "values": 
              2, 1],
              4, 3],
              6, 5]
              ]
        }
      ]
    }

Where 2, 4, and 6 are observations for `value1` and 1, 3, 5 are observations for `value2`\.

## Scoring a time series model with Supporting features ##

After you deploy your model, you can go to the page detailing your deployment to get prediction values\. Choose one of the following ways to test your deployment:

### Using existing input values ###

You can use existing input values in your data set to obtain prediction values\. Click **Predict** to obtain a set of prediction values\. The total number of prediction values in the output is defined by prediction horizon that you previously set during the experiment configuration stage\.

### Using new input values ###

You can choose to populate the spreadsheet with new input values or use JSON code to obtain a prediction\.

#### Using spreadsheet to provide new input data for predicting values ####

To add input data to the **New observations (optional)** spreadsheet, select the **Input** tab and do one of the following:

<!-- <ul> -->

 *  Add pre\-existing \.csv file containing new observations from your local directory by clicking **Browse local files**\.
 *  Download the input file template by clicking **Download CSV template**, enter values, and upload the file\.
 *  Use an existing data asset from your project by clicking **Search in space**\.
 *  Manually enter input observations in the spreadsheet\.

<!-- </ul> -->

You can also provide future values for Supporting features if you previously enabled your experiment to leverage these values during the experiment configuration stage\. Make sure to add these values to the *Future supporting features (optional)* spreadsheet\.

#### Using JSON code to provide input data ####

To add input data using JSON code, select the **Paste JSON** tab and do one of the following:

<!-- <ul> -->

 *  Add pre\-existing JSON file containing new observations from your local directory by clicking **Browse local files**\.
 *  Use an existing data asset from your project by clicking **Search in space**\.
 *  Manually enter or paste JSON code into the editor\.

<!-- </ul> -->

In this code sample, the prediction column is `pollution`, and the supporting features are `temp` and `press`\.

    {
            "input_data": [
                    {
                            "id": "observations",
                            "values": 
                                    
                                            96.125,
                                            3.958,
                                            1026.833
                                    ]
                            ]
                    },
                    {
                            "id": "supporting_features",
                            "values": 
                                    
                                            3.208,
                                            1020.667
                                    ]
                            ]
                    }
            ]
    }

## Next steps ##

[Saving an AutoAI generated notebook (Watson Machine Learning)](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/autoai-notebook.html)

**Parent topic:**[Building a time series experiment](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/autoai-timeseries.html)

<!-- </article "role="article" "> -->