Esc
Ask AIAnswers may be inaccurate; check the linked pages.Esc
Ask anything about these docs, like how to get started or what a function does.

XgboostHyperparams

chronax.models.xgboost_model.XgboostHyperparams · inherits PydanticBaseModel

(No prose summary provided in docstring.)

Attributes

Attribute Type Default Description
n_estimators int - Number of boosting rounds
max_depth int - Maximum tree depth
learning_rate float - Learning rate
reg_alpha float 0.0 L1 regularization strength (optional)
reg_lambda float 1.0 L2 regularization strength (optional)
subsample float 0.8 Subsample ratio of the training instances (optional)
colsample_bytree float 0.8 Subsample ratio of columns for each tree (optional)
min_child_weight int 1 Minimum sum of instance weight needed in a child (optional)
gamma float 0.0 Minimum loss reduction required to make a further partition (optional)

XgboostModel

chronax.models.xgboost_model.XgboostModel · inherits BaseModel

Multivariate XGBoost model implementation for time series forecasting. This model extends the univariate XGBoost to handle multiple target variables simultaneously. Uses sklearn's MultiOutputRegressor to handle multiple targets with advanced feature engineering.

__init__(self, params: Dict[str, Any], settings: Dict[str, Any])

Initialize XGBoost model with a given configuration.

Parameter Type Default Description
params Dict[str, Any] - Model parameters dictionary
settings Dict[str, Any] - Settings dictionary containing device, python_version, etc.

train(self, y_context: numpy.ndarray, y_target: numpy.ndarray, timestamps_context: numpy.ndarray, timestamps_target: numpy.ndarray, x_context: Optional[numpy.ndarray] = None, x_target: Optional[numpy.ndarray] = None, **kwargs) -> XgboostModel

Train the Multivariate XGBoost model for direct multi-output forecasting.

TECHNIQUE: Advanced Multivariate Feature Engineering with Gradient Boosting - Creates lag features from all target variables - Adds rolling statistics per target (mean, std, min, max, median, trend, range, IQR) - Includes cross-correlation and ratio features between target pairs - Incorporates temporal patterns (weekly means if window ≥ 7) - Uses XGBoost's gradient boosting with MultiOutputRegressor for non-linear pattern learning

Parameter Type Default Description
y_context np.ndarray - Past target values (DataFrame for multivariate)
y_target np.ndarray - Future target values (optional, for validation)
timestamps_context np.ndarray - Timestamps for y_context (optional)
timestamps_target np.ndarray - Timestamps for y_target (optional)
x_context Optional[np.ndarray] None (undocumented)
x_target Optional[np.ndarray] None (undocumented)
**kwargs - Additional keyword arguments

Returns: Self (The fitted model instance).

rolling_predict(self, y_context: numpy.ndarray, timestamps_context: numpy.ndarray, timestamps_target: numpy.ndarray, **kwargs) -> numpy.ndarray

Autoregressive rolling prediction for Multivariate XGBoost. Predicts the entire length of y_target by repeatedly using its own predictions as context.

Parameter Type Default Description
y_context np.ndarray - Historical context data with shape (timesteps, num_targets)
timestamps_context np.ndarray - Timestamps for context data
timestamps_target np.ndarray - Timestamps for target data
**kwargs - Additional keyword arguments

Returns: np.ndarray (Predictions with shape (num_targets, forecast_steps)).

predict(self, y_context: numpy.ndarray, timestamps_context: numpy.ndarray, timestamps_target: numpy.ndarray, x_context: Optional[numpy.ndarray] = None, x_target: Optional[numpy.ndarray] = None, **kwargs) -> numpy.ndarray

Make predictions using the trained Multivariate XGBoost model.

TECHNIQUE: Autoregressive Rolling Window Multi-step Forecasting with Advanced Features - Uses last lookback_window values to create comprehensive multivariate features - Predicts forecast_horizon steps ahead using trained MultiOutputRegressor - Uses its own predictions to update the window and predict further steps - Repeats until forecast_steps are reached

Parameter Type Default Description
y_context np.ndarray - Historical context data
timestamps_context np.ndarray - Timestamps for context data
timestamps_target np.ndarray - Timestamps for target data
x_context Optional[np.ndarray] None (undocumented)
x_target Optional[np.ndarray] None (undocumented)
**kwargs - Additional keyword arguments

Returns: np.ndarray (Model predictions with shape (forecast_steps, num_targets)).

Raises: * ValueError: If Model is not trained yet.