Skip to main content

The easiest way to run and scale time-series machine learning in the Cloud.

Project description

Time-series machine learning and embeddings at scale


functime Python PyPi Code style: black GitHub Publish to PyPI GitHub Build Docs GitHub Run Quickstart


functime is a powerful Python library for production-ready AutoML forecasting and time-series embeddings. Forecasting and embeddings are run and deployed in functime Cloud, which is accessed via an scikit-learn API and command line interface.

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.

Want to use functime for seamless time-series analytics across your data team Looking for fully-managed production-grade AI/ML forecasting and time-series embeddings? Book a 15 minute discovery call to learn more about functime's Team / Enterprise plans.

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
  • AutoML: Automated lags and hyperparameter tuning using FLAML
  • Utilities to add calendar effects, special events (e.g. holidays), weather patterns, and economic trends
  • Supports recursive, direct, and ensemble forecast strategies

Note: All preprocessors, time-series splitters, and forecasting metrics are implemented with Polars and open-sourced under the Apache-2.0 license. Contributions are always welcome.

Getting Started

  1. First, install functime via the pip package manager.
pip install functime
  1. Then sign-up for a free functime Cloud account via the command-line interface (CLI).
functime login
  1. That's it! You can execute time series predictions at scale using functime's scikit-learn fit-predict API.

Forecasting

import polars as pl
from functime.cross_validation import train_test_split
from functime.forecasting import LightGBM
from functime.metrics import mase

# Load example data
y = pl.read_parquet("https://bit.ly/commodities-data")
entity_col, time_col = y.columns[:2]

# Time series split
y_train, y_test = y.pipe(train_test_split(test_size=3))

# Fit-predict
model = LightGBM(freq="1mo", lags=24, max_horizons=3, strategy="ensemble")
model.fit(y=y_train)
y_pred = model.predict(fh=3)

# functime ❤️ functional design
# fit-predict in a single line
y_pred = LightGBM(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)

Classification

import polars as pl
import functime
from sklearn.linear_model import RidgeClassifierCV
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import accuracy_score
from sklearn.pipeline import make_pipeline

# Load GunPoint dataset (150 observations, 150 timestamps)
X_y_train = pl.read_parquet("https://bit.ly/gunpoint-train")
X_y_test = pl.read_parquet("https://bit.ly/gunpoint-test")

# Train-test split
X_train, y_train = X_y_train.select(pl.all().exclude("label")), X_y_train.select("label")
X_test, y_test = X_y_test.select(pl.all().exclude("label")), X_y_test.select("label")

X_train_embs = functime.embeddings.embed(X_train, model="minirocket")

# Fit classifier on the embeddings
classifier = make_pipeline(
    StandardScaler(with_mean=False),
    RidgeClassifierCV(alphas=np.logspace(-3, 3, 10)),
)
classifier.fit(X_train_embs, y_train)

# Predict and
X_test_embs = embed(X_test, model="minirocket")
labels = classifier.predict(X_test_embs)
accuracy = accuracy_score(predictions, y_test)

Clustering

import functime
import polars as pl
from hdbscan import HDBSCAN
from umap import UMAP
from functime.preprocessing import roll

# Load S&P500 panel data from 2022-06-01 to 2023-06-01
# Columns: ticker, time, price
y = pl.read_parquet("https://bit.ly/sp500-data")

# Create embeddings
embeddings = functime.embeddings.embed(y_ma_60, model="minirocket")

# Reduce dimensionality with UMAP
reducer = UMAP(n_components=500, n_neighbors=10, metric="manhattan")
umap_embeddings = reducer.fit_transform(embeddings)

# Cluster with HDBSCAN
clusterer = HDBSCAN(metric="minkowski", p=1)
estimator.fit(X)

# Get predicted cluster labels
labels = estimator.predict(X)

Deployment

functime deploys and trains your forecasting models the moment you call any .fit method. Run the functime list CLI command to list all deployed models. To view data and forecasts usage, run the functime usage CLI command.

Example CLI usage

You can reuse a deployed model for predictions anywhere using the stub_id variable. Note: the .from_deployed model class must be the same as during .fit.

forecaster = LightGBM.from_deployed(stub_id)
y_pred = forecaster.predict(fh=3)

License

functime is distributed under AGPL-3.0-only. For Apache-2.0 exceptions, see LICENSING.md.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

functime-0.1.10-py3-none-any.whl (47.8 kB view details)

Uploaded Python 3

File details

Details for the file functime-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: functime-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 47.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for functime-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 338902aedab50ed13eb3e31ae832763d93df4b6036b0d3362ed9b744992a42d5
MD5 ddb201858372ffbe563311a03f3eeac4
BLAKE2b-256 73874d1d897add18323313ebe668bffe8f6c81b77a068d31603db16e7d31eef4

See more details on using hashes here.

Supported by

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