---
title: Time series
description: Outlines how to set up batch predictions for time series models. Includes settings details and code examples.

---

# Time series {: #time-series }

Batch predictions for time series models work without any additional configuration. However, in most cases you need to either modify the default configuration or prepare the prediction dataset.

!!! note
    Time series batch predictions are not generally available for cross-series projects or traditional time series models (such as ARIMA); however, this functionality is available as a  [public preview](pp-ts-tts-lstm-batch-pred) feature.

## Time series batch prediction settings {: #time-series-batch-prediction-settings }

The default configuration can be overridden using the `timeseriesSettings` job configuration property:

|Parameter |Example| Description |
|------------|------------|-----------------|
|  `type` |  `forecast` |   Must be either `forecast` (default) or `historical`. |
|  `forecastPoint` |  `2019-02-04T00:00:00Z`  |   Optional. By default, DataRobot infers the forecast point from the dataset. To configure, `type` must be set to `forecast`.|
|  `predictionsStartDate`  |  `2019-01-04T00:00:00Z` |   Optional. By default, DataRobot infers the start date from the dataset. To configure, `type` must be set to `historical`.|
|  `predictionsEndDate` |  `2019-02-04T00:00:00Z`  |   Optional. By default, DataRobot infers the end date from the dataset. To configure, `type` must be set to `historical`. |
|`relaxKnownInAdvanceFeaturesCheck`| `false` |  Optional. If activated, missing values in the known in advance features are allowed in the forecast window at prediction time. If omitted or `false`, missing values are not allowed. Default: `false`.   |


Here is a complete example job:

```json
{
    "deploymentId": "5f22ba7ade0f435ba7217bcf",
    "intakeSettings": {"type": "localFile"},
    "outputSettings": {"type": "localFile"},
    "timeseriesSettings": {
        "type": "historical",
        "predictionsStartDate": "2020-01-01",
        "predictionsEndDate": "2020-03-31"
    }
}
```

An example using Python SDK:

```python
import datarobot as dr

dr.Client(
    endpoint="https://app.datarobot.com/api/v2",
    token="...",
)

deployment_id = "..."

input_file = "to_predict.csv"
output_file = "predicted.csv"

job = dr.BatchPredictionJob.score_to_file(
    deployment_id,
    input_file,
    output_file,
    timeseries_settings={
        "type": "historical",
        "predictions_start_date": "2020-01-01",
        "predictions_end_date": "2020-03-31",
    },
)

print("started scoring...", job)
job.wait_for_completion()
```


## Prediction type {: #prediction-type }

When using `forecast` mode, DataRobot makes predictions using `forecastPoint` or rows in the dataset without a target. In `historical` mode, DataRobot enables bulk predictions, which calculates predictions for all possible forecast points and forecast distances within `predictionsStartDate` and `predictionsEndDate` range.

## Requirements for the scoring dataset {: #requirements-for-the-scoring-dataset }

To ensure the Batch Prediction API can process your time series dataset, you must configure the following:

* Sort prediction rows by their timestamps, with the earliest row first.
    * If using multiseries, the prediction rows must be sorted by series ID then timestamp.
* There is **no limit** on the number of series DataRobot supports. The only limit is the job timeout as mentioned in [Limits](batch-prediction-api/index#limits).

### Single series forecast dataset example {: #single-series-forecast-dataset-example }

The following is an example forecast dataset for a single series:

<table>
  <tr>
    <th>date</th>
    <th>y</th>
  </tr>
  <tr>
    <td>2020-01-01</td>
    <td>9342.85</td>
  </tr>
  <tr>
    <td>2020-01-02</td>
    <td>4951.33</td>
  </tr>
  <tr>
    <td colspan="2" align="center"><i>24 more historical rows</i></td>
  </tr>
  <tr>
    <td>2020-01-27</td>
    <td>4180.92</td>
  </tr>
  <tr>
    <td>2020-01-28</td>
    <td>5943.11</td>
  </tr>
  <tr>
    <td>2020-01-29</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-01-30</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-01-31</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-01</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-02</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-03</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-04</td>
    <td></td>
  </tr>
</table>

### Multiseries forecast dataset example {: #multiseries-forecast-dataset-example }

If scoring multiple series, the data must be ordered by series and timestamp:

<table>
  <tr>
    <th>date</th>
    <th>series</th>
    <th>y</th>
  </tr>
  <tr>
    <td>2020-01-01</td>
    <td>A</td>
    <td>9342.85</td>
  </tr>
  <tr>
    <td>2020-01-02</td>
    <td>A</td>
    <td>4951.33</td>
  </tr>
  <tr>
    <td colspan="3" align="center"><i>24 more historical rows</i></td>
  </tr>
  <tr>
    <td>2020-01-27</td>
    <td>A</td>
    <td>4180.92</td>
  </tr>
  <tr>
    <td>2020-01-28</td>
    <td>A</td>
    <td>5943.11</td>
  </tr>
  <tr>
    <td>2020-01-29</td>
    <td>A</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-01-30</td>
    <td>A</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-01-31</td>
    <td>A</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-01</td>
    <td>A</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-02</td>
    <td>A</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-03</td>
    <td>A</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-04</td>
    <td>A</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-01-01</td>
    <td>B</td>
    <td>8477.22</td>
  </tr>
  <tr>
    <td>2020-01-02</td>
    <td>B</td>
    <td>7210.29</td>
  </tr>
  <tr>
    <td colspan="3" align="center"><i>24 more historical rows</i></td>
  </tr>
  <tr>
    <td>2020-01-27</td>
    <td>B</td>
    <td>7400.21</td>
  </tr>
  <tr>
    <td>2020-01-28</td>
    <td>B</td>
    <td>8844.71</td>
  </tr>
  <tr>
    <td>2020-01-29</td>
    <td>B</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-01-30</td>
    <td>B</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-01-31</td>
    <td>B</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-01</td>
    <td>B</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-02</td>
    <td>B</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-03</td>
    <td>B</td>
    <td></td>
  </tr>
  <tr>
    <td>2020-02-04</td>
    <td>B</td>
    <td></td>
  </tr>
</table>
