Chapter 22 Predictions using glmnet Model

We predict using the glmnet model.

AuthorGLM = train(formula, data = labeledTerms,
                  method = "glmnet",trControl = fitControl,
                  na.action = na.pass,metric="LogLoss", maximize=FALSE)  

predictions = predict(AuthorGLM,labeledTermsTest,type = 'prob')

# Save the solution to a dataframe
solution <- data.frame('id' = test$id, predictions)

head(solution)
##        id       EAP        HPL         MWS
## 1 id02310 0.1483739 0.05823763 0.793388478
## 2 id24541 0.1367529 0.84022349 0.023023574
## 3 id00134 0.4635034 0.53113157 0.005365013
## 4 id27757 0.1716008 0.82497320 0.003425992
## 5 id04081 0.7116491 0.10344372 0.184907176
## 6 id27337 0.4591286 0.53811284 0.002758600
# Write it to file
write.csv(solution, 'GLMNetEDASpooky29Oct2017.csv', row.names = F)