class documentation
class SparseLinearRegressor(BaseSparseEstimator, RegressorMixin): (source)
Constructor: SparseLinearRegressor(k, gamma, normalize, max_iters, ...)
Sparse linear model for regression.
The model is trained using the L2 loss function and the L2 regularization penalty. The optimal features are selected using a scalable cutting plane algorithm.
Method | _fit |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _make |
Undocumented |
Method | _pre |
Normalize the target variable. |
Method | _predict |
Perform inference using the fitted model. |
Instance Variable | _scaler |
Undocumented |
Inherited from BaseSparseEstimator
:
Method | __init__ |
Model constructor. |
Method | fit |
Fit the model to the training data. |
Method | predict |
Predict using the fitted model. |
Instance Variable | feature |
Set of features that are mutually exclusive. For example, if feature_groups=[{0, 1}, {2, 3}] , then at most one features 0 and 1 will be selected, and at most one features 2 and 3 will be selected. This can be used to encode prior knowledge about the problem. |
Instance Variable | gamma |
The regularization parameter. If None , then gamma is set to 1 / sqrt(n_samples) . |
Instance Variable | k |
The sparsity parameter (i.e. number of non-zero coefficients). If None , then k is set to the square root of the number of features, rounded to the nearest integer. |
Instance Variable | max |
The maximum number of iterations. |
Instance Variable | normalize |
Whether to normalize the data before fitting the model. |
Instance Variable | random |
Controls the random seed for the initial guess if a user-defined initial guess is not provided. |
Instance Variable | solver |
The solver to use for the optimization problem. The available options are "CBC" and "GUROBI". Support for the "HiGHS" solver is also planned for a future release. |
Instance Variable | start |
The initial guess for the selected features. For example if start={0, 1, 2} , then the first three features will be selected. If None , then the initial guess is randomly selected. Providing a good initial guess based on problem-specific knowledge can significantly speed up the search. |
Instance Variable | tol |
The tolerance for the stopping criterion. |
Instance Variable | verbose |
Whether to enable logging of the search progress. |
Property | coef |
Get the coefficients of the linear model. |
Property | intercept |
Get the intercept of the linear model. |
Method | _validate |
Undocumented |
Class Variable | _parameter |
Undocumented |
Instance Variable | _coef |
Undocumented |
Instance Variable | _gamma |
Undocumented |
Instance Variable | _k |
Undocumented |
Instance Variable | _scaler_ |
Undocumented |
def _make_callback(self, X:
np.ndarray
, y: np.ndarray
) -> Callable[ [ np.ndarray], tuple[ float, np.ndarray]]
:
(source)
¶
Undocumented
Perform inference using the fitted model.
Parameters | |
X:np.ndarray | The training data. The array should be of shape (n_samples, n_features). |
proba:bool | Not used. Exists for interoperability with the sparse linear classifier. |
Returns | |
np.ndarray | The predicted values. The array will be of shape (n_samples,). |