|
| 1 | +# Time Series Forecasting with Pretrained Models |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Oracle AI Quick Actions now support hosting and using pretrained time-series forecasting models with a few clicks. As |
| 6 | +part of this, we’ve added support for the Granite-TimeSeries TTM (TinyTimeMixer) model, which offers lightweight, |
| 7 | +high-accuracy forecasting for multivariate time series data. This is the first of several pretrained models we aim to |
| 8 | +support through our AI Quick Actions interface. |
| 9 | + |
| 10 | +Granite TTM provides state-of-the-art performance in zero-shot scenarios and is especially well-suited for short-to-mid |
| 11 | +range forecasting on CPU-only environments. |
| 12 | + |
| 13 | +## Deploying the Model using AI Quick Action |
| 14 | + |
| 15 | +Users can navigate to the **AI Quick Actions UI** and select **Model Explorer**. From there, select |
| 16 | +`granite-timeseries-ttm-r1` from the provided models and then click **"Deploy"**. Once deployed, an endpoint URL will be |
| 17 | +provided for invoking predictions via a REST API. |
| 18 | +The deployment handles model loading, environment setup, and endpoint exposure automatically. |
| 19 | + |
| 20 | +## Request Payload Structure |
| 21 | + |
| 22 | +| Key | Type | Required | Description | |
| 23 | +|------------------|---------------|----------|-----------------------------------------------------------------------------------------------------------------------------| |
| 24 | +| historical_data | object | Yes | Dictionary representing historical data | |
| 25 | +| timestamp_format | string | No | Format of the timestamp values in the timestamp_column e.g. "%Y-%m-%d %H:%M:%S" | |
| 26 | +| timestamp_column | string | Yes | Name of the datetime column | |
| 27 | +| target_columns | array[string] | Yes | Columns to be predicted | |
| 28 | +| id_columns | array[string] | No | List of column names which identify different time series in a multi-time series input (For multi-series forecast use case) | |
| 29 | + |
| 30 | +### Example Payload For Single Time Series Forecast (without id_columns) |
| 31 | + |
| 32 | +```json |
| 33 | +{ |
| 34 | +"historical_data": |
| 35 | + { |
| 36 | + "instant": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], |
| 37 | + "dteday": ["2011-01-01 00:00:00", "2011-01-01 01:00:00", "2011-01-01 02:00:00", "2011-01-01 03:00:00", "2011-01-01 04:00:00", |
| 38 | + "2011-01-01 05:00:00", "2011-01-01 06:00:00", "2011-01-01 07:00:00", "2011-01-01 08:00:00", "2011-01-01 09:00:00", |
| 39 | + "2011-01-01 10:00:00", "2011-01-01 11:00:00", "2011-01-01 12:00:00", "2011-01-01 13:00:00", "2011-01-01 14:00:00"], |
| 40 | + "season": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], |
| 41 | + "yr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
| 42 | + "mnth": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], |
| 43 | + "hr": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], |
| 44 | + "holiday": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
| 45 | + "weekday": [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6], |
| 46 | + "workingday": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
| 47 | + "weathersit": [1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2], |
| 48 | + "temp": [0.24, 0.22, 0.22, 0.24, 0.24, 0.24, 0.22, 0.2, 0.24, 0.32, 0.38, 0.36, 0.42, 0.46, 0.46], |
| 49 | + "atemp": [0.2879, 0.2727, 0.2727, 0.2879, 0.2879, 0.2576, 0.2727, 0.2576, 0.2879, 0.3485, 0.3939, 0.3333, 0.4242, 0.4545, 0.4545], |
| 50 | + "hum": [0.81, 0.8, 0.8, 0.75, 0.75, 0.75, 0.8, 0.86, 0.75, 0.76, 0.76, 0.81, 0.77, 0.72, 0.72], |
| 51 | + "windspeed": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0896, 0.0, 0.0, 0.0, 0.0, 0.2537, 0.2836, 0.2836, 0.2985, 0.2836], |
| 52 | + "casual": [3, 8, 5, 3, 0, 0, 2, 1, 1, 8, 12, 26, 29, 47, 35], |
| 53 | + "registered": [13, 32, 27, 10, 1, 1, 0, 2, 7, 6, 24, 30, 55, 47, 71], |
| 54 | + "cnt": [16, 40, 32, 13, 1, 1, 2, 3, 8, 14, 36, 56, 84, 94, 106] |
| 55 | + }, |
| 56 | +"timestamp_column": "dteday", |
| 57 | +"timestamp_format": "%Y-%m-%d %H:%M:%S", |
| 58 | +"target_columns": ["cnt","casual"] |
| 59 | +} |
| 60 | +``` |
| 61 | +### Sample Output |
| 62 | +```json |
| 63 | + |
| 64 | +{ |
| 65 | + "forecast": [ |
| 66 | + { |
| 67 | + "cnt_prediction": [79.7074593556, 67.1107353027, ...], |
| 68 | + "casual_prediction": [26.6367874235, 21.9595151501, ...] |
| 69 | + } |
| 70 | + ] |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +### Example Payload For Multi-Time Series Forecast (with id_columns) |
| 75 | +```json |
| 76 | +{ |
| 77 | + "historical_data": { |
| 78 | + "Store": [1, 2, 2, 1, 1, 2], |
| 79 | + "Date": ["2013-01-01", "2013-01-01", "2013-01-02", "2013-01-02", "2013-01-03", "2013-01-03"], |
| 80 | + "Sales": [10, 10, null, 223, 10, 3232], |
| 81 | + "DayOfWeek": [2, 2, 3, 3, 4, 4], |
| 82 | + "Customers": [0, 0, 650, 668, 578, 555] |
| 83 | + }, |
| 84 | + "timestamp_column": "Date", |
| 85 | + "target_columns": ["Sales"], |
| 86 | + "timestamp_format": "%Y-%m-%d", |
| 87 | + "id_columns": ["Store"] |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +### Sample Output |
| 92 | +```json |
| 93 | +{ |
| 94 | + "forecast": [ |
| 95 | + { |
| 96 | + "Sales_prediction": [41.57, 44.79, ..., 70.84], |
| 97 | + "Store": 1 |
| 98 | + }, |
| 99 | + { |
| 100 | + "Sales_prediction": [1594.56, 1407.68, ..., 1151.16], |
| 101 | + "Store": 2 |
| 102 | + } |
| 103 | + ] |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +### FAQ |
| 108 | + |
| 109 | +#### What is the model's context and forecast length? |
| 110 | + |
| 111 | +This model uses a context window of 512 past points and forecasts 96 future points by default |
| 112 | + |
| 113 | +#### What happens if my data has missing timestamps or gaps? |
| 114 | + |
| 115 | +Missing values are handled by the TimeSeriesPreprocessor from the tsfm library. If the data contains missing values, |
| 116 | +they must be included as null in the input payload otherwise it can lead to errors like: "All arrays must be of the same |
| 117 | +length". |
| 118 | + |
| 119 | +#### Is GPU required? |
| 120 | + |
| 121 | +No. TTM is CPU-efficient and suitable for inference on standard OCI compute shapes. |
| 122 | + |
| 123 | +#### Can I monitor the deployed endpoint? |
| 124 | + |
| 125 | +Yes, standard OCI endpoint monitoring (logs, metrics) is supported. |
| 126 | + |
| 127 | +## References |
| 128 | + |
| 129 | + [Granite TTM on Hugging Face](https://huggingface.co/ibm-granite/granite-timeseries-ttm-r1) |
| 130 | + |
| 131 | + [IBM Research Paper](https://arxiv.org/abs/2401.03955) |
0 commit comments