macrosynergy.learning.forecasting.linear_model.sur#

class LinearMultiTargetRegression(fit_intercept=True, seemingly_unrelated=False, covariance_estimator='ewm', span=60, feature_selection=None)[source]#

Bases: BaseEstimator, RegressorMixin

Linear regression model with multiple targets, supporting seemingly unrelated regression (SUR) via feasible generalized least squares (FGLS).

Parameters:
  • fit_intercept (bool, default=True) – Whether to include an intercept term in the regression.

  • seemingly_unrelated (bool, default=False) – Whether to make the regression seemingly unrelated.

  • covariance_estimator (Union[str, BaseEstimator], default="ewm") – Choice of covariance estimator. Options are “ml” for maximum likelihood, “ewm” for exponentially weighted moving covariance, or a custom scikit-learn compatible covariance estimator.

  • span (int, default=60) – Span parameter for exponentially weighted covariance estimation of residuals.

  • feature_selection (object, default=None) – A feature selection object inheriting from scikit-learn’s SelectorMixin base class in sklearn.feature_selection. If provided, feature selection is applied per target before fitting.

fit(X, y, sample_weight=None)[source]#

Fit the linear multi-target regression model.

Parameters:
  • X (pd.DataFrame) – Feature matrix of shape (n_samples, n_features). Should be multi-indexed by asset and real date.

  • y (pd.DataFrame) – Target matrix of shape (n_samples, n_assets). Should be multi-indexed by asset and real date.

  • sample_weight (array-like of shape (n_samples,), default=None) – Individual weights for each sample.

predict(X)[source]#

Predict method to return predictions for each asset.

Parameters:

X (pd.DataFrame) – Feature matrix of shape (n_samples, n_features). Should be multi-indexed by asset and real date.

set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$') LinearMultiTargetRegression#

Configure whether metadata should be requested to be passed to the fit method.

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 (see sklearn.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 to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • 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.

New in version 1.3.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') LinearMultiTargetRegression#

Configure whether metadata should be requested to be passed to the score method.

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 (see sklearn.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 to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • 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.

New in version 1.3.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

Returns:

self – The updated object.

Return type:

object