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)) + tt"l1_ratio" xx alpha ||w||_1 + (1 - tt"l1_ratio") xx alpha/2 ||w||_2 ^ 2`- By default, - l1_ratio=1.0corresponds to Lasso (pure L1 penalty). When- 0 < l1_ratio < 1, the penalty is a convex combination of L1 and L2 (i.e., ElasticNet).- l1_ratio=0.0corresponds to Ridge (pure L2), but note that pure Ridge is not typically used with this class.- 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. Only used when- penalty="l1_plus_l2". For- l1_ratio = 0the penalty is an L2 penalty.- For l1_ratio = 1it is an L1 penalty. For- 0 < 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 accuracy on provided data and labels. - set_params(**params)- Set the parameters of this estimator. - set_score_request(*[, sample_weight])- Configure whether metadata should be requested to be passed to the - scoremethod.- sparsify()- Convert coefficient matrix to sparse format.