SuperGLMClassifier#
- class superglm.SuperGLMClassifier(
- 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,
- threshold: float = 0.5,
- weight_semantics: Literal['prior', 'frequency'] = 'prior',
Bases:
BaseEstimator,ClassifierMixinPenalised binomial GLM for binary classification.
Uses
SuperGLM(family="binomial")under the hood. Implements the sklearn classifier contract:classes_,predict,predict_proba,decision_function.Accepts DataFrame or ndarray input. See module docstring for details on ndarray mode and penalty defaults.
- Parameters:
- 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
See
SuperGLMRegressor.- spline_penaltyfloat or None
See
SuperGLMRegressor.- featuresdict[str, FeatureSpec] or None
Native-style feature specs. Mutually exclusive with shorthand wrapper arguments. See
SuperGLMRegressorfor details.- spline_featureslist of str or int, or None
Columns to treat as spline features.
- categorical_featureslist of str or int, or None
Columns to treat as categorical.
- numeric_featureslist of str or int, or None
Columns to treat as numeric.
- feature_nameslist of str or None
Column names for ndarray input.
- n_knotsint or list of int
Interior knots for spline features.
- degreeint
B-spline degree.
- categorical_basestr
Base level strategy.
- offsetstr, int, list, or None
Offset column(s).
- thresholdfloat
Classification threshold for
predict()(default 0.5).- 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.
- predict_proba(X) NDArray#
Return class probabilities, shape
(n_samples, 2).
- predict(X) NDArray#
Return class labels (0 or 1) using the threshold.
- decision_function(X) NDArray#
Return log-odds (linear predictor).
- summary( )#
Return the fitted model summary with categorical display control.
- set_fit_request( ) SuperGLMClassifier#
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( ) SuperGLMClassifier#
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.