Skip to main content

'Time series forecasting using fuzzy logic and AutoML'

Project description

AutoFuzzTS

Time series forecasting library using fuzzy logic and automated machine learning.
Build and evaluate time series models automatically using fuzzy logic and AutoML techniques.

The package is designed for academic benchmarking and controlled experimentation in one-step-ahead time-series forecasting. It assumes a fixed train/validation/test split and focuses on reproducible model comparison rather than real-time deployment.

Installation

pip install autofuzzts

🚀 Quick Start

Load and prepare your time series data

import pandas as pd

# Load dataset into a pandas DataFrame
data = pd.read_csv('../../data/sample_datasets/NYSE.csv')
data.head(10)
# Select the target column to forecast
data_column_name = "Close"
df = data[[data_column_name]].copy()

# Split into train, validation, and test sets
test_len = len(df) // 5
val_len = len(df) // 5
train_len = len(df) - test_len - val_len

df_train = df[:train_len]
df_val = df[train_len:(train_len + val_len)]
df_test = df[(train_len + val_len):]

Tune hyperparameters using Bayesian search

from autofuzzts import pipeline

# Run Bayesian optimization for fuzzy pipeline configuration
best_config, best_rmse = pipeline.tune_hyperparameters_bayes(
    train_set=df_train,
    val_set=df_val,
    n_trials=20,
    metric="rmse"
)

print(f"Best configuration: {best_config}")

Example output:

Best configuration: {'n_fuzzy_sets': 13, 'number_of_lags': 6, 'fuzzy_part_func': 'Cosine'}

Train, calibrate, and predict

from autofuzzts import fit_calibrate_predict

# Train model, calibrate, and make one-step-ahead predictions
pred_set, pred_center_points, pred_test = fit_calibrate_predict(
    train_set=df_train,
    test_set=df_test,
    config=best_config,
    model_type="xgb"
)

This returns:

  • pred_set: predicted fuzzy sets
  • pred_center_points: corresponding fuzzy center values
  • pred_test: crisp numeric predictions (one-step-ahead forecast)

Function Overview

fit_calibrate_predict()

fit_calibrate_predict(
    train_set: pd.DataFrame,
    test_set: pd.DataFrame,
    config: dict,
    model_type: Literal['xgb', 'mlp', 'tpot'] = 'xgb',
    number_cv_calib: int = 5,
    diff_type: Literal['perc', 'abs'] = 'perc',
    covariates: list[str] | None = None,
    exclude_bool: bool = False
) -> float

Trains and calibrates a fuzzy time series model on the training set using cross-validation, then predicts on the test set and returns performance metrics.


Description

AutoFuzzTS automates the process of fuzzy time series modeling by:

  • building and testing multiple fuzzy pipelines,
  • tuning hyperparameters using Bayesian optimization, and
  • integrating tuned classification models - XGBoost, MLP, or TPOT.

This allows for rapid experimentation and selection of optimal configurations for forecasting tasks.


📄 Reference

This code is based on the research:

Optimizing stock price forecasting: a hybrid approach using fuzziness and automated machine learning
Jan Timko, Radwa El Shawi, Stefania Tomasiello
Expert Systems with Applications, Volume 259, 2025, 128844

Read on ScienceDirect

If you use this code in your research or projects, please cite the paper.


📄 License

This project is licensed under the MIT 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

autofuzzts-0.1.3.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

autofuzzts-0.1.3-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file autofuzzts-0.1.3.tar.gz.

File metadata

  • Download URL: autofuzzts-0.1.3.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for autofuzzts-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1e07ca4b7b949270f2a84bcfc0679c465152527fce9a26e25cb29c1eec22cc2c
MD5 136f620bdd4517d3c1d566d177f93574
BLAKE2b-256 d053dbd22ed6dac1457464797ea3a53e124394d5bf057f54527eeca2181eca68

See more details on using hashes here.

Provenance

The following attestation bundles were made for autofuzzts-0.1.3.tar.gz:

Publisher: workflow_live.yml on jtimko16/AutoFuzzTS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autofuzzts-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: autofuzzts-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for autofuzzts-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4b98e14e942790ee4f833b7ecb01d5acbf3efeaace480bda00dd1a49bb0e1be8
MD5 2ed7575a40b4874c3b58babbbd5ea998
BLAKE2b-256 e7b6062620b04349db8945ea4d33a3c6ff3dfd869a4b63acf6559d99b61a5fb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for autofuzzts-0.1.3-py3-none-any.whl:

Publisher: workflow_live.yml on jtimko16/AutoFuzzTS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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