public class LASSO
extends java.lang.Object
The Lasso typically yields a sparse solution, of which the parameter vector β has relatively few nonzero coefficients. In contrast, the solution of L2-regularized least squares (i.e. ridge regression) typically has all coefficients nonzero. Because it effectively reduces the number of variables, the Lasso is useful in some contexts.
For over-determined systems (more instances than variables, commonly in machine learning), we normalize variables with mean 0 and standard deviation 1. For under-determined systems (less instances than variables, e.g. compressed sensing), we assume white noise (i.e. no intercept in the linear model) and do not perform normalization. Note that the solution is not unique in this case.
There is no analytic formula or expression for the optimal solution to the L1-regularized least squares problems. Therefore, its solution must be computed numerically. The objective function in the L1-regularized least squares is convex but not differentiable, so solving it is more of a computational challenge than solving the L2-regularized least squares. The Lasso may be solved using quadratic programming or more general convex optimization methods, as well as by specific algorithms such as the least angle regression algorithm.
Constructor and Description |
---|
LASSO() |
Modifier and Type | Method and Description |
---|---|
static LinearModel |
fit(smile.data.formula.Formula formula,
smile.data.DataFrame data)
Fits a L1-regularized least squares model.
|
static LinearModel |
fit(smile.data.formula.Formula formula,
smile.data.DataFrame data,
double lambda)
Fits a L1-regularized least squares model.
|
static LinearModel |
fit(smile.data.formula.Formula formula,
smile.data.DataFrame data,
double lambda,
double tol,
int maxIter)
Fits a L1-regularized least squares model.
|
static LinearModel |
fit(smile.data.formula.Formula formula,
smile.data.DataFrame data,
java.util.Properties prop)
Fits a L1-regularized least squares model.
|
public static LinearModel fit(smile.data.formula.Formula formula, smile.data.DataFrame data)
formula
- a symbolic description of the model to be fitted.data
- the data frame of the explanatory and response variables.
NO NEED to include a constant column of 1s for bias.public static LinearModel fit(smile.data.formula.Formula formula, smile.data.DataFrame data, java.util.Properties prop)
prop
include
smile.lasso.lambda
is the shrinkage/regularization parameter. Large lambda means more shrinkage.
Choosing an appropriate value of lambda is important, and also difficult.
smile.lasso.tolerance
is the tolerance for stopping iterations (relative target duality gap).
smile.lasso.max.iterations
is the maximum number of IPM (Newton) iterations.
formula
- a symbolic description of the model to be fitted.data
- the data frame of the explanatory and response variables.
NO NEED to include a constant column of 1s for bias.prop
- Training algorithm hyper-parameters and properties.public static LinearModel fit(smile.data.formula.Formula formula, smile.data.DataFrame data, double lambda)
formula
- a symbolic description of the model to be fitted.data
- the data frame of the explanatory and response variables.
NO NEED to include a constant column of 1s for bias.lambda
- the shrinkage/regularization parameter.public static LinearModel fit(smile.data.formula.Formula formula, smile.data.DataFrame data, double lambda, double tol, int maxIter)
formula
- a symbolic description of the model to be fitted.data
- the data frame of the explanatory and response variables.
NO NEED to include a constant column of 1s for bias.lambda
- the shrinkage/regularization parameter.tol
- the tolerance for stopping iterations (relative target duality gap).maxIter
- the maximum number of IPM (Newton) iterations.