Lasso算法

在统计学和机器学习中，Lasso算法（，又译最小绝对值收敛和选择算子、套索算法）是一种同时进行特征选择和正则化（数学）的回归分析方法，旨在增强统计模型的预测准确性和可解释性，最初由斯坦福大学统计学教授罗伯特·蒂布希拉尼于1996年基于Leo Breiman的非负参数推断（Nonnegative Garrote, NNG）提出。Lasso算法最初用于计算最小二乘法模型，这个简单的算法揭示了很多估计量的重要性质，如估计量与岭回归（Ridge regression，也叫吉洪诺夫正则化）和最佳子集选择的关系，Lasso系数估计值和软阈值（soft thresholding）之间的联系。它也揭示了当协变量共线时，Lasso系数估计值不一定唯一（类似标准线性回归）。
虽然最早是为应用最小二乘法而定义的算法，lasso正则化可以简单直接地拓展应用于许多统计学模型上，包括广义线性模型，广义估计方程，成比例灾难模型和M-估计。Lasso选择子集的能力依赖于限制条件的形式并且有多种表现形式，包括几何学，贝叶斯统计，和凸分析。
Lasso算法与基追踪降噪联系紧密。
历史来源.
蒂布希拉尼最初使用Lasso来提高预测的准确性与回归模型的可解释性，他修改了模型拟合的过程，在协变量中只选择一个子集应用到最终模型中，而非用上全部协变量。这是基于有着相似目的，但方法有所不同的Breiman的非负参数推断。
在Lasso之前，选择模型中协变量最常用的方法是移步选择，这种方法在某些情况下是准确的，例如一些协变量与模型输出值有强相关性情况。然而在另一些情况下，这种方法会让预测结果更差。在当时，岭回归是提高模型预测准确性最常用的方法。岭回归可以通过缩小大的回归系数来减少过拟合从而改善模型预测偏差。但是它并不选择协变量，所以对模型的准确构建和解释没有帮助。
Lasso结合了上述的两种方法，它通过强制让回归系数绝对值之和小于某固定值，即强制一些回归系数变为0，有效地选择了不包括这些回归系数对应的协变量的更简单的模型。这种方法和岭回归类似，在岭回归中，回归系数平方和被强制小于某定值，不同点在于岭回归只改变系数的值，而不把任何值设为0。
基本形式.
Lasso最初为了最小二乘法而被设计出来，Lasso的最小二乘法应用能够简单明了地展示Lasso的许多特性。
最小二乘.
假设一个样本包括N种事件，每个事件包括"p"个协变量和一个输出值。让formula_1为输出值，并且formula_2为第i种情况的协变量向量，那么Lasso要计算的目标方程就是： 
对所有 formula_3，计算 formula_4 
这里 formula_5 是一个决定规则化程度的预定的自由参数。 设formula_6为协变量矩阵，那么 formula_7，其中 formula_8 是 formula_9的第 "i" 行，那么上式可以写成更紧凑的形式：
这里 formula_12 是标准 formula_13 范数，formula_14是formula_15维的1的向量。
因为 formula_16，所以有
对变量进行中心化是常用的数据处理方法。并且协方差一般规范化为 formula_18 ，这样得到的解就不会依赖测量的规模。
它的目标方程还可以写为：
其拉格朗日形式为：
其中 formula_21 和 formula_22 的关系取决于数据特征。
正交协变量.
现在考虑一些Lasso回归估计的基本性质。
首先假定所有的协变量都是正交的，即 formula_23，其中formula_24 为 克罗内克δ函数。等价的矩阵写法为 formula_25，使用次梯度法可有如下的表达形式
formula_27 用于表示软阈值算子，当这个值非常小的时候为0。一个与之相近的记号formula_28用来表示硬阈值算子，将较小的数值记为0的同时保留原有的较大数值。
与岭回归相比较，其中岭回归的目标在于最小化
即有
因此岭回归是对OLS回归中所有的系数以一致的系数formula_31缩放，并不会进行变量选择。
同样也可以对best subset selection算法进行比较，其目标在于最小化
其中 formula_33 表示 "formula_34 norm"，即0范数，被定义为该向量中非零元的个数。在这个例子中，可以得到
其中 formula_28 被称为软阈值算子，formula_37 为示性函数。
总的来说，Lasso估计量展现出了岭回归和最佳子划分算法的系数收缩的优点，使得部分系数为0。此外，在岭回归全部使用一个常数系数缩放的时候，Lasso回归会将一个接近0的系数变为0。
相关协变量.
对于一般的情况中，不同的协变量之间可能并不是独立的，其中一种特例即为变量存在重复，例如变量j和变量k，有formula_38，formula_39。在这种情况下参数 formula_40 和 formula_41的Lasso回归的估计量不是唯一确定的。
事实上，如果有一些 formula_42 中存在 formula_43，寻找一个formula_44进行变换，将formula_45变换为formula_46 的同时有 formula_47 变换为 formula_48，并保留其他参数不变，此时Lasso回归具有有效的连续性质。一些基于Lasso回归的改进，例如弹性网络正则化，旨在解决这个缺点。
一般形式.
Lasso正则化可以扩展为其他目标函数，例如广义线性模型，广义估计方程，比例风险模型和M估计。 有目标函数
其中Lasso正则化回归给出了下面模型的估计量
在这里只有formula_51是一个惩罚项，formula_52是一个自由变量，与最基本的模型中的 formula_53 变量一样。
算法解释.
几何解释.
Lasso回归可以使得某些项系数为0，从几何上来看，不同约束边界形状的岭回归则不能。他们都可以解释为最小化相同的目标函数
但是有不同的约束条件：在Lasso回归中为 formula_55 而在岭回归中为 formula_56。
The figure shows that the constraint region defined by the formula_57 norm is a square rotated so that its corners lie on the axes (in general a cross-polytope), while the region defined by the formula_58 norm is a circle (in general an "n"-sphere), which is rotationally invariant and, therefore, has no corners. As seen in the figure, a convex object that lies tangent to the boundary, such as the line shown, is likely to encounter a corner (or a higher-dimensional equivalent) of a hypercube, for which some components of formula_51 are identically zero, while in the case of an "n"-sphere, the points on the boundary for which some of the components of formula_51 are zero are not distinguished from the others and the convex object is no more likely to contact a point at which some components of formula_51 are zero than one for which none of them are.
Making λ easier to interpret with an accuracy-simplicity tradeoff.
The lasso can be rescaled so that it becomes easy to anticipate and influence the degree of shrinkage associated with a given value of formula_22. It is assumed that formula_9 is standardized with z-scores and that formula_64 is centered (zero mean). Let formula_65 represent the hypothesized regression coefficients and let formula_66 refer to the data-optimized ordinary least squares solutions. We can then define the Lagrangian as a tradeoff between the in-sample accuracy of the data-optimized solutions and the simplicity of sticking to the hypothesized values. This results in
where formula_68 is specified below. The first fraction represents relative accuracy, the second fraction relative simplicity, and formula_69 balances between the two.
Given a single regressor, relative simplicity can be defined by specifying formula_70 as formula_71, which is the maximum amount of deviation from formula_65 when formula_73. Assuming that formula_74, the solution path can be defined in terms of formula_75:
If formula_77, the ordinary least squares solution (OLS) is used. The hypothesized value of formula_78 is selected if formula_69 is bigger than formula_75. Furthermore, if formula_81, then formula_69 represents the proportional influence of formula_78. In other words, formula_84 measures in percentage terms the minimal amount of influence of the hypothesized value relative to the data-optimized OLS solution.
If an formula_85-norm is used to penalize deviations from zero given a single regressor, the solution path is given by
formula_86. Like formula_87, formula_88 moves in the direction of the point formula_89 when formula_69 is close to zero; but unlike formula_87, the influence of formula_75 diminishes in formula_88 if formula_69 increases (see figure). <br>Given multiple regressors, the moment that a parameter is activated (i.e. allowed to deviate from formula_65) is also determined by a regressor's contribution to formula_75 accuracy. First, 
An formula_75 of 75% means that in-sample accuracy improves by 75% if the unrestricted OLS solutions are used instead of the hypothesized formula_65 values. The individual contribution of deviating from each hypothesis can be computed with the formula_100 x formula_100 matrix 
where formula_103. If formula_104 when formula_75 is computed, then the diagonal elements of formula_106 sum to formula_75. The diagonal formula_106 values may be smaller than 0 or, less often, larger than 1. If regressors are uncorrelated, then the formula_109 diagonal element of formula_106 simply corresponds to the formula_111 value between formula_112 and formula_64.
A rescaled version of the adaptive lasso of can be obtained by setting formula_114. If regressors are uncorrelated, the moment that the formula_109 parameter is activated is given by the formula_109 diagonal element of formula_106. Assuming for convenience that formula_65 is a vector of zeros,
That is, if regressors are uncorrelated, formula_69 again specifies the minimal influence of formula_65. Even when regressors are correlated, the first time that a regression parameter is activated occurs when formula_69 is equal to the highest diagonal element of formula_106.
These results can be compared to a rescaled version of the lasso by defining formula_124, which is the average absolute deviation of formula_66 from formula_65. Assuming that regressors are uncorrelated, then the moment of activation of the formula_109 regressor is given by
For formula_129, the moment of activation is again given by formula_130. If formula_65 is a vector of zeros and a subset of formula_132 relevant parameters are equally responsible for a perfect fit of formula_81, then this subset is activated at a formula_69 value of formula_135. The moment of activation of a relevant regressor then equals formula_136. In other words, the inclusion of irrelevant regressors delays the moment that relevant regressors are activated by this rescaled lasso. The adaptive lasso and the lasso are special cases of a '1ASTc' estimator. The latter only groups parameters together if the absolute correlation among regressors is larger than a user-specified value.
Bayesian interpretation.
Just as ridge regression can be interpreted as linear regression for which the coefficients have been assigned normal prior distributions, lasso can be interpreted as linear regression for which the coefficients have Laplace prior distributions. The Laplace distribution is sharply peaked at zero (its first derivative is discontinuous at zero) and it concentrates its probability mass closer to zero than does the normal distribution. This provides an alternative explanation of why lasso tends to set some coefficients to zero, while ridge regression does not.
Convex relaxation interpretation.
Lasso can also be viewed as a convex relaxation of the best subset selection regression problem, which is to find the subset of formula_137 covariates that results in the smallest value of the objective function for some fixed formula_138, where n is the total number of covariates. The "formula_34 norm", formula_140, (the number of nonzero entries of a vector), is the limiting case of "formula_141 norms", of the form formula_142 (where the quotation marks signify that these are not really norms for formula_143 since formula_144 is not convex for formula_143, so the triangle inequality does not hold). Therefore, since p = 1 is the smallest value for which the "formula_13 norm" is convex (and therefore actually a norm), lasso is, in some sense, the best convex approximation to the best subset selection problem, since the region defined by formula_147 is the convex hull of the region defined by formula_148 for formula_143.
应用.
LASSO已被应用于经济和金融领域，可以改善预测结果并选择有时被忽视的变量。例如：公司破产预测和高增长公司预测。