skglm.SparseLogisticRegression¶
- class skglm.SparseLogisticRegression(alpha=1.0, l1_ratio=1.0, tol=0.0001, max_iter=20, max_epochs=1000, verbose=0, fit_intercept=True, warm_start=False)[source]¶
Sparse Logistic regression estimator.
The optimization objective for sparse Logistic regression is:
`1 / n_"samples" sum_(i=1)^(n_"samples") log(1 + exp(-y_i x_i^T w)) + alpha ||w||_1`- Parameters:
- alphafloat, default=1.0
Regularization strength; must be a positive float.
- l1_ratiofloat, default=1.0
The ElasticNet mixing parameter, with
0 <= l1_ratio <= 1
. Forl1_ratio = 0
the penalty is an L2 penalty.For l1_ratio = 1
it is an L1 penalty. For0 < l1_ratio < 1
, the penalty is a combination of L1 and L2.- tolfloat, optional
Stopping criterion for the optimization.
- max_iterint, optional
The maximum number of outer iterations (subproblem definitions).
- max_epochsint
Maximum number of prox Newton iterations on each subproblem.
- verbosebool or int
Amount of verbosity.
- fit_interceptbool, optional (default=True)
Whether or not to fit an intercept.
- warm_startbool, optional (default=False)
When set to
True
, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution.
- Attributes:
- classes_ndarray, shape (n_classes, )
A list of class labels known to the classifier.
- coef_ndarray, shape (1, n_features) or (n_classes, n_features)
Coefficient of the features in the decision function.
coef_
is of shape (1, n_features) when the given problem is binary.- intercept_ndarray, shape (1,) or (n_classes,)
constant term in decision function. Not handled yet.
- n_iter_int
Number of subproblems solved to reach the specified tolerance.
- __init__(alpha=1.0, l1_ratio=1.0, tol=0.0001, max_iter=20, max_epochs=1000, verbose=0, fit_intercept=True, warm_start=False)[source]¶
Methods
__init__
([alpha, l1_ratio, tol, max_iter, ...])decision_function
(X)Predict confidence scores for samples.
densify
()Convert coefficient matrix to dense array format.
fit
(X, y)Fit the model according to the given training data.
get_metadata_routing
()Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
predict
(X)Predict class labels for samples in X.
predict_proba
(X)Probability estimates.
score
(X, y[, sample_weight])Return the mean accuracy on the given test data and labels.
set_params
(**params)Set the parameters of this estimator.
set_score_request
(*[, sample_weight])Request metadata passed to the
score
method.sparsify
()Convert coefficient matrix to sparse format.