Skip to content

Instantly share code, notes, and snippets.

@monogenea
Last active April 6, 2020 05:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monogenea/d1f9de7b2bd5e03af9863b08a9004dd3 to your computer and use it in GitHub Desktop.
Save monogenea/d1f9de7b2bd5e03af9863b08a9004dd3 to your computer and use it in GitHub Desktop.
# Test set prediction
predXProb <- predict(model, test$X)
predXClass <- speciesClass[apply(predXProb, 1, which.max)]
trueXClass <- speciesClass[apply(test$Y, 1, which.max)]
# Plot confusion matrix
confMatTest <- confusionMatrix(data = factor(predXClass, levels = speciesClass),
reference = factor(trueXClass, levels = speciesClass))
pheatmap(confMatTest$table, cluster_rows = F, cluster_cols = F,
border_color = NA, show_colnames = F,
labels_row = speciesClass,
color = cols(max(confMatTest$table)+1))
# Accuracy in test set
mean(predXClass == trueXClass) # 0.7364
# Write sessioninfo
writeLines(capture.output(sessionInfo()), "sessionInfo")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment