macrosynergy.learning.forecasting.model_systems.base_regression_system#
- class BaseRegressionSystem(roll='full', min_xs_samples=2, data_freq=None)[source]#
Bases:
BaseEstimator,RegressorMixin,ABC- fit(X, y)[source]#
Fit a regression on each cross-section of a panel, subject to availability.
- Parameters:
X (pd.DataFrame) – Input feature matrix.
y (pd.Series, pd.DataFrame or np.ndarray) – Target variable.
- Returns:
self – Fitted regression system object.
- Return type:
- predict(X)[source]#
Make predictions over a panel dataset based on trained observation-specific models.
- Parameters:
X (pd.DataFrame) – Input feature matrix.
- Returns:
predictions – Pandas series of predictions, multi-indexed by cross-section and date.
- Return type:
pd.Series
- roll_dates(roll, X_section, y_section, unique_dates)[source]#
Adjust dataset to be contained within a rolling window.
- Parameters:
- Returns:
X_section (pd.DataFrame) – Input feature matrix for the cross-section, adjusted for the rolling window.
y_section (pd.Series) – Target variable for the cross-section, adjusted for the rolling window.
- abstract store_model_info(section, model)[source]#
Store necessary model information for explainability.
- Parameters:
section (str) – The identifier of the cross-section.
model (RegressorMixin) – The fitted regression model.
Notes
Must be overridden.
- abstract create_model()[source]#
Instantiate a regression model for a given cross-section.
Notes
Must be overridden.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') BaseRegressionSystem#
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.New in version 1.3.