A scikit-learn-like interface for Moirai time series forecasting using native quantile outputs
Project description
moirai_sklearn
A scikit-learn-like interface for Moirai time series forecasting.
Uses the native quantile predictions from Moirai (p10, p20, ..., p90) to compute distribution statistics directly - no artificial binning needed.
Installation
pip install moirai_sklearn
Or from source:
git clone https://github.com/guyko81/moirai_sklearn.git
cd moirai_sklearn
pip install -e .
Quick Start
from moirai_sklearn import MoiraiForecaster
import numpy as np
ts = np.sin(np.linspace(0, 10, 100)) + np.random.randn(100) * 0.1
model = MoiraiForecaster()
predictions = model.predict(ts, horizon=30)
intervals = model.predict_interval(ts, horizon=30, confidence=0.8)
Methods
| Method | Description |
|---|---|
predict(data, horizon) |
Point predictions (median) |
predict_mean(data, horizon) |
Mean estimated from quantiles |
predict_median(data, horizon) |
Median (p50) directly |
predict_mode(data, horizon) |
Mode from quantile density |
predict_quantile(data, horizon, q) |
Any quantile(s) via interpolation |
predict_interval(data, horizon, confidence) |
Prediction intervals |
predict_std(data, horizon) |
Std estimated from IQR |
predict_all(data, horizon) |
DataFrame with everything |
Input Formats
# NumPy array
model.predict(np.array([1, 2, 3, 4, 5]), horizon=10)
# Pandas Series
model.predict(pd.Series([1, 2, 3, 4, 5]), horizon=10)
# Pandas DataFrame (single column)
model.predict(pd.DataFrame({'value': [1, 2, 3, 4, 5]}), horizon=10)
Models
Salesforce/moirai-2.0-R-small(default)Salesforce/moirai-2.0-R-baseSalesforce/moirai-2.0-R-large
Features
✨ Clean API: Simple, intuitive scikit-learn-style interface
📊 Rich Statistics: Mean, median, mode, quantiles, intervals, and standard deviation
🎯 Native Quantiles: Uses Moirai's built-in quantile predictions (no binning)
🔌 Flexible Input: Supports NumPy arrays, Pandas Series, and DataFrames
⚡ Efficient: Smart model caching for repeated predictions
Examples
Check out the examples/basic_usage.py file for more detailed examples including:
- Simple forecasting
- Prediction intervals
- Multiple quantiles
- Pandas DataFrame inputs
- Visualization
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Citation
If you use this package in your research, please cite the original Moirai paper:
@article{woo2024unified,
title={Unified Training of Universal Time Series Forecasting Transformers},
author={Woo, Gerald and Liu, Chenghao and Kumar, Akshat and Xiong, Caiming and Savarese, Silvio and Sahoo, Doyen},
journal={arXiv preprint arXiv:2402.02592},
year={2024}
}
License
Apache 2.0 - See LICENSE file for details.
Acknowledgments
This package is a wrapper around uni2ts, the official implementation of Moirai by Salesforce AI Research.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file moirai_sklearn-0.1.1.tar.gz.
File metadata
- Download URL: moirai_sklearn-0.1.1.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a45e38a445f301fadab3decf6e9d6ce553b920768f3a40935457337c12d6e7f
|
|
| MD5 |
9304e7ceda860fc6f0abd6502af63471
|
|
| BLAKE2b-256 |
22db05397168a49009b3f9b6e1cd0ea0f728f9111aaaac11d64729121262ec1f
|
File details
Details for the file moirai_sklearn-0.1.1-py3-none-any.whl.
File metadata
- Download URL: moirai_sklearn-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
deacf08b94422d5f19433c85448cd21890835b579e0ad2e2dd7b891cfa76d5fd
|
|
| MD5 |
5a2ac231e8ae6b43f58652e043fe2c8b
|
|
| BLAKE2b-256 |
73fbdcf99c25a987caac7f7c5f9d7077ffc002b605ea114df9b8075f5b46c9f2
|