Lasso
- 16. 程式 and 模擬
#生成 data
n=10000
x1=rnorm(n,5,1)
x2=rnorm(n,10,2)
x3=rnorm(n,15,3)
x4=rnorm(n,20,4)
x5=rnorm(n,25,5)
x6=rnorm(n,30,6)
x7=rnorm(n,35,7)
x8=rnorm(n,40,8)
y= 20*x1+10*x2+0.1*x3+10*x4+0.1*x5 + rnorm(n,0,1)
- 17. 程式 and 模擬
x=matrix(c( x1,x2,x3,x4,x5,x6,x7,x8 ),ncol=8)
gt <- cv.glmnet(x, y)
gt.coef <- coef(gt$glmnet.fit, s = gt$lambda.1se)
plot(gt)
- 21. 實例
利用lasso進行建 model and predict (*0.985)
Kaggle N0.1201
再加上 machine learning
Kaggle N0.398
two model 合併
Kaggle N0.315