module mlforecast.core

Global Variables

  • pl
  • date_features_dtypes

class TimeSeries

Utility class for storing and transforming time series data.

method __init__

__init__(
    freq: Union[int, str],
    lags: Optional[Iterable[int]] = None,
    lag_transforms: Optional[Dict[int, List[Union[Callable, Tuple[Callable, Any]]]]] = None,
    date_features: Optional[Iterable[Union[str, Callable]]] = None,
    num_threads: int = 1,
    target_transforms: Optional[List[Union[BaseTargetTransform, _BaseGroupedArrayTargetTransform]]] = None,
    lag_transforms_namer: Optional[Callable] = None
)

property features

Names of all computed features.

method fit_transform

fit_transform(
    data: DataFrame,
    id_col: str,
    time_col: str,
    target_col: str,
    static_features: Optional[List[str]] = None,
    dropna: bool = True,
    keep_last_n: Optional[int] = None,
    max_horizon: Optional[int] = None,
    return_X_y: bool = False,
    as_numpy: bool = False,
    weight_col: Optional[str] = None
) β†’ Union[DataFrame, Tuple[DataFrame, ndarray]]
Add the features to data and save the required information for the predictions step. If not all features are static, specify which ones are in static_features. If you don’t want to drop rows with null values after the transformations set dropna=False If keep_last_n is not None then that number of observations is kept across all series for updates.

method load

load(path: Union[str, Path], protocol: Optional[str] = None) β†’ TimeSeries

method predict

predict(
    models: Dict[str, Union[BaseEstimator, List[BaseEstimator]]],
    horizon: int,
    before_predict_callback: Optional[Callable] = None,
    after_predict_callback: Optional[Callable] = None,
    X_df: Optional[DataFrame] = None,
    ids: Optional[List[str]] = None
) β†’ DataFrame

method save

save(path: Union[str, Path]) β†’ None

method update

update(df: Union[DataFrame, pl_DataFrame]) β†’ None
Update the values of the stored series.