Time-series machine learning at scale.
Project description
functime is a powerful Python library for production-ready global forecasting and time-series feature engineering.
functime also comes with time-series preprocessing (box-cox, differencing etc), cross-validation splitters (expanding and sliding window), and forecast metrics (MASE, SMAPE etc). All optimized as lazy Polars transforms.
Highlights
- Fast: Forecast 100,000 time series in seconds on your laptop
- Efficient: Embarrassingly parallel feature engineering for time-series using
Polars
- Battle-tested: Machine learning algorithms that deliver real business impact and win competitions
- Exogenous features: supported by every forecaster
- Backtesting with expanding window and sliding window splitters
- Automated lags and hyperparameter tuning using
FLAML
- Censored forecaster: for zero-inflated and thresholding forecasts
Getting Started
Install functime
via the pip package manager.
pip install functime
Forecasting
import polars as pl
from functime.cross_validation import train_test_split
from functime.feature_extraction import add_fourier_terms
from functime.forecasting import linear_model
from functime.preprocessing import scale
from functime.metrics import mase
# Load commodities price data
y = pl.read_parquet("https://github.com/descendant-ai/functime/raw/main/data/commodities.parquet")
entity_col, time_col = y.columns[:2]
# Time series split
y_train, y_test = y.pipe(train_test_split(test_size=3))
# Fit-predict
forecaster = linear_model(freq="1mo", lags=24)
forecaster.fit(y=y_train)
y_pred = forecaster.predict(fh=3)
# functime ❤️ functional design
# fit-predict in a single line
y_pred = linear_model(freq="1mo", lags=24)(y=y_train, fh=3)
# Score forecasts in parallel
scores = mase(y_true=y_test, y_pred=y_pred, y_train=y_train)
# Forecast with target transforms and feature transforms
forecaster = linear_model(
freq="1mo",
lags=24,
target_transform=scale(),
feature_transform=add_fourier_terms(sp=12, K=6)
)
# Forecast with exogenous regressors!
# Just pass them into X
X = (
y.select([entity_col, time_col])
.pipe(add_fourier_terms(sp=12, K=6)).collect()
)
X_train, X_future = y.pipe(train_test_split(test_size=3))
forecaster = linear_model(freq="1mo", lags=24)
forecaster.fit(y=y_train, X=X_train)
y_pred = forecaster.predict(fh=3, X=X_future)
View the full walkthrough on forecasting with functime
.
License
functime
is distributed under Apache-2.0.
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
functime-0.7.0.tar.gz
(60.1 kB
view details)
Built Distribution
functime-0.7.0-py3-none-any.whl
(66.6 kB
view details)
File details
Details for the file functime-0.7.0.tar.gz
.
File metadata
- Download URL: functime-0.7.0.tar.gz
- Upload date:
- Size: 60.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2f3d1c7932520ebec3be3fb2c80681ef1b3553ec850577b17feb53df9a47fe3 |
|
MD5 | 86f136177d3bcd0fc40bce07b0260723 |
|
BLAKE2b-256 | 1952b4f202116fa9c909360fb47d1abfdb262d7b81bb0aee82b9819f9e8fb0cf |
File details
Details for the file functime-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: functime-0.7.0-py3-none-any.whl
- Upload date:
- Size: 66.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a66a3a6472ef386a5033deb3fadb5ac4802e6fa60cdccafe9bdb2eaf9b41328 |
|
MD5 | bd381f3b38bcb11e4ea9b6ac0273dc05 |
|
BLAKE2b-256 | a8172d020e80901f2423f953799f0e3040c0652383fb99842358416d648f2d64 |