Merge changes I02169a8a,I23fa3680,Iee2355e0,Iae35113f
* changes:
Restore original x axis direction for tradeoff plot
Plot also Sensitivity, Balanced Accuracy and use ggplot
Fscore over the full range
added Fscore plot for various cutoffs
diff --git a/R/idiomclassification_mk_pf.R b/R/idiomclassification_mk_pf.R
index 220dd14..7521226 100644
--- a/R/idiomclassification_mk_pf.R
+++ b/R/idiomclassification_mk_pf.R
@@ -102,6 +102,20 @@
View(collected_results)
+# Analysing tradeoff between Fscore, Recall, Precision for various cutoffs
+# full range from precision almost 100% to recall almost 100%
+rf_classifier = randomForest(fmla, train, importance=TRUE)
+cvalues<-tibble()
+for (c in c(seq(from=0.4,to=0.99,by=0.025),0.999)) {
+ prediction_for_table <- predict(rf_classifier, test %>% select(-CO_IDIOM), cutoff = c(1-c, c))
+ conf<-confusionMatrix(prediction_for_table, test$CO_IDIOM, positive = "idiom")
+ cvalues <-bind_rows(cvalues, c(cutoff=c, conf$byClass))
+}
+cvalues %>%
+ select(c("cutoff", "Recall", "Precision", "F1", "Specificity", "Balanced Accuracy")) %>%
+ pivot_longer(!cutoff, names_to=c("measure")) %>%
+ ggplot(aes(cutoff, value, colour=measure)) + geom_line()
+
# Using estimates by random forest on entire dataset
library(randomForest)