macrosynergy.learning.forecasting.meta_estimators.country_by_country_regressions#
- class CountryByCountryRegression(estimator, min_xs_samples=32)[source]#
Bases:
BaseEstimator,MetaEstimatorMixin,RegressorMixinMetaEstimator to fit a scikit-learn-compatible regressor on each country’s data slice in a panel. If a country has fewer samples than min_xs_samples, a global model is used for the sake of prediction.
- Parameters:
Notes
Country by country regressions model a panel through a “bottoms-up” approach, treating each country as a separate regression problem. This is useful when a panel is particularly heterogeneous or each time series in the panel is long. Short time series results in a low-bias, high-variance model that tends to underperform a global forecasting model. Regularization on each country-specific model can help improve performance.
- predict(X)[source]#
Predict the target values for the given input data.
- Parameters:
X (pd.DataFrame) – Input features for prediction.
- Returns:
Predicted target values.
- Return type:
np.ndarray
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') CountryByCountryRegression#
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.