coreforecast
coreforecast is a Python library that provides fast C++ implementations of common forecasting routines, particularly useful for transforming time series data in a grouped fashion. It's often leveraged internally by higher-level Nixtla libraries like MLForecast, StatsForecast, and NeuralForecast to achieve high performance. The current version is 0.0.17, released on February 24, 2026. Given its 'Alpha' development status, releases appear to be on an as-needed basis rather than a fixed cadence.
Warnings
- gotcha coreforecast is primarily a low-level dependency. Most users will interact with it indirectly through higher-level Nixtla libraries like MLForecast, StatsForecast, or NeuralForecast. Direct usage is for specific C++ operator needs.
- breaking Version incompatibilities between coreforecast and other Nixtla libraries (e.g., mlforecast) can lead to 'AttributeError'. For instance, mlforecast==0.11.6 might not be compatible with older coreforecast versions.
- gotcha The `GroupedArray` data structure expects `data` and `indptr` to be 1D NumPy arrays. Incorrectly structuring `indptr` (e.g., not matching group boundaries) will lead to incorrect calculations or errors.
Install
-
pip install coreforecast -
conda install -c conda-forge coreforecast
Imports
- GroupedArray
from coreforecast.grouped_array import GroupedArray
- ExpandingMean
from coreforecast.lag_transforms import ExpandingMean
- LocalStandardScaler
from coreforecast.scalers import LocalStandardScaler
Quickstart
import numpy as np
from coreforecast.grouped_array import GroupedArray
from coreforecast.lag_transforms import ExpandingMean
from coreforecast.scalers import LocalStandardScaler
# The base data structure is the "grouped array"
# data: values of the series
# indptr: series boundaries such that data[indptr[i] : indptr[i + 1]] returns the i-th series.
# For example, if you have two series of sizes 3 and 7, indptr would be [0, 3, 10].
data = np.arange(10).astype(np.float32)
indptr = np.array([0, 3, 10], dtype=np.int32)
ga = GroupedArray(data, indptr)
# Apply transformations
exp_mean = ExpandingMean(lag=1).transform(ga)
scaler = LocalStandardScaler().fit(ga)
standardized = scaler.transform(ga)
print("Original data:", data)
print("GroupedArray indptr:", indptr)
print("Expanding Mean:", exp_mean)
print("Standardized data (first group):")
print(standardized.data[standardized.indptr[0]:standardized.indptr[1]])