Module for handling time series data and forecasting using Darts.
Project description
Sinapsis Darts Forecasting
Module for handling time series data and forecasting using Darts.
🐍 Installation • 🚀 Features • 📚 Usage Example • 🌐 Webapp • 📙 Documentation • 🔍 License
Sinapsis Darts Forecasting provides a powerful and flexible implementation for time series forecasting using the Darts library.
🐍 Installation
Install using your package manager of choice. We encourage the use of uv
Example with uv:
uv pip install sinapsis-darts-forecasting --extra-index-url https://pypi.sinapsis.tech
or with raw pip:
pip install sinapsis-darts-forecasting --extra-index-url https://pypi.sinapsis.tech
🚀 Features
Templates Supported
The Sinapsis Darts Forecasting provides a powerful and flexible implementation for time series forecasting using the Darts library.
TimeSeriesDataframeLoader
The following attributes apply to TimeSeriesDataframeLoader template:
apply_to(list, required): Specifies which attribute inTimeSeriesPacketshould be converted from Pandas DataFrame to Darts TimeSeries (content, past_covariates, future_covariates, predictions).from_pandas_kwargs(dict[str, Any], optional): Additional arguments to pass toTimeSeries.from_dataframe().
Darts Transformers
The following attributes apply to all the preprocessing templates from Darts Transformers:
apply_to(list, required): Specifies which attributes inTimeSeriesPacketshould be transformed (content, past_covariates, future_covariates, predictions).method(Literal, required): Specifies the transformation method to apply.transform_kwargs(dict[str, Any], optional): Additional keyword arguments for the selected transformation method.params_key(str, optional): If provided, transformation parameters are stored/retrieved inTimeSeriesPacket.generic_data.
Additional transformation-specific attributes can be dynamically assigned through the class initialization dictionary (*_init attributes). These attributes correspond directly to the arguments used in Darts Transformers.
Darts Models
The following attribute apply only to templates from Darts Models:
forecast_horizon(int, optional): Number of future time steps the model should predict. Defaults to10. Additional transformation-specific attributes can be dynamically assigned through the class initialization dictionary (*_initattributes). These attributes correspond directly to the arguments used in Darts Models. Typically used for hyperparameters directly assigned to the corresponding model.
[!TIP] Use CLI command
sinapsis info --all-template-namesto show a list with all the available Template names installed with Sinapsis Image Transforms.
[!TIP] Use CLI command
sinapsis info --example-template-config TEMPLATE_NAMEto produce an example Agent config for the Template specified in TEMPLATE_NAME.
For example, for TimeSeriesDataframeLoader use sinapsis info --example-template-config TimeSeriesDataframeLoader to produce the following example config:
agent:
name: my_test_agent
templates:
- template_name: InputTemplate
class_name: InputTemplate
attributes: {}
- template_name: TimeSeriesDataframeLoader
class_name: TimeSeriesDataframeLoader
template_input: InputTemplate
attributes:
apply_to: 'content'
from_pandas_kwargs: {}
📚 Usage Example
Below is an example configuration for **Sinapsis Darts Forecasting** using an XGBoost model. This setup extracts pandas DataFrames from the time series packet attributes and converts them into `TimeSeries` objects, using the `Date` column as the time index. Missing dates are filled with a daily frequency, and any missing values are interpolated using a linear method. The model is then trained and used to generate predictions with a forecast horizon of 100 days, with several configurable hyperparameters.Example config
agent:
name: XGBLSTMForecastingAgent
description: ''
templates:
- template_name: InputTemplate
class_name: InputTemplate
attributes: {}
- template_name: TimeSeriesDataframeLoader
class_name: TimeSeriesDataframeLoader
template_input: InputTemplate
attributes:
apply_to: ["content", "past_covariates", "future_covariates"]
from_pandas_kwargs:
time_col: "Date"
fill_missing_dates: True
freq: "D"
- template_name: MissingValuesFiller
class_name: MissingValuesFillerWrapper
template_input: TimeSeriesDataframeLoader
attributes:
method: "transform"
missingvaluesfiller_init: {}
apply_to: ["content", "past_covariates", "future_covariates"]
transform_kwargs:
method: "linear"
- template_name: TimeSeries
class_name: XGBModelWrapper
template_input: MissingValuesFiller
attributes:
forecast_horizon: 100
xgbmodel_init:
lags: 30
lags_past_covariates: 30
output_chunk_length: 100
random_state: 42
n_estimators: 200
learning_rate: 0.1
max_depth: 6
[!IMPORTANT] Attributes specified under the
*_initkeys (e.g.,missingvaluesfiller_init,xgbmodel_init) correspond directly to the Darts transformation or models parameters. Ensure that values are assigned correctly according to the official Darts documentation, as they affect the behavior and performance of the model or the data.
To run the config, use the CLI:
sinapsis run name_of_config.yml
🌐 Webapp
The webapp provides an intuitive interface for data loading, preprocessing, and forecasting. The webapp supports CSV file uploads, visualization of historical data, and forecasting.
[!NOTE] Kaggle offers a variety of datasets for forecasting. In this-link from Kaggle, you can find a Bitcoin historical dataset. You can download it to use it in the app. Past and future covariates datasets are optional for the analysis.
[!IMPORTANT] Note that if you use another dataset, you need to change the attributes of the
TimeSeriesDataframeLoader
[!IMPORTANT] To run the app you first need to clone this repository:
git clone git@github.com:Sinapsis-ai/sinapsis-time-series-forecasting.git
cd sinapsis-time-series-forecasting
[!NOTE] If you'd like to enable external app sharing in Gradio,
export GRADIO_SHARE_APP=True
🐳 Docker
IMPORTANT This docker image depends on the sinapsis-nvidia:base image. Please refer to the official sinapsis instructions to Build with Docker.
- Build the sinapsis-time-series-forecasting image:
docker compose -f docker/compose.yaml build
- Start the app container:
docker compose -f docker/compose_apps.yaml up sinapsis-darts-forecasting-gradio -d
- Check the status:
docker logs -f sinapsis-darts-forecasting-gradio
- The logs will display the URL to access the webapp, e.g.:
NOTE: The url can be different, check the output of logs
Running on local URL: http://127.0.0.1:7860
- To stop the app:
docker compose -f docker/compose_apps.yaml down
💻 UV
To run the webapp using the uv package manager, please:
- Create the virtual environment and sync the dependencies:
uv sync --frozen
- Install the wheel:
uv pip install sinapsis-time-series-forecasting[all] --extra-index-url https://pypi.sinapsis.tech
- Run the webapp:
uv run webapps/darts_time_series_gradio_app.py
- The terminal will display the URL to access the webapp, e.g.:
NOTE: The url can be different, check the output of the terminal
Running on local URL: http://127.0.0.1:7860
📙 Documentation
Documentation for this and other sinapsis packages is available on the sinapsis website
Tutorials for different projects within sinapsis are available at sinapsis tutorials page
🔍 License
This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the LICENSE file.
For commercial use, please refer to our official Sinapsis website for information on obtaining a commercial license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sinapsis_darts_forecasting-0.1.7.tar.gz.
File metadata
- Download URL: sinapsis_darts_forecasting-0.1.7.tar.gz
- Upload date:
- Size: 24.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
497702937e8bed67b0cc2393430dabc468379e247699e022a7d7c2b5300412e8
|
|
| MD5 |
0a050ea00cb0db2282030a04548dc6ec
|
|
| BLAKE2b-256 |
f55ab17d080da4a3b7ba3b64794cbe3f5960a1600b7f3fc9acc742ab3b3b5851
|
File details
Details for the file sinapsis_darts_forecasting-0.1.7-py3-none-any.whl.
File metadata
- Download URL: sinapsis_darts_forecasting-0.1.7-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4653313703ebac679d55b24cb201868941e2c328942cc938237e39665b31233d
|
|
| MD5 |
41d5b3425084ab9e7cbfbeec347c8b55
|
|
| BLAKE2b-256 |
bba7dcccb4d7649f88ec9c085ac446c9f15dab4e8ca7d46c2fcd74b8d76bcf8d
|