Last active
April 6, 2020 05:53
-
-
Save monogenea/cc76296dbeb488880929bd7d29d81d32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Grep species, set colors for heatmap | |
speciesClass <- gsub(colnames(train$Y), pat = "species", rep = "") | |
cols <- colorRampPalette(rev(brewer.pal(n = 7, name = "RdGy"))) | |
# Validation predictions | |
predProb <- predict(model, val$X) | |
predClass <- speciesClass[apply(predProb, 1, which.max)] | |
trueClass <- speciesClass[apply(val$Y, 1, which.max)] | |
# Plot confusion matrix | |
confMat <- confusionMatrix(data = factor(predClass, levels = speciesClass), | |
reference = factor(trueClass, levels = speciesClass)) | |
pheatmap(confMat$table, cluster_rows = F, cluster_cols = F, | |
border_color = NA, show_colnames = F, | |
labels_row = speciesClass, | |
color = cols(max(confMat$table)+1)) | |
# Accuracy in validation set | |
mean(predClass == trueClass) # 0.7541 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment