topepo / APM_Exercises

Exercises for the book Applied Predictive Modeling by Kuhn and Johnson (2013)
194 stars 158 forks source link

Ex 6.1: added more low tuning values for enet mod #2

Closed pekaalto closed 9 years ago

pekaalto commented 9 years ago

Hi, The optimal parameter for L1 penalty in Lasso model seems to be 0.02. This low values were omitted from the original tuning grid.

Also, predictors(meatENet) returns NULL, which in turn makes length(predictors(meatENet)) to 0.

I am not sure if predictors( <<enetModel>> ) is broken in caret or it was never even intended to work that way. Maybe worth checking out. Now I couldn't find a way to pull the coefficients from the enet model trained by caret. Would be nice if there were a way.

It seems that it's possible to get them like this:

enetFit = enet(x = absorpTrain, y = proteinTrain,lambda=0)
coef_set = predict(enetFit,type="coefficients",s=0.02,mode="fraction")
sum(abs(coef_set$coefficients) > 0.00001)

But for this the model is needed again so it's not so handy. I omitted this from the pull req.

topepo commented 9 years ago

looks great!

Thanks,

Max