Week5 Lasso Regression
1.Feature selection
1)All subsets
每一个特征都有可能包含或者不包含共有
2)Greedy algorithms
Forward stepwise algorithm
从0特征开始,每次增加一个特征(保留之前的结果)
用validation_set(数据量较小时需要cross validation)计算 ,直到 是停止算法。
3)Regularize
Ridge regression(L2 regularized regression)
L2 encourage
Lasso regression(L1 regularized regression)
L1 sparse
【注意】lasso的
-----------------------------------
由于L1 norm是不可导的,故Lasso不能像Ridge一样采用Gradient Decent算法,而应采用Subgradient Decent算法:
Coodinate descent
1)feature matrix可以先normalize(归一化)
【注意】归一化针对每一个
2)Lasso的结果
3)Lasso的代码(Cyclical coordinate descent)
coodinate(指一次处理一个) descent是固定其他w参数而变更wi :
更新
For each iteration:
1)As you loop over features in order and perform coordinate descent, measure how much each coordinate changes.
2)After the loop, if the maximum change across all coordinates is falls below the tolerance, stop. Otherwise, go back to step 1.
4)Lasso和Ridge的区别(待补充)
lasso是sparse会将一部分w舍弃(置为0,所以是feature selection),而ridge使w趋近0但不会为0
为什么lasso可以将w置0,而ridge不行?
从几何图形上可以理解;
如上图为两特征的
ridge的solution为椭圆与圆相切的点,很明显不能使
以ridge为例,对某一个特定