Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Created February 21, 2022 15:40
Show Gist options
  • Save MJacobs1985/d22d884e10af32a946038aa74b9cece4 to your computer and use it in GitHub Desktop.
Save MJacobs1985/d22d884e10af32a946038aa74b9cece4 to your computer and use it in GitHub Desktop.
stopCluster(cl)
registerDoSEQ()
cl <- makeCluster(8)
registerDoParallel(cl)
pm1 <- train(rochefant~. -customer, data = training,
preProcess = c("center", "scale"),
method = "glmnet",
trControl = tr,
na.action = na.omit)
arrange(pm1$results, RMSE) %>% head
summary(pm1)
plot(pm1)
plot(varImp(pm1))
pm1$bestTune
testing_comp<-testing%>%na.omit()
testing_comp$pred<-predict(pm1, testing)
ggplot(testing_comp, aes(rochefant,pred,
colour=as.factor(slaughtermonth))) +
geom_point(alpha=0.3, size=1) +
geom_smooth(method=lm, se=FALSE, linetype="dashed", size=1)+
geom_abline(slope=1, linetype="dashed") + theme_bw() +
facet_wrap(~slaughteryear)+theme_bw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment