SuperGLMRegressor#
- class superglm.SuperGLMRegressor(
- family: str | Distribution = 'poisson',
- penalty: str | Penalty | None = None,
- selection_penalty: float | Literal['auto'] | None = None,
- spline_penalty: float | None = None,
- features: dict | None = None,
- spline_features: list[str | int] | None = None,
- categorical_features: list[str | int] | None = None,
- numeric_features: list[str | int] | None = None,
- feature_names: list[str] | None = None,
- n_knots: int | list[int] = 10,
- degree: int = 3,
- categorical_base: str = 'most_exposed',
- offset: str | int | list[str | int] | None = None,
- weight_semantics: Literal['prior', 'frequency'] = 'prior',
Bases:
BaseEstimator,RegressorMixinPenalised GLM for count / continuous regression.
Accepts DataFrame or ndarray input. See module docstring for details on ndarray mode and penalty defaults.
- Parameters:
- familystr or Distribution
Distribution family. Strings:
"poisson","gamma","gaussian". For parameterized families use objects:families.tweedie(p=1.5),families.nb2(theta=1.0). For binary classification useSuperGLMClassifier.- penaltystr, Penalty, or None
Penalty type.
None(default) means no feature-selection penalty whenselection_penaltyis alsoNoneor zero. Explicit automatic or positive selection strength auto-upgrades to"group_lasso".- selection_penaltyfloat, {“auto”}, or None
Group penalty strength.
Noneand zero disable feature selection;"auto"explicitly calibrates the strength from the fit data.- spline_penaltyfloat or None
Within-group spline smoothing. Defaults to 0.1.
- featuresdict[str, FeatureSpec] or None
Native-style feature specs. Mutually exclusive with the shorthand wrapper arguments (
spline_features,categorical_features,numeric_features, non-defaultn_knots/degree/categorical_base).- spline_featureslist of str or int, or None
Columns to treat as spline features (by name or index).
- categorical_featureslist of str or int, or None
Columns to treat as categorical (by name or index). Required for ndarray input if any columns are categorical.
- numeric_featureslist of str or int, or None
Columns to treat as numeric (by name or index). Unspecified columns default to numeric.
- feature_nameslist of str or None
Column names for ndarray input. Ignored for native DataFrames.
- n_knotsint or list of int
Interior knots for spline features.
- degreeint
B-spline degree (default 3).
- categorical_basestr
Base level strategy (
"most_exposed"or"first").- offsetstr, int, list, or None
Offset column(s) by name or index.
- weight_semantics{“prior”, “frequency”}
What
sample_weightsays about a row."prior"(default) reads it as a precision,Var(Y_i) = phi V(mu_i) / w_i;"frequency"reads it as a replication count, where an integer weight is exactly a repeated row. Passed through toSuperGLM.
- summary( )#
Return the fitted model summary with categorical display control.
- set_fit_request( ) SuperGLMRegressor#
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:
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter infit.
- Returns:
- selfobject
The updated object.
- set_score_request( ) SuperGLMRegressor#
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:
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter inscore.
- Returns:
- selfobject
The updated object.