Time Series¶
- class endgame.timeseries.BaseForecaster(random_state=None, verbose=False)[source]¶
Bases:
BaseEstimator,RegressorMixin,ABCBase class for all time series forecasters.
Provides sklearn-compatible interface with time series specific extensions. Designed for integration with signal processing.
- Parameters:
- y_¶
The training time series (stored for forecasting).
- Type:
np.ndarray
Notes
All forecasters follow the pattern: 1. fit(y, X=None) - Learn from historical data 2. predict(horizon) - Generate future predictions 3. update(y_new) - Incrementally update with new data (optional)
For sklearn pipeline compatibility, forecasters also support: - fit_predict(y, horizon) - Fit and predict in one call - score(y_true, y_pred) - Evaluate forecast accuracy
Design Considerations for Signal Processing Integration: - All methods accept raw arrays (no timestamp requirements) - Frequency/sampling rate stored in freq_ attribute - Support for irregularly sampled data via interpolation - Hooks for spectral features (FFT, wavelets) via features parameter
- abstractmethod fit(y, X=None, **fit_params)[source]¶
Fit the forecaster to training data.
- Parameters:
y (array-like of shape (n_samples,) or (n_samples, n_series)) – Training time series.
X (array-like of shape (n_samples, n_features), optional) – Exogenous features aligned with y.
**fit_params (dict) – Additional parameters for fitting.
- Return type:
- Returns:
self – Fitted forecaster.
- abstractmethod predict(horizon, X=None)[source]¶
Generate point forecasts.
- Parameters:
horizon (int) – Number of steps ahead to forecast.
X (array-like of shape (horizon, n_features), optional) – Exogenous features for the forecast horizon.
- Return type:
- Returns:
np.ndarray – Point forecasts of shape (horizon,) or (horizon, n_series).
- fit_predict(y, horizon, X=None, X_future=None, **fit_params)[source]¶
Fit and predict in one step.
- Parameters:
- Return type:
- Returns:
np.ndarray – Forecasts.
- update(y_new, X_new=None)[source]¶
Update the forecaster with new observations.
Default implementation re-fits with concatenated data. Subclasses may override for incremental updates.
- Parameters:
y_new (array-like) – New observations to incorporate.
X_new (array-like, optional) – Corresponding exogenous features.
- Return type:
- Returns:
self – Updated forecaster.
- score(y_true, y_pred=None, horizon=None, metric='mse')[source]¶
Score the forecaster’s predictions.
- Parameters:
- Return type:
- Returns:
float – Negative score (for sklearn compatibility, lower is better).
- get_fitted_values()[source]¶
Get in-sample fitted values (one-step-ahead predictions).
- Return type:
- Returns:
np.ndarray – Fitted values for the training period.
- get_residuals()[source]¶
Get in-sample residuals.
- Return type:
- Returns:
np.ndarray – Residuals (y - fitted_values).
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (BaseForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (BaseForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.ForecasterMixin[source]¶
Bases:
objectMixin providing common forecaster functionality.
Defines the interface that all forecasters must implement.
- predict_interval(horizon, coverage=0.95, X=None)[source]¶
Generate prediction intervals.
- Parameters:
- Return type:
- Returns:
tuple of np.ndarray – (point_forecast, lower_bound, upper_bound)
- class endgame.timeseries.UnivariateForecasterMixin[source]¶
Bases:
ForecasterMixinMixin for univariate time series forecasters.
Forecasters using this mixin expect a single time series as input.
- class endgame.timeseries.MultivariateForecasterMixin[source]¶
Bases:
ForecasterMixinMixin for multivariate time series forecasters.
Forecasters using this mixin can handle multiple time series or a single series with multiple variables.
- class endgame.timeseries.NaiveForecaster(strategy='last', random_state=None, verbose=False)[source]¶
Bases:
BaseForecaster,UnivariateForecasterMixinNaive forecaster using simple strategies.
Implements several naive forecasting strategies that serve as strong baselines, especially for random walk-like data.
- Parameters:
strategy (str, default="last") – Forecasting strategy: - “last”: Predict the last observed value (random walk) - “mean”: Predict the mean of the training data - “median”: Predict the median of the training data
random_state (int, optional) – Random seed (unused, for API consistency).
verbose (bool, default=False) – Enable verbose output.
Examples
>>> model = NaiveForecaster(strategy="last") >>> model.fit(y_train) >>> forecast = model.predict(horizon=7)
Notes
The “last” strategy is equivalent to a random walk model without drift and often performs surprisingly well on financial and economic data.
- fit(y, X=None, **fit_params)[source]¶
Fit the naive forecaster.
- Parameters:
y (array-like of shape (n_samples,)) – Training time series.
X (ignored) – Exogenous features (not used).
- Return type:
- Returns:
self – Fitted forecaster.
- predict_interval(horizon, coverage=0.95, X=None)[source]¶
Generate prediction intervals using residual-based approach.
- get_fitted_values()[source]¶
Get in-sample fitted values.
For naive forecaster, fitted values are lagged actuals (strategy=last) or constant values (strategy=mean/median).
- Return type:
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (NaiveForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (NaiveForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.SeasonalNaiveForecaster(seasonal_period=1, random_state=None, verbose=False)[source]¶
Bases:
BaseForecaster,UnivariateForecasterMixinSeasonal naive forecaster.
Predicts using values from the same season in the previous cycle. Essential baseline for data with strong seasonality.
- Parameters:
Examples
>>> # Weekly seasonality >>> model = SeasonalNaiveForecaster(seasonal_period=7) >>> model.fit(daily_sales) >>> forecast = model.predict(horizon=14) # Next two weeks
- fit(y, X=None, **fit_params)[source]¶
Fit the seasonal naive forecaster.
- Parameters:
y (array-like of shape (n_samples,)) – Training time series.
X (ignored) – Not used.
- Return type:
- Returns:
self – Fitted forecaster.
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (SeasonalNaiveForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (SeasonalNaiveForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.MovingAverageForecaster(window=5, weights=None, center=False, random_state=None, verbose=False)[source]¶
Bases:
BaseForecaster,UnivariateForecasterMixinMoving average forecaster.
Predicts using simple or weighted moving average of recent observations. Effective for smoothing noise and capturing local trends.
- Parameters:
window (int, default=5) – Number of recent observations to average.
weights (array-like, optional) – Custom weights for each lag. If None, uses equal weights. Weights are applied in reverse order (most recent first).
center (bool, default=False) – If True, use centered moving average (for decomposition). Only affects fitted values, not predictions.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
Examples
>>> # Simple moving average >>> model = MovingAverageForecaster(window=7) >>> model.fit(y_train) >>> forecast = model.predict(horizon=30)
>>> # Weighted moving average (recent values weighted more) >>> model = MovingAverageForecaster(window=5, weights=[1, 2, 3, 4, 5])
- fit(y, X=None, **fit_params)[source]¶
Fit the moving average forecaster.
- Parameters:
y (array-like) – Training time series.
X (ignored) – Not used.
- Return type:
- Returns:
self – Fitted forecaster.
- predict(horizon, X=None)[source]¶
Generate moving average forecasts.
Note: For multi-step forecasts, this uses a recursive approach where each forecast becomes input for the next.
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (MovingAverageForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (MovingAverageForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.ExponentialSmoothingForecaster(alpha=0.3, beta=None, optimize=False, initial_method='heuristic', random_state=None, verbose=False)[source]¶
Bases:
BaseForecaster,UnivariateForecasterMixinSimple exponential smoothing forecaster.
Implements single exponential smoothing (SES) for level forecasting and double exponential smoothing (Holt’s method) for trend.
- Parameters:
alpha (float, default=0.3) – Smoothing parameter for level (0 < alpha < 1). Higher values give more weight to recent observations.
beta (float, optional) – Smoothing parameter for trend (0 < beta < 1). If None, uses simple exponential smoothing without trend.
optimize (bool, default=False) – If True, optimize alpha (and beta) using grid search.
initial_method (str, default="heuristic") – Method for initializing level (and trend): - “heuristic”: Use first few observations - “estimated”: Estimate from training data
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
Examples
>>> # Simple exponential smoothing >>> model = ExponentialSmoothingForecaster(alpha=0.3) >>> model.fit(y_train) >>> forecast = model.predict(horizon=10)
>>> # Holt's linear trend method >>> model = ExponentialSmoothingForecaster(alpha=0.3, beta=0.1)
>>> # Optimize parameters >>> model = ExponentialSmoothingForecaster(optimize=True)
- fit(y, X=None, **fit_params)[source]¶
Fit the exponential smoothing forecaster.
- Parameters:
y (array-like) – Training time series.
X (ignored) – Not used.
- Return type:
- Returns:
self – Fitted forecaster.
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.DriftForecaster(random_state=None, verbose=False)[source]¶
Bases:
BaseForecaster,UnivariateForecasterMixinDrift (random walk with drift) forecaster.
Predicts using the last value plus average historical change. Equivalent to fitting a line between first and last observations.
- Parameters:
Examples
>>> model = DriftForecaster() >>> model.fit(y_train) >>> forecast = model.predict(horizon=10)
Notes
The drift method is equivalent to: y_hat[t+h] = y[t] + h * (y[t] - y[1]) / (t - 1)
This is a useful baseline for trending data where you expect the trend to continue.
- fit(y, X=None, **fit_params)[source]¶
Fit the drift forecaster.
- Parameters:
y (array-like) – Training time series.
X (ignored) – Not used.
- Return type:
- Returns:
self – Fitted forecaster.
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (DriftForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (DriftForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.ThetaForecaster(theta=2.0, seasonal_period=None, random_state=None, verbose=False)[source]¶
Bases:
BaseForecaster,UnivariateForecasterMixinTheta method forecaster.
Implements the Theta method which won the M3 forecasting competition. Decomposes series into two theta lines and combines their forecasts.
- Parameters:
theta (float, default=2.0) – Theta parameter. theta=0 gives linear regression, theta=2 is the standard Theta method.
seasonal_period (int, optional) – If provided, applies seasonal adjustment before forecasting.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
Examples
>>> model = ThetaForecaster(theta=2.0) >>> model.fit(y_train) >>> forecast = model.predict(horizon=12)
Notes
The Theta method: 1. Decomposes series into theta=0 (linear trend) and theta=2 (amplified curvature) 2. Forecasts theta=0 using linear regression 3. Forecasts theta=2 using simple exponential smoothing 4. Combines forecasts (equal weights)
This simple method often outperforms complex approaches on many datasets.
References
Assimakopoulos, V., & Nikolopoulos, K. (2000). The theta model: a decomposition approach to forecasting. International Journal of Forecasting, 16(4), 521-530.
- fit(y, X=None, **fit_params)[source]¶
Fit the Theta forecaster.
- Parameters:
y (array-like) – Training time series.
X (ignored) – Not used.
- Return type:
- Returns:
self – Fitted forecaster.
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (ThetaForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (ThetaForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.ExpandingWindowCV(n_splits=5, initial_train_size=None, val_size=None, gap=0, step_size=None)[source]¶
Bases:
BaseCrossValidatorExpanding window cross-validation for time series.
Training window expands with each fold while validation window remains fixed size.
- Parameters:
n_splits (int, default=5) – Number of folds.
initial_train_size (int, optional) – Initial training set size. If None, computed from n_splits.
val_size (int, optional) – Validation set size. If None, computed from n_splits.
gap (int, default=0) – Number of samples to skip between train and validation.
step_size (int, optional) – How many samples to add per fold. If None, uses val_size.
Examples
>>> cv = ExpandingWindowCV(n_splits=5, initial_train_size=100, val_size=20) >>> for train_idx, val_idx in cv.split(X): ... # train_idx grows with each fold ... pass
- class endgame.timeseries.SlidingWindowCV(n_splits=5, train_size=None, val_size=None, gap=0, step_size=None)[source]¶
Bases:
BaseCrossValidatorSliding window cross-validation for time series.
Both training and validation windows have fixed sizes and slide through the data.
- Parameters:
Examples
>>> cv = SlidingWindowCV(n_splits=5, train_size=100, val_size=20) >>> for train_idx, val_idx in cv.split(X): ... # Both windows slide forward ... pass
- class endgame.timeseries.BlockedTimeSeriesSplit(n_splits=5, gap_before=0, gap_after=0)[source]¶
Bases:
BaseCrossValidatorBlocked time series split for reducing temporal leakage.
Splits data into blocks that respect temporal structure and adds gaps to prevent leakage from adjacent periods.
- Parameters:
Examples
>>> cv = BlockedTimeSeriesSplit(n_splits=5, gap_before=10, gap_after=5) >>> for train_idx, val_idx in cv.split(X): ... pass
- endgame.timeseries.mase(y_true, y_pred, y_train, seasonal_period=1)[source]¶
Mean Absolute Scaled Error.
Scales MAE by the in-sample MAE of a naive seasonal forecast. MASE < 1 means the model outperforms seasonal naive.
- endgame.timeseries.smape(y_true, y_pred)[source]¶
Symmetric Mean Absolute Percentage Error.
- Parameters:
y_true (array-like) – True values.
y_pred (array-like) – Predicted values.
- Return type:
- Returns:
float – SMAPE in percentage (0-200%).
- endgame.timeseries.mape(y_true, y_pred)[source]¶
Mean Absolute Percentage Error.
- Parameters:
y_true (array-like) – True values.
y_pred (array-like) – Predicted values.
- Return type:
- Returns:
float – MAPE in percentage.
- endgame.timeseries.rmsse(y_true, y_pred, y_train)[source]¶
Root Mean Squared Scaled Error.
Used in M5 forecasting competition.
- Parameters:
y_true (array-like) – True values.
y_pred (array-like) – Predicted values.
y_train (array-like) – Training data for scaling.
- Return type:
- Returns:
float – RMSSE score.
- endgame.timeseries.wape(y_true, y_pred)[source]¶
Weighted Absolute Percentage Error.
- Parameters:
y_true (array-like) – True values.
y_pred (array-like) – Predicted values.
- Return type:
- Returns:
float – WAPE in percentage.
- endgame.timeseries.coverage(y_true, lower, upper)[source]¶
Compute prediction interval coverage.
- Parameters:
y_true (array-like) – True values.
lower (array-like) – Lower bounds of prediction intervals.
upper (array-like) – Upper bounds of prediction intervals.
- Return type:
- Returns:
float – Coverage probability (0-1).
- endgame.timeseries.interval_width(lower, upper)[source]¶
Compute average prediction interval width.
- Parameters:
lower (array-like) – Lower bounds.
upper (array-like) – Upper bounds.
- Return type:
- Returns:
float – Mean interval width.
- endgame.timeseries.winkler_score(y_true, lower, upper, alpha=0.05)[source]¶
Compute Winkler score for prediction intervals.
Combines coverage and sharpness. Lower is better.
- class endgame.timeseries.AutoARIMAForecaster(d=None, D=None, max_p=5, max_q=5, max_P=2, max_Q=2, seasonal=True, m=1, stationary=False, ic='aicc', approximation=True, random_state=None, verbose=False)[source]¶
Bases:
StatsForecastWrapperAutoARIMA forecaster via statsforecast.
Automatically selects the best ARIMA model using AIC/BIC. 20x faster than pmdarima.
- Parameters:
d (int, optional) – Order of differencing. If None, auto-selected.
D (int, optional) – Order of seasonal differencing. If None, auto-selected.
max_p (int, default=5) – Maximum p (AR order).
max_q (int, default=5) – Maximum q (MA order).
max_P (int, default=2) – Maximum seasonal P.
max_Q (int, default=2) – Maximum seasonal Q.
seasonal (bool, default=True) – Whether to fit seasonal ARIMA.
m (int, default=1) – Seasonal period.
stationary (bool, default=False) – If True, restricts search to stationary models.
ic (str, default="aicc") – Information criterion: “aicc”, “aic”, “bic”.
approximation (bool, default=True) – Use approximation for speed.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
Examples
>>> # Monthly data with yearly seasonality >>> model = AutoARIMAForecaster(seasonal=True, m=12) >>> model.fit(monthly_sales) >>> forecast = model.predict(horizon=12)
>>> # Non-seasonal ARIMA >>> model = AutoARIMAForecaster(seasonal=False) >>> model.fit(daily_returns)
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (AutoARIMAForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (AutoARIMAForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.AutoETSForecaster(model='ZZZ', season_length=1, damped=None, random_state=None, verbose=False)[source]¶
Bases:
StatsForecastWrapperAutoETS (Error, Trend, Seasonal) forecaster via statsforecast.
Automatically selects the best exponential smoothing model.
- Parameters:
model (str, default="ZZZ") –
ETS model specification (Error, Trend, Seasonal): - Error: A(dditive), M(ultiplicative), Z(auto) - Trend: N(one), A(dditive), Ad(damped additive), M(ultiplicative), Md(damped multiplicative), Z(auto) - Seasonal: N(one), A(dditive), M(ultiplicative), Z(auto) Examples: “AAN” (additive error, additive trend, no seasonal),
”ZZZ” (auto-select all)
season_length (int, default=1) – Seasonal period.
damped (bool, optional) – Whether to use damped trend. If None, auto-selected.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
Examples
>>> # Auto-select ETS model >>> model = AutoETSForecaster(model="ZZZ", season_length=12) >>> model.fit(monthly_sales) >>> forecast = model.predict(horizon=12)
>>> # Specific model: additive error, damped trend, multiplicative seasonal >>> model = AutoETSForecaster(model="AdM", season_length=12)
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (AutoETSForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (AutoETSForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.AutoThetaForecaster(season_length=1, decomposition_type='multiplicative', random_state=None, verbose=False)[source]¶
Bases:
StatsForecastWrapperAutoTheta forecaster via statsforecast.
Implements optimized Theta method with automatic selection.
- Parameters:
Examples
>>> model = AutoThetaForecaster(season_length=12) >>> model.fit(monthly_data) >>> forecast = model.predict(horizon=6)
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (AutoThetaForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (AutoThetaForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.MSTLForecaster(season_lengths=[7], trend_forecaster='auto_arima', stl_kwargs=None, random_state=None, verbose=False)[source]¶
Bases:
BaseForecaster,UnivariateForecasterMixinMSTL (Multiple Seasonal-Trend decomposition using Loess) forecaster.
Handles multiple seasonal patterns (e.g., daily + weekly + yearly). Decomposes series then forecasts trend and seasonal components separately.
- Parameters:
season_lengths (List[int], default=[7]) – List of seasonal periods to model.
trend_forecaster (str, default="auto_arima") – Method for forecasting trend: “auto_arima”, “auto_ets”, “naive”.
stl_kwargs (dict, optional) – Additional arguments for STL decomposition.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
Examples
>>> # Hourly data with daily and weekly seasonality >>> model = MSTLForecaster(season_lengths=[24, 168]) >>> model.fit(hourly_demand) >>> forecast = model.predict(horizon=48)
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (MSTLForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (MSTLForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.CESForecaster(season_length=1, model='Z', random_state=None, verbose=False)[source]¶
Bases:
StatsForecastWrapperComplex Exponential Smoothing forecaster via statsforecast.
Uses complex-valued exponential smoothing for improved accuracy on some data patterns.
- Parameters:
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (CESForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (CESForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.TSFreshFeatureExtractor(preset='efficient', column_id='id', column_sort=None, column_value=None, select_relevant=True, fdr_level=0.05, n_jobs=-1, show_warnings=False)[source]¶
Bases:
BaseEstimator,TransformerMixinSklearn-compatible tsfresh feature extractor.
Wraps tsfresh’s feature extraction with automatic relevance filtering and imputation.
- Parameters:
preset (str, default="efficient") – Feature calculation preset: - “minimal”: ~10 features per column (fast) - “efficient”: ~100 features per column (balanced) - “comprehensive”: ~800 features per column (slow but thorough)
column_id (str, default="id") – Name of the column containing series identifiers.
column_sort (str, optional) – Name of the column to sort by (e.g., timestamp).
column_value (str, optional) – Name of the column containing values (if single-column series).
select_relevant (bool, default=True) – Whether to filter features by relevance to target.
fdr_level (float, default=0.05) – False discovery rate for feature selection.
n_jobs (int, default=-1) – Number of parallel jobs (-1 for all cores).
show_warnings (bool, default=False) – Whether to show tsfresh warnings.
Examples
>>> # Basic usage >>> extractor = TSFreshFeatureExtractor(preset="efficient") >>> features = extractor.fit_transform(df, y=target)
>>> # Without relevance filtering >>> extractor = TSFreshFeatureExtractor(select_relevant=False) >>> features = extractor.transform(df)
- fit(X, y=None, **fit_params)[source]¶
Fit the feature extractor.
- Parameters:
X (DataFrame) – Input data with columns for id, sort, and values.
y (array-like, optional) – Target variable for relevance filtering. Required if select_relevant=True.
- Return type:
- Returns:
self – Fitted extractor.
- class endgame.timeseries.TimeSeriesFeatureExtractor(features=None, window_sizes=[7, 14, 30], lag_range=(1, 10))[source]¶
Bases:
BaseEstimator,TransformerMixinFast time series feature extractor without tsfresh dependency.
Extracts common time series features that are useful for GBDT models. Faster than tsfresh but with fewer features.
- Parameters:
features (List[str], optional) –
Features to extract. If None, extracts all. Options: “statistics”, “trend”, “seasonality”, “autocorr”, “entropy”,
”spectral”, “peaks”, “crossings”.
window_sizes (List[int], default=[7, 14, 30]) – Window sizes for rolling features.
lag_range (tuple, default=(1, 10)) – Range of lags for autocorrelation features.
Examples
>>> extractor = TimeSeriesFeatureExtractor(features=["statistics", "trend"]) >>> features = extractor.fit_transform(time_series_array)
- fit(X, y=None, **fit_params)[source]¶
Fit the extractor (learn feature names).
- class endgame.timeseries.NBEATSForecaster(input_chunk_length=30, output_chunk_length=7, num_stacks=30, num_blocks=1, num_layers=4, layer_widths=256, expansion_coefficient_dim=5, generic_architecture=True, batch_size=32, n_epochs=100, learning_rate=0.001, random_state=None, verbose=False)[source]¶
Bases:
DartsForecasterWrapperN-BEATS (Neural Basis Expansion Analysis) forecaster.
State-of-the-art neural architecture for time series forecasting based on backward and forward residual links.
- Parameters:
input_chunk_length (int, default=30) – Lookback window length.
output_chunk_length (int, default=7) – Forecast horizon for training.
num_stacks (int, default=30) – Number of stacks.
num_blocks (int, default=1) – Number of blocks per stack.
num_layers (int, default=4) – Number of fully connected layers per block.
layer_widths (int, default=256) – Width of fully connected layers.
expansion_coefficient_dim (int, default=5) – Dimension of expansion coefficients.
generic_architecture (bool, default=True) – Whether to use generic architecture (vs interpretable).
batch_size (int, default=32) – Training batch size.
n_epochs (int, default=100) – Number of training epochs.
learning_rate (float, default=1e-3) – Learning rate.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
Examples
>>> model = NBEATSForecaster(input_chunk_length=30, output_chunk_length=7) >>> model.fit(train_data) >>> forecast = model.predict(horizon=7)
References
Oreshkin et al. (2020). “N-BEATS: Neural basis expansion analysis for interpretable time series forecasting.”
- set_fit_request(*, val_y='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
val_y (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
val_yparameter infit.self (NBEATSForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (NBEATSForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (NBEATSForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.NHITSForecaster(input_chunk_length=30, output_chunk_length=7, num_stacks=3, num_blocks=1, num_layers=2, layer_widths=512, batch_size=32, n_epochs=100, learning_rate=0.001, random_state=None, verbose=False)[source]¶
Bases:
DartsForecasterWrapperN-HiTS (Neural Hierarchical Interpolation) forecaster.
Improved version of N-BEATS with hierarchical interpolation for better long-horizon forecasting.
- Parameters:
input_chunk_length (int, default=30) – Lookback window length.
output_chunk_length (int, default=7) – Forecast horizon for training.
num_stacks (int, default=3) – Number of stacks.
num_blocks (int, default=1) – Number of blocks per stack.
num_layers (int, default=2) – Number of FC layers per block.
layer_widths (int, default=512) – Width of FC layers.
batch_size (int, default=32) – Training batch size.
n_epochs (int, default=100) – Number of training epochs.
learning_rate (float, default=1e-3) – Learning rate.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
References
Challu et al. (2022). “N-HiTS: Neural Hierarchical Interpolation for Time Series Forecasting.”
- set_fit_request(*, val_y='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
val_y (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
val_yparameter infit.self (NHITSForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (NHITSForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (NHITSForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.TFTForecaster(input_chunk_length=30, output_chunk_length=7, hidden_size=64, lstm_layers=1, num_attention_heads=4, hidden_continuous_size=8, dropout=0.1, batch_size=32, n_epochs=100, learning_rate=0.001, add_relative_index=True, random_state=None, verbose=False)[source]¶
Bases:
DartsForecasterWrapperTemporal Fusion Transformer forecaster.
Multi-horizon forecasting with interpretable attention mechanism. Handles static, known future, and observed inputs.
- Parameters:
input_chunk_length (int, default=30) – Lookback window length.
output_chunk_length (int, default=7) – Forecast horizon.
hidden_size (int, default=64) – Hidden state size.
lstm_layers (int, default=1) – Number of LSTM layers.
num_attention_heads (int, default=4) – Number of attention heads.
hidden_continuous_size (int, default=8) – Hidden size for continuous variable processing.
dropout (float, default=0.1) – Dropout rate.
batch_size (int, default=32) – Training batch size.
n_epochs (int, default=100) – Number of training epochs.
learning_rate (float, default=1e-3) – Learning rate.
add_relative_index (bool, default=True) – Whether to add relative time index as feature.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
References
Lim et al. (2021). “Temporal Fusion Transformers for Interpretable Multi-horizon Time Series Forecasting.”
- set_fit_request(*, val_y='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
val_y (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
val_yparameter infit.self (TFTForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (TFTForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (TFTForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.PatchTSTForecaster(input_chunk_length=32, output_chunk_length=7, patch_length=16, d_model=128, nhead=4, num_encoder_layers=3, dim_feedforward=256, dropout=0.1, batch_size=32, n_epochs=100, learning_rate=0.001, random_state=None, verbose=False)[source]¶
Bases:
DartsForecasterWrapperPatch Time Series Transformer forecaster.
Transformer model that uses patching for efficient long sequence modeling.
- Parameters:
input_chunk_length (int, default=32) – Lookback window length (should be divisible by patch_length).
output_chunk_length (int, default=7) – Forecast horizon.
patch_length (int, default=16) – Length of each patch.
d_model (int, default=128) – Dimension of the model.
nhead (int, default=4) – Number of attention heads.
num_encoder_layers (int, default=3) – Number of encoder layers.
dim_feedforward (int, default=256) – Feedforward network dimension.
dropout (float, default=0.1) – Dropout rate.
batch_size (int, default=32) – Training batch size.
n_epochs (int, default=100) – Number of training epochs.
learning_rate (float, default=1e-3) – Learning rate.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
References
Nie et al. (2023). “A Time Series is Worth 64 Words: Long-term Forecasting with Transformers.”
- set_fit_request(*, val_y='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
val_y (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
val_yparameter infit.self (PatchTSTForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (PatchTSTForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (PatchTSTForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.DLinearForecaster(input_chunk_length=30, output_chunk_length=7, shared_weights=False, kernel_size=25, batch_size=32, n_epochs=100, learning_rate=0.001, random_state=None, verbose=False)[source]¶
Bases:
DartsForecasterWrapperDLinear forecaster.
Simple linear model with trend-seasonal decomposition. Often competitive with complex transformers while being much faster.
- Parameters:
input_chunk_length (int, default=30) – Lookback window length.
output_chunk_length (int, default=7) – Forecast horizon.
shared_weights (bool, default=False) – Whether to share weights across series.
kernel_size (int, default=25) – Kernel size for moving average decomposition.
batch_size (int, default=32) – Training batch size.
n_epochs (int, default=100) – Number of training epochs.
learning_rate (float, default=1e-3) – Learning rate.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
References
Zeng et al. (2023). “Are Transformers Effective for Time Series Forecasting?”
- set_fit_request(*, val_y='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
val_y (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
val_yparameter infit.self (DLinearForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (DLinearForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (DLinearForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.TimesNetForecaster(input_chunk_length=30, output_chunk_length=7, hidden_size=64, num_encoder_layers=2, num_kernels=6, batch_size=32, n_epochs=100, learning_rate=0.001, random_state=None, verbose=False)[source]¶
Bases:
DartsForecasterWrapperTimesNet forecaster.
Temporal 2D-variation modeling for time series analysis. Converts 1D time series to 2D tensors for pattern extraction.
- Parameters:
input_chunk_length (int, default=30) – Lookback window length.
output_chunk_length (int, default=7) – Forecast horizon.
hidden_size (int, default=64) – Hidden dimension size.
num_encoder_layers (int, default=2) – Number of encoder layers.
num_kernels (int, default=6) – Number of inception kernels.
batch_size (int, default=32) – Training batch size.
n_epochs (int, default=100) – Number of training epochs.
learning_rate (float, default=1e-3) – Learning rate.
random_state (int, optional) – Random seed.
verbose (bool, default=False) – Enable verbose output.
References
Wu et al. (2023). “TimesNet: Temporal 2D-Variation Modeling for General Time Series Analysis.”
- set_fit_request(*, val_y='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
val_y (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
val_yparameter infit.self (TimesNetForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_predict_request(*, horizon='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
predictmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inpredict.self (TimesNetForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- set_score_request(*, horizon='$UNCHANGED$', metric='$UNCHANGED$', y_pred='$UNCHANGED$', y_true='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
horizon (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
horizonparameter inscore.metric (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
metricparameter inscore.y_pred (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_predparameter inscore.y_true (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
y_trueparameter inscore.self (TimesNetForecaster)
- Returns:
self (object) – The updated object.
- Return type:
- class endgame.timeseries.RocketTransformer(n_kernels=10000, normalize=True, random_state=None)[source]¶
Bases:
BaseEstimator,TransformerMixinROCKET (Random Convolutional Kernel Transform) for time series.
Transforms time series using random convolutional kernels with random length, weights, bias, dilation, and padding. Extracts max value and proportion of positive values (PPV) from each convolution.
- Parameters:
Examples
>>> transformer = RocketTransformer(n_kernels=10000) >>> X_transformed = transformer.fit_transform(X_train) >>> print(X_transformed.shape) # (n_samples, 20000)
Notes
ROCKET generates 2 features per kernel: - Maximum value of the convolution - Proportion of positive values (PPV)
For 10,000 kernels (default), this produces 20,000 features.
- class endgame.timeseries.MiniRocketTransformer(n_kernels=10000, random_state=None)[source]¶
Bases:
BaseEstimator,TransformerMixinMiniROCKET transform for time series.
A faster, almost deterministic variant of ROCKET using fixed kernels with limited weight values. Up to 75x faster than ROCKET on large datasets.
- Parameters:
Examples
>>> transformer = MiniRocketTransformer() >>> X_transformed = transformer.fit_transform(X_train)
Notes
Key differences from ROCKET: - Uses fixed kernels of length 9 - Weights restricted to two values (-1 and 2) - Uses 84 fixed convolutions as seeds for dilations - Does NOT require normalized input - Almost deterministic (small random component in dilation selection)
Minimum time series length is 9.
- class endgame.timeseries.MultiRocketTransformer(n_kernels=10000, n_features_per_kernel=4, random_state=None)[source]¶
Bases:
BaseEstimator,TransformerMixinMultiROCKET transform for time series.
Extension of MiniROCKET for multivariate time series with additional pooling operations (mean, standard deviation).
- Parameters:
Examples
>>> transformer = MultiRocketTransformer() >>> X_transformed = transformer.fit_transform(X_train) # Multivariate OK
- class endgame.timeseries.HydraTransformer(n_kernels=8, n_groups=64, random_state=None)[source]¶
Bases:
BaseEstimator,TransformerMixinHYDRA (Hybrid Dictionary-ROCKET) transform for time series.
Combines dictionary methods with convolutional kernels. Uses competing kernels that extract and count symbolic patterns while leveraging kernel transformations.
- Parameters:
Examples
>>> transformer = HydraTransformer(n_kernels=8, n_groups=64) >>> X_transformed = transformer.fit_transform(X_train)
Notes
HYDRA can be combined with ROCKET/MiniROCKET for improved accuracy. A single hyperparameter controls the trade-off between dictionary-like and ROCKET-like behavior.
References
Dempster, A., et al. (2023). “HYDRA: Competing convolutional kernels for fast and accurate time series classification.”
- class endgame.timeseries.RocketClassifier(n_kernels=10000, normalize=True, alphas=None, random_state=None)[source]¶
Bases:
BaseEstimator,ClassifierMixinROCKET classifier for time series classification.
Combines ROCKET transform with RidgeClassifierCV for fast and accurate time series classification.
- Parameters:
- classes_¶
Unique class labels.
- Type:
ndarray
- transformer_¶
Fitted ROCKET transformer.
- Type:
- classifier_¶
Fitted classifier.
- Type:
RidgeClassifierCV
Examples
>>> clf = RocketClassifier(n_kernels=10000) >>> clf.fit(X_train, y_train) >>> predictions = clf.predict(X_test) >>> accuracy = clf.score(X_test, y_test)
Notes
This achieves state-of-the-art accuracy on many UCR datasets while being orders of magnitude faster than deep learning approaches.
- predict(X)[source]¶
Predict class labels.
- Parameters:
X (array-like) – Time series to classify.
- Return type:
- Returns:
np.ndarray – Predicted labels.
- predict_proba(X)[source]¶
Predict class probabilities.
Note: RidgeClassifier doesn’t have native predict_proba. This uses decision function with softmax normalization.
- Parameters:
X (array-like) – Time series to classify.
- Return type:
- Returns:
np.ndarray of shape (n_samples, n_classes) – Class probabilities.
- class endgame.timeseries.MiniRocketClassifier(n_kernels=10000, alphas=None, random_state=None)[source]¶
Bases:
BaseEstimator,ClassifierMixinMiniROCKET classifier for time series classification.
Faster variant of ROCKET using fixed kernels. Up to 75x faster on large datasets while maintaining similar accuracy.
- Parameters:
Examples
>>> clf = MiniRocketClassifier() >>> clf.fit(X_train, y_train) >>> accuracy = clf.score(X_test, y_test)
Notes
Recommended as the default ROCKET variant due to speed and near-deterministic behavior.
- class endgame.timeseries.MultiRocketClassifier(n_kernels=10000, n_features_per_kernel=4, alphas=None, random_state=None)[source]¶
Bases:
BaseEstimator,ClassifierMixinMultiROCKET classifier for multivariate time series.
Extension of MiniROCKET with additional pooling operations.
- Parameters:
- class endgame.timeseries.HydraClassifier(n_kernels=8, n_groups=64, alphas=None, random_state=None)[source]¶
Bases:
BaseEstimator,ClassifierMixinHYDRA classifier for time series classification.
Combines dictionary methods with ROCKET using competing kernels. Often more accurate than ROCKET alone.
- Parameters:
Examples
>>> clf = HydraClassifier() >>> clf.fit(X_train, y_train) >>> accuracy = clf.score(X_test, y_test)
- class endgame.timeseries.HydraMiniRocketClassifier(hydra_kernels=8, hydra_groups=64, minirocket_kernels=10000, alphas=None, random_state=None)[source]¶
Bases:
BaseEstimator,ClassifierMixinCombined HYDRA + MiniROCKET classifier.
Concatenates features from both HYDRA and MiniROCKET for improved accuracy. This combination often achieves the best results.
- Parameters:
Examples
>>> clf = HydraMiniRocketClassifier() >>> clf.fit(X_train, y_train) >>> accuracy = clf.score(X_test, y_test)
Notes
This combination was shown to significantly improve accuracy over either method alone in the HYDRA paper.