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.

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("../clean_data/ADBE_yf_hourly_cleaned.csv").head(240)

# Select the target column to forecast
data_column_name = "close_price"
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_clusters': 19, 'number_of_lags': 2, 'fuzzy_part_func': 'Triangle'}

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.



📄 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.1.tar.gz (15.5 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.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: autofuzzts-0.1.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for autofuzzts-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e3b156563f67554dc97735039d799cbfec11726729b11eadf71a3513f1702784
MD5 d929a6ad7029ed5a7708532fdb6d705b
BLAKE2b-256 7aefca3e09e42cbd4117d3e3b8e8e1cf100e9b3bdde25412a42673db03176509

See more details on using hashes here.

File details

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

File metadata

  • Download URL: autofuzzts-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.8

File hashes

Hashes for autofuzzts-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40bbcba5ea5ca458c8b9c57b20ae3a537962d3b7a05ae7c1f5cced22faf462fc
MD5 2378b20fb1de8f73f88eb0790c83b5d7
BLAKE2b-256 f183adebbd5e88421d5355eb39e76c9cdfa6efe303c1dbb628c84e127fb06e77

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