skglm.GeneralizedLinearEstimatorCV#
- class skglm.GeneralizedLinearEstimatorCV(datafit, penalty, solver, alphas=None, l1_ratio=None, cv=4, n_jobs=1, random_state=None, eps=0.001, n_alphas=100)[source]#
Cross-validated wrapper for GeneralizedLinearEstimator.
This class performs cross-validated selection of the regularization parameter(s) for a generalized linear estimator, supporting both L1 and elastic-net penalties.
- Parameters:
- datafitobject
Datafit (loss) function instance (e.g., Logistic, Quadratic).
- penaltyobject
Penalty instance with an ‘alpha’ parameter (and optionally ‘l1_ratio’).
- solverobject
Solver instance to use for optimization.
- alphasarray-like of shape (n_alphas,), optional
List of alpha values to try. If None, they are set automatically.
- l1_ratiofloat or array-like, optional
The ElasticNet mixing parameter(s), with 0 <= l1_ratio <= 1. Only used if the penalty supports ‘l1_ratio’. If None, defaults to 1.0 (Lasso).
- cvint, default=4
Number of cross-validation folds.
- n_jobsint, default=1
Number of jobs to run in parallel for cross-validation.
- random_stateint or None, default=None
Random seed for cross-validation splitting.
- epsfloat, default=1e-3
Ratio of minimum to maximum alpha if alphas are set automatically.
- n_alphasint, default=100
Number of alphas along the regularization path if alphas are set automatically.
- Attributes:
- alpha_float
Best alpha found by cross-validation.
- l1_ratio_float or None
Best l1_ratio found by cross-validation (if applicable).
- best_estimator_GeneralizedLinearEstimator
Estimator fitted on the full data with the best parameters.
- coef_ndarray
Coefficients of the fitted model.
- intercept_float or ndarray
Intercept of the fitted model.
- alphas_ndarray
Array of alphas used in the search.
- scores_path_ndarray
Cross-validation scores for each parameter combination.
- n_iter_int or None
Number of iterations run by the solver (if available).
- n_features_in_int or None
Number of features seen during fit.
- feature_names_in_ndarray or None
Names of features seen during fit.
- __init__(datafit, penalty, solver, alphas=None, l1_ratio=None, cv=4, n_jobs=1, random_state=None, eps=0.001, n_alphas=100)[source]#
Methods
__init__
(datafit, penalty, solver[, alphas, ...])fit
(X, y)Fit the model using cross-validation.
get_metadata_routing
()Get metadata routing of this object.
get_params
([deep])Get parameters of the estimators including the datafit's and penalty's.
predict
(X)Predict target values for samples in X.
predict_proba
(X)score
(X, y)set_params
(**params)Set the parameters of this estimator.