Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Last active February 22, 2022 09:04
Show Gist options
  • Save MJacobs1985/f5b2b8146496fccdd46c1bec5c4bec9d to your computer and use it in GitHub Desktop.
Save MJacobs1985/f5b2b8146496fccdd46c1bec5c4bec9d to your computer and use it in GitHub Desktop.
training_comp<-training%>%na.omit()
enetgrid<-expand.grid(.lambda=c(0,0.01,.1),
.fraction = seq(0.5, 1 , length=20))
enet1 <- train(rochefant~.-customer, data = training_comp,
preProcess = c("center", "scale"),
method = "enet",
tuneGrid=enetgrid,
trControl = tr)
enet1;summary(enet1);plot(enet1)
enet1pred<-predict(enet1, testing)
pm1values<-data.frame(obs=testing$rochefant,
pred=enet1pred,
wts=testing$weightclasshalv,
cfactor=testing$c.factor,
length=testing$length)
ggplot(pm1values, aes(obs,pred,
colour=length,
size=cfactor)) +
geom_point(alpha=0.3,size=2) +
geom_smooth(method=lm, se=FALSE,colour="red", linetype="dashed")+
geom_abline(slope=1, linetype="dashed") + theme_bw() +
facet_wrap(~wts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment