# Timeseries Forecast

## Model Scenario

{% embed url="<https://www.youtube.com/watch?v=jmWv7g9mils>" %}
Watch a video on how to build a Time Series forecast based on demo dataset
{% endembed %}

A **Timeseries Forecast Model** is designed to predict future values by analyzing historical time-related data. To utilize this model, your dataset must include both time-based and numerical columns. In this tutorial, we'll cover the fundamentals of the **Model Scenario** to help you achieve optimal results.&#x20;

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FzfBUK094ZWq0ciirCLww%2FScreenshot%202024-07-22%20at%2017.17.36.png?alt=media&#x26;token=2755e914-963f-42b2-a9fc-0311b11486c4" alt="" width="205"><figcaption><p>Timeseries forecast model</p></figcaption></figure>

***

### Target Column

For the **Target Column**, select a numeric value you want to predict. It's crucial to have values by day, week, or year. If some dates are repeated, you can aggregate them by taking their sum, average, etc.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2Fz97Dqf2Z5nH4D7C4UrPv%2FScreenshot%202024-07-22%20at%2017.20.46.png?alt=media&#x26;token=4922562b-14d8-4b21-92bb-298ce294dde5" alt=""><figcaption></figcaption></figure>

***

### Sequence and Time dimension setup

Next, you can choose a **Sequence Identifier Field** to group fields and generate an independent time series and forecast forecast for each group. Keep in mind, these values shouldn't be unique; they must form a series and there is maximum of 500 unique values allowed as sequence identifier. If you don't want to generate independent time series for each group, you can leave this option empty.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FfiJR6RnQtVaGkLEZ0C9q%2FScreenshot%202024-07-22%20at%2017.21.17.png?alt=media&#x26;token=9dcf6132-4d80-42c4-b7d6-b59a3935cef9" alt=""><figcaption></figcaption></figure>

***

Then, select the **Time/Date Column**, specifying the column containing time-related values. The **Time Interval** represents the data frequency—choose daily for daily data, yearly for annual data, etc. With **Forecast Horizon**, decide how many days, weeks, or years you want to predict from the last date in your dataset.

If your dataset includes external factors that influence the target—such as marketing spend, weather, or pricing—you can add them as regressors. Simply select up to 5 additional columns in the *Regressors* field. These values will help the model better understand patterns and improve forecast accuracy. More info can be found in the [Regressors](https://docs.graphite-note.com/graphite-note-documentation/graphite-note-models/advanced-ml-model-settings/regressors) section.

> &#x20;:warning: Note: Since you’ve selected additional regressors for this model, predictions can’t be generated directly within the app interface. This is because the model requires future values for each regressor to make accurate predictions. Providing this data manually can be impractical, especially for large datasets. Instead, please use our Prediction API to submit your regressor values and generate forecasts programmatically.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FjT8DckMMQvIK3YPtxLmU%2Fimage.png?alt=media&#x26;token=464f0bdf-8015-4adf-97f3-c80bd032751c" alt=""><figcaption><p>Time and Date selections and Regressors</p></figcaption></figure>

***

The model performs well with seasonal data patterns. If your data shows a linear growth trend, select "additive" for **Seasonality Mode**; for exponential growth, select "multiplicative." For example, if you see annual patterns, set **Yearly Seasonality** to True. (TIP: Plotting your data beforehand can help you understand these patterns.) If you're unsure, the model will attempt to detect seasonality automatically.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FzBGWcXSD4bXojleGh4mJ%2FScreenshot%202024-07-22%20at%2017.22.46.png?alt=media&#x26;token=ea71188a-2537-4893-8748-2670081f5d0c" alt=""><figcaption><p>Seasonality settings</p></figcaption></figure>

For daily or hourly intervals, you can access **Advanced Parameters** to add special dates, weekends, holidays, or limit the target value.

***

### Advanced Parameters <a href="#headline-11-92" id="headline-11-92"></a>

We are constantly enhancing our platform with new features and improving existing models. For your daily data, we've introduced some new capabilities that can significantly boost forecast accuracy. Now, you can limit your target predictions, remove outliers, and include country holidays and special events.&#x20;

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FBzoTsKM7VrmJfzTP58Ru%2FScreenshot%202024-07-22%20at%2017.23.19.png?alt=media&#x26;token=c975a472-185c-4dc8-b135-90d60898580c" alt=""><figcaption><p>Selecting advanced parameters like special dates and holidays</p></figcaption></figure>

To set prediction limits, enter the minimum and maximum values for your target variable. For example, if you're predicting daily temperatures and know the maximum is 40°C, enter that value to prevent the model from predicting higher temperatures. This helps the model recognize the appropriate range of the **Target Column**.  Additionally, you can use the **Remove Days of the Week** feature to exclude certain days from your predictions.

***

### Country holidays and special dates <a href="#headline-11-92" id="headline-11-92"></a>

We added parameters for country holidays and special dates to improve model accuracy. Large deviations can occur around holidays, where stores see more customers than usual. By informing the model about these holidays, you can achieve more balanced and accurate predictions. To add holidays in Graphite Note, navigate to the advanced section of the **Model Scenario** and select the relevant country or countries.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FkpAluNjuBLPFU6VGijYs%2FScreenshot%202024-07-22%20at%2017.27.43.png?alt=media&#x26;token=28bf0e64-025d-476f-8df6-c8402cf70c37" alt=""><figcaption><p>Selecting Country Holidays</p></figcaption></figure>

Similarly, you can add promotions or events that affect your data by enabling **Add special dates** option. Enter the promotion name, start date, duration, and future dates. This ensures the model accounts for these events in future predictions.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FgIssDb5gGMV7UetviHl8%2FScreenshot%202024-07-22%20at%2017.28.46.png?alt=media&#x26;token=f3758d7b-10cc-4a28-b766-024ac36e6945" alt=""><figcaption></figcaption></figure>

Combining these parameters provides more accurate results. The more information the model receives, the better the predictions.

***

### Removing data points <a href="#headline-11-92" id="headline-11-92"></a>

In addition to adding holidays and special events, you can delete specific data points from your dataset. In Graphite Note, enter the start and end dates of the period you want to remove. For single-day periods, enter the same start and end date. You can remove multiple periods if necessary. Understanding your data and identifying outliers or irrelevant periods is crucial for accurate predictions. Removing these dates can help eliminate biases and improve model accuracy.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FTeM4ssG8MmizYMBOcKEE%2FScreenshot%202024-07-22%20at%2023.18.03.png?alt=media&#x26;token=09f5c3a0-f105-4fa9-984d-5ddb9d3c54f2" alt=""><figcaption></figcaption></figure>

By following these steps, you can harness the full potential of your **Timeseries Forecast Model**, providing valuable insights and more accurate predictions for your business. Now it's your turn to do some modeling and explore your results!&#x20;

***

### Training model

After setting all parameters it is time to **Run Scenario** and train **Machine Learning** model.\
\
Before you do, you can choose to toggle Enable Model Results Dataset. This option creates a dedicated dataset that compares the model’s historical predictions with actual values, enabling detailed seasonality, trend analysis, and performance evaluation. These results will be accessible in the Performance tab once the model has finished training.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2Fi4WAHLU7Git6St6Wpq8x%2Fimage.png?alt=media&#x26;token=9f3e1769-67b2-48ab-b17c-115fa551e8ae" alt=""><figcaption><p>Running scenario</p></figcaption></figure>

***

The training duration may vary depending on the data volume, typically ranging from 1 to 10 minutes. The training will utilize 80% of the data to train various machine learning models and the remaining 20% to test these models and calculate relevant scores. Once completed, you will receive information about the best model based on the F1 value and details about training time.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FOX0Ktiv9oMRVwA7O3JYV%2FScreenshot%202024-07-22%20at%2023.30.09.png?alt=media&#x26;token=4ee2af3e-e4af-4c93-bc3c-d248a3d5e6b3" alt=""><figcaption></figcaption></figure>

***

## Model Performance

To interpret the results after running your model, you will be taken to Performance tab. Here, on the Overivew screen, you can see the overall model performance post-training. Model evaluation metrics such as F1 Score, Accuracy, AUC, Precision, and Recall are displayed to assess the performance of classification models.&#x20;

On the performance tab, you can explore six different views that provide insights related to model training and results: Overview, [Model Fit](#model-fit), [Trend](#trend),[ Seasonality](#seasonality),[ Special Dates](#special-dates), and [Details](#details).

***

### Overview

The Overview screen provides a summary of your time series model’s forecasting accuracy. It displays key performance metrics to help you quickly assess how well the model predicts your target variable (e.g., *sales*).

The following metrics are shown:

* R-Squared – Indicates how much of the variance in your target variable is explained by the model (closer to 100% is better).
* MAPE (Mean Absolute Percentage Error) – Shows the average percentage error between predicted and actual values (lower is better).
* MAE (Mean Absolute Error) – Represents the average absolute difference between predicted and actual values.
* RMSE (Root Mean Squared Error) – Measures the average magnitude of the prediction error, giving more weight to large errors.<br>
*

```
<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2F9sQPUMORtkiz7XOixOvd%2Fimage.png?alt=media&#x26;token=86faaa93-da1e-4b1f-850a-941845e44c1a" alt=""><figcaption><p>Overview in Model performance tab</p></figcaption></figure>
```

These metrics offer a quick and easy way to understand how reliable your forecast is, before diving deeper into model fit, trends, seasonality, and special date effects.

***

### Model Fit

The **Model Fit Tab** displays a graph with actual and predicted values. The primary prediction is shown with a yellow line, and the uncertainty interval is illustrated with a yellow shaded area. This visualization helps assess the model's performance. If you used the **Sequence Identifier Field**, you can choose which value to analyze in each **Model Result**.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2Fi3eA8wh1Gcp025RI2Ahs%2Fimage.png?alt=media&#x26;token=8db74704-954c-459c-80cd-b42ddad95e1e" alt=""><figcaption></figcaption></figure>

***

### Trend

Trends and seasonality are key characteristics of time-series data that should be analyzed. The **Trend Tab** displays a graph illustrating the global trend that Graphite Note has detected from your historical data.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FFRLp5dUYYRJKDqhitIrj%2Fimage.png?alt=media&#x26;token=501e861e-f9ff-4036-85db-62ab43abfed3" alt=""><figcaption></figcaption></figure>

***

### Seasonality

Seasonality represents the repeating patterns or cycles of behavior over time. Depending on your **Time Interval**, you can find one or two graphs in the **Seasonality Tab**. For daily data, one graph shows weekly patterns, while the other shows yearly patterns. For weekly and monthly data, the graph highlights recurring patterns throughout the year.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FiLZf3YwOFpFBK2AJLdsQ%2Fimage.png?alt=media&#x26;token=d6d768fa-b452-4678-94a0-a2cfc97f1de1" alt=""><figcaption><p>Seasonality graph showing patterns in historical data</p></figcaption></figure>

***

### Special Dates

The Special Dates graph shows the percentage effects of the special dates and holidays in historical and future data. Special Dates are only supported for the Daily Time interval set in the scenario.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FYR8NdTx6PS69102Wve64%2FScreenshot%202024-07-22%20at%2023.58.33.png?alt=media&#x26;token=673ed511-25f2-4c1d-831a-8387438e0ab8" alt=""><figcaption><p>Special Dates and Holidays effects</p></figcaption></figure>

***

### Details

**Details tab** shows the results of the predictive model, presented in a table format. Each record includes the predicted label, predicted probability, and predicted correctness, offering insights into the model's predictions, confidence, and accuracy for each data point. Dataset test results can be exporetd into Excel by clicking on the XLSX button in the right corner.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FpwQZlbr0AdLyPsbjvHYi%2Fimage.png?alt=media&#x26;token=8a5eb507-65b9-4407-82ee-71519175d133" alt=""><figcaption><p>Model results in a dataset that can be exported to Excel</p></figcaption></figure>

***

## Take actions with Timeseries forecast&#x20;

After building and analyzing a time series forecasting model in Graphite Note, the Predict function allows you to apply the model to real-world use cases. This enables you to forecast future values based on historical patterns and known sequences, helping you plan more effectively and make proactive business decisions. There are two ways to use prediction in **Time Series Forecast** models:

* [What-If Scenario Predictions](#what-if-scenario-predictions)
* [API Predictions](#api-predictions)

#### **What-If Scenario Predictions**

In the Predict screen, you can select a specific sequence ID (such as a product, store, or region) and define a forecast period using start and end dates. After submitting your selection, Graphite Note generates a forecast for that time range, showing predicted values in tabular format.

This is useful for:

* Exploring how trends will evolve for specific time series
* Planning inventory, staffing, or production based on expected values
* Reviewing changes over different time periods or entities

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FTIInYzEJ4gco5aCWMZyu%2Fimage.png?alt=media&#x26;token=541e3b4b-287d-479f-8829-6ce2b4680d05" alt=""><figcaption><p>Predict option with what-if selections</p></figcaption></figure>

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2FYS6Fx8OrUZnBtenOm5Mi%2Fimage.png?alt=media&#x26;token=970d0b83-9c90-40d3-ba93-616aaf4ebb1a" alt=""><figcaption><p>Predicted data for selected interval</p></figcaption></figure>

{% hint style="info" %}
⚠️ Important: If your model includes additional regressors, predictions cannot be generated through the app interface. This is because the model requires future values for each regressor, which must be supplied at the time of prediction. To generate predictions with regressors, please use the Graphite Note Prediction API, where you can programmatically provide the necessary inputs.
{% endhint %}

#### API Predictions

For time series forecasting models, Graphite Note also supports predictions via the Prediction API. This is ideal for integrating forecasts into dashboards, external systems, or automated workflows.

<figure><img src="https://3727300098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgnR78y9L7FDWeb4jdvdW%2Fuploads%2Fh0cyeTqWAh9HIVUaQHev%2Fimage.png?alt=media&#x26;token=9214823d-f7be-4abc-81e4-de81314f44c2" alt=""><figcaption><p>API request definition that can be used to set up API call from third party tool</p></figcaption></figure>

Instead of using the interface manually, you send a simple API request with three key inputs:

* startDate: The beginning of the forecast period
* endDate: The end of the forecast period
* sequenceID: The identifier for the time series you want to forecast (e.g., “Product A” )

This API makes it easy to fetch forecasts programmatically and use them wherever you need, whether that’s a planning tool, a custom app, or a business report.&#x20;

For full details, visit the [Prediction API documentation](https://docs.graphite-note.com/api/predict).&#x20;

{% hint style="info" %}
Timeseries predictions can be made only with API Prediction request v1.
{% endhint %}

***

### Create Notebook

You can share your prediction results with your team using the Notebook feature. With Notebooks, users can also run their own predictions on your Timerseries Forecast model.

Notebooks allow you to create various visualizations with detailed descriptions. You can plot model results for better understanding and enable users to make their own predictions. For more information, refer to the [Data Storytelling section](https://docs.graphite-note.com/graphite-note-documentation/notebooks).
