Skip to main content

Module that contains different packages to perform time-series-related operations through Sinapsis templates.

Project description



Sinapsis Time Series Forecasting

Monorepo with packages to perform time series forecasting, preprocessing, and data loading.

🐍 Installation📦 Packages📚 Usage example 🌐 Webapp 📙 Documentation🔍 License

🐍 Installation

This monorepo currently consists of the following packages to handle time-series data:

  • sinapsis-darts-forecasting

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

[!IMPORTANT] Templates in each package may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:

with uv:

  uv pip install sinapsis-darts-forecasting[all] --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

  pip install sinapsis-darts-forecasting[all] --extra-index-url https://pypi.sinapsis.tech

[!TIP] You can also install all the packages within this project:

  uv pip install sinapsis-time-series-forecasting[all] --extra-index-url https://pypi.sinapsis.tech

📦 Packages

Packages summary
  • Sinapsis Darts Forecasting
    • Dataframe Loader
      Convert a pandas Dataframe into a Darts TimeSeries object.
    • Darts Transforms
      Apply several data transformations using Darts transformers to different sources in the time series packet.
    • Darts Models
      Fit and predict data inside the container using Darts baseline, statistical, machine learning and deep learning models.

[!TIP] Use CLI command sinapsis info --all-template-names to show a list with all the available Template names installed with Sinapsis Time Series Forecasting.

[!TIP] Use CLI command sinapsis info --example-template-config TEMPLATE_NAME to produce an example Agent config for the Template specified in TEMPLATE_NAME.

For example, for XGBModelWrapper use sinapsis info --example-template-config XGBModelWrapper to produce the following example config:

agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: XGBModelWrapper
  class_name: XGBModelWrapper
  template_input: InputTemplate
  attributes:
    forecast_horizon: 10
    xgbmodel_init:
      lags: null
      lags_past_covariates: null
      lags_future_covariates: null
      output_chunk_length: 1
      output_chunk_shift: 0
      add_encoders: null
      likelihood: null
      quantiles: null
      random_state: null
      multi_models: true
      use_static_covariates: true

📚 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 agent config
agent:
  name: XGBLSTMForecastingAgent
  description: ''

templates:

- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}

- template_name: TimeSeriesFromDataframeLoader
  class_name: TimeSeriesFromDataframeLoader
  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: TimeSeriesFromDataframeLoader
  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

To run, simply use:

sinapsis run name_of_the_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 TimeSeriesFromDataframeLoader

[!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.

  1. Build the sinapsis-time-series-forecasting image:
docker compose -f docker/compose.yaml build
  1. Start the app container:
docker compose -f docker/compose_apps.yaml up sinapsis-darts-forecasting-gradio -d
  1. Check the status:
docker logs -f sinapsis-darts-forecasting-gradio
  1. 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
  1. To stop the app:
docker compose -f docker/compose_apps.yaml down
💻 UV

To run the webapp using the uv package manager, please:

  1. Create the virtual environment and sync the dependencies:
uv sync --frozen
  1. Install the wheel:
uv pip install sinapsis-time-series-forecasting[all] --extra-index-url https://pypi.sinapsis.tech
  1. Run the webapp:
uv run webapps/darts_time_series_gradio_app.py
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sinapsis_time_series-0.1.11.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sinapsis_time_series-0.1.11-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file sinapsis_time_series-0.1.11.tar.gz.

File metadata

File hashes

Hashes for sinapsis_time_series-0.1.11.tar.gz
Algorithm Hash digest
SHA256 abaae5cf0776de0fc17b7e7163429d244c0e9bf4894ab3265f17c2e87947b364
MD5 2997cf5c44f1ade32cdc4afba2dcc283
BLAKE2b-256 d1e3e55d37435589773cf8f915a9dfc7b94c91e4b7bb91c87398e32847656484

See more details on using hashes here.

File details

Details for the file sinapsis_time_series-0.1.11-py3-none-any.whl.

File metadata

File hashes

Hashes for sinapsis_time_series-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 e94354973768d7474aca67de852db8d218b863f904a4d3069fa53d14d75e7c7b
MD5 cd97262ac7edaa8cd1b1186964e5ae53
BLAKE2b-256 e6c9472cf12f88abe0fae335df1131c1a2321fb5b8d0cfcd5bde0922f7a97462

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page