View source: R/sparse_regression.R
fit_sparse_regression | R Documentation |
Computes the regularization path for the specified loss function and penalty function.
fit_sparse_regression(
x,
y,
penalty = "L0",
algorithm = "CD",
regulators_num = ncol(x),
cross_validation = FALSE,
n_folds = 10,
seed = 1,
loss = "SquaredError",
nLambda = 100,
nGamma = 5,
gammaMax = 10,
gammaMin = 1e-04,
partialSort = TRUE,
maxIters = 200,
rtol = 1e-06,
atol = 1e-09,
activeSet = TRUE,
activeSetNum = 3,
maxSwaps = 100,
scaleDownFactor = 0.8,
screenSize = 1000,
autoLambda = NULL,
lambdaGrid = list(),
excludeFirstK = 0,
intercept = TRUE,
lows = -Inf,
highs = Inf,
...
)
x |
The matrix of regulators. |
y |
The vector of target. |
penalty |
The type of regularization, default is |
algorithm |
The type of algorithm used to minimize the objective function, default is |
regulators_num |
The number of non-zore coefficients, this value will affect the final performance. The maximum support size at which to terminate the regularization path. Recommend setting this to a small fraction of min(n,p) (e.g. 0.05 * min(n,p)) as L0 regularization typically selects a small portion of non-zeros. |
cross_validation |
Logical value, default is |
n_folds |
The number of folds for cross-validation, default is |
seed |
The random seed for cross-validation, default is |
loss |
The loss function. |
nLambda |
The number of Lambda values to select. |
nGamma |
The number of Gamma values to select. |
gammaMax |
The maximum value of Gamma when using the |
gammaMin |
The minimum value of Gamma when using the |
partialSort |
If |
maxIters |
The maximum number of iterations (full cycles) for |
rtol |
The relative tolerance which decides when to terminate optimization, based on the relative change in the objective between iterations. |
atol |
The absolute tolerance which decides when to terminate optimization, based on the absolute L2 norm of the residuals. |
activeSet |
If |
activeSetNum |
The number of consecutive times a support should appear before declaring support stabilization. |
maxSwaps |
The maximum number of swaps used by |
scaleDownFactor |
This parameter decides how close the selected Lambda values are. |
screenSize |
The number of coordinates to cycle over when performing initial correlation screening. |
autoLambda |
Ignored parameter. Kept for backwards compatibility. |
lambdaGrid |
A grid of Lambda values to use in computing the regularization path. |
excludeFirstK |
This parameter takes non-negative integers. |
intercept |
If |
lows |
Lower bounds for coefficients. |
highs |
Upper bounds for coefficients. |
... |
Parameters for other methods. |
An S3 object describing the regularization path
Hazimeh, Hussein et al. “L0Learn: A Scalable Package for Sparse Learning using L0 Regularization.” J. Mach. Learn. Res. 24 (2022): 205:1-205:8.
Hazimeh, Hussein and Rahul Mazumder. “Fast Best Subset Selection: Coordinate Descent and Local Combinatorial Optimization Algorithms.” Oper. Res. 68 (2018): 1517-1537.
https://github.com/hazimehh/L0Learn/blob/master/R/fit.R
data("example_matrix")
fit <- fit_sparse_regression(
example_matrix[, -1],
example_matrix[, 1]
)
head(coef(fit))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.