tsforecasting

TSForecasting: Automated Time Series Forecasting Framework

https://github.com/tslu1s/tsforecasting

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.7%) to scientific vocabulary

Keywords

autogluon automated-forecasting automated-timeseries-forecasting automl automl-pipeline catboost data-science forecasting lightgbm machine-learning python scikit-learn timeseries timeseries-analysis timeseries-forecasting xgboost
Last synced: 6 months ago · JSON representation ·

Repository

TSForecasting: Automated Time Series Forecasting Framework

Basic Info
  • Host: GitHub
  • Owner: TsLu1s
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 256 KB
Statistics
  • Stars: 29
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Topics
autogluon automated-forecasting automated-timeseries-forecasting automl automl-pipeline catboost data-science forecasting lightgbm machine-learning python scikit-learn timeseries timeseries-analysis timeseries-forecasting xgboost
Created over 3 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

LinkedIn Contributors Stargazers MIT License Downloads Monthly Downloads


TSForecasting: Automated Time Series Forecasting Framework

Framework Contextualization

The TSForecasting project offers a comprehensive and integrated pipeline designed to Automate Time Series Forecasting applications. By implementing multivariate approaches that incorporate multiple regression models, it combines varied relevant modules such as SKLearn, AutoGluon, CatBoost and XGBoost, following an Expanding Window structured approach for performance evaluation ensuring a robust, scalable and optimized forecasting solution.

The architecture design includes five main sections, these being: data preprocessing, feature engineering, hyperparameter optimization, forecast ensembling and forecasting method selection which are organized and customizable in a pipeline structure.

This project aims at providing the following application capabilities:

  • General applicability on tabular datasets: The developed forecasting procedures are applicable on any data table associated with any Time Series Forecasting scopes.

  • Hyperparameter optimization and customization: It provides full configuration for each model hyperparameter through the customization of model_configurations dictionary, allowing optimal performance to be obtained for any use case.

  • Robustness and improvement of predictive results: The implementation of the TSForecasting pipeline aims to improve the predictive performance directly associated with the application of the best performing forecasting method.

Main Development Tools

Major frameworks used to built this project:

Performance Evaluation Structure

The Expanding Window evaluation technique is a temporary approximation on the real value of the time series data. The first test segment is selected according to the train length and then it's forecasted in accordance with forecast size. The starting position of the subsequent segment is set in direct relation to the sliding window size, this meaning, if the sliding size is equal to the forecast size, each next segment starts at the end of the previous. This process is repeated until all time series data gets segmented and it uses all the iterations and observations to construct an aggregated and robust performance analysis to each predicted point.

Where to get it

Binary installer for the latest released version is available at the Python Package Index (PyPI).

Installation

To install this package from Pypi repository run the following command:

pip install tsforecasting

Usage Examples

1. TSForecasting - Automated Time Series Forecasting

The first needed step after importing the package is to load a dataset and define your DataTime (datetime64[ns] type) and Target column to be predicted, then rename them to Date and y, respectively. The following step is to define your future running pipeline parameters variables, these being: * trainsize: Length of Train data in which will be applied the first Expanding Window iteration; * lags: The number of time steps in each window, indicating how many past observations each input sample includes; * horizon: Full length of test/future ahead predictions; * slidingsize: Length of sliding window, sliding_size>=horizon is suggested; * models: All selected models intented to be ensembled for evaluation. To fit and compare predictive performance of available models set them in paramater models:list, options are the following: * RandomForest * ExtraTrees * GBR * KNN * GeneralizedLR * XGBoost * LightGBM * Catboost * AutoGluon

  • hparameters: Nested dictionary in which are contained all models and specific hyperparameters configurations. Feel free to customize each model as you see fit (customization example shown bellow);
  • granularity: Valid interval of periods correlated to data -> 1m,30m,1h,1d,1wk,1mo (default='1d');
  • metric: Default predictive evaluation metric is MAE (Mean Absolute Error), other options are MAPE (Mean Absolute Percentage Error) and MSE (Mean Squared Error);

The fit_forecast method set the default parameters for fitting and comparison of all segmented windows for each selected and configurated model. After implementation, the history method agregates the returning the variable fit_performance containing the detailed measures of each window iteration forecasted value and all segmented iterations performance.

The forecast method forecasts the future values based on the previously predefined best performing model.

```py

from tsforecasting.forecasting import (TSForecasting, model_configurations) import pandas as pd import warnings warnings.filterwarnings("ignore", category=Warning) #-> For a clean console

Dataframe Loading

data = pd.readcsv('csvdirectorypath') data = data.rename(columns={'DateTimeColumn': 'Date','TargetNameColumn':'y'}) data = data[['Date',"y"]]

Get Models Hyperparameters Configurations

parameters = model_configurations() print(parameters)

Customization Hyperparameters Example

hparameters["RandomForest"]["n_estimators"] = 50 hparameters["KNN"]["n_neighbors"] = 5 hparameters["Catboost"]["iterations"] = 150 hparameters["AutoGluon"]["time_limit"] = 50

Fit Forecasting Evaluation

tsf = TSForecasting(trainsize = 0.90, lags = 10, horizon = 10, slidingsize = 30, models = ['RandomForest', 'ExtraTrees', 'GBR', 'KNN', 'GeneralizedLR', 'XGBoost', 'LightGBM', 'Catboost', 'AutoGluon'], hparameters = hparameters, granularity = '1h', metric = 'MAE' ) tsf = tsf.fit_forecast(dataset = data)

Get Fit History

fit_performance = tsf.history()

Forecast

forecast = tsf.forecast(dataset = data)

```

2. TSForecasting - Extra Auxiliar Methods

The make_timeseries method transforms a DataFrame into a format ready for time series analysis. This transformation prepares data sets for forecasting future values based on historical data, optimizing the input for subsequent model training and analysis, taking into consideration both the recency of data and the horizon of the prediction.

  • window_size: Determinates how many past observations each sample in the DataFrame should include. This creates a basis for learning from historical data.
  • horizon: Defines the number of future time steps to forecast. This addition provides direct targets for prediction models.
  • granularity: Adjusts the temporal detail from minutes to months, making the method suitable for diverse time series datasets (options -> 1m,30m,1h,1d,1wk,1mo).
  • datetime_engineering: When activated enriches the dataset with extra date-time features, such as year, month, and day of the week, potentialy enhancing the predictive capabilities of the model.

```py

from tsforecasting.forecasting import Processing

pr = Processing()

data = pr.maketimeseries(dataset = data, windowsize = 10, horizon = 2, granularity = '1h', datetime_engineering = True)

```

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Luis Santos - LinkedIn

Owner

  • Name: Luís Santos
  • Login: TsLu1s
  • Kind: user
  • Location: Braga, Portugal

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this Python package, please cite it as below."
authors:
- family-names: "Santos"
  given-names: "Luís"
  orcid: "https://orcid:0000-0002-4121-1133"
title: "TSForecasting - Automated Time Series Forecasting Framework"
version: 1.2.16
doi: ""
date-released: 2022-11-07
url: "https://github.com/TsLu1s/TSForecasting"

GitHub Events

Total
  • Watch event: 2
Last Year
  • Watch event: 2

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 156
  • Total Committers: 2
  • Avg Commits per committer: 78.0
  • Development Distribution Score (DDS): 0.077
Past Year
  • Commits: 100
  • Committers: 2
  • Avg Commits per committer: 50.0
  • Development Distribution Score (DDS): 0.11
Top Committers
Name Email Commits
Luís Santos 8****s 144
TsLuis l****8@h****m 12

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 67 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 25
  • Total maintainers: 1
pypi.org: tsforecasting

TSForecasting: Automated Time Series Forecasting Framework

  • Versions: 25
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 67 Last month
Rankings
Dependent packages count: 6.6%
Stargazers count: 13.9%
Downloads: 14.0%
Average: 17.7%
Forks count: 23.2%
Dependent repos count: 30.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

requirements.txt pypi
  • autokeras >=1.0.20
  • matplotlib >=3.5.2
  • neuralprophet >=0.4.1
  • numpy >=1.21.5
  • pandas >=1.3.5
  • pmdarima >=2.0.1
  • python-dateutil >=2.8.2
  • scikit-learn >=1.0.2
  • xgboost >=1.6.2
setup.py pypi