added Fscore plot for various cutoffs
Change-Id: Iae35113fa15da3a8f01613a70f9c788db52a60c7
diff --git a/R/idiomclassification_mk_pf.R b/R/idiomclassification_mk_pf.R
index f564231..8104878 100644
--- a/R/idiomclassification_mk_pf.R
+++ b/R/idiomclassification_mk_pf.R
@@ -102,6 +102,21 @@
View(collected_results)
+# Analysing tradeoff between Fscore, Recall, Precision for various cutoffs
+rf_classifier = randomForest(fmla, train, importance=TRUE)
+cvalues<-c()
+for (c in seq(from=0.05, to=0.5, by=0.025)) {
+ prediction_for_table <- predict(rf_classifier, test %>% select(-CO_IDIOM), cutoff = c(c, 1-c))
+ conf<-confusionMatrix(prediction_for_table, test$CO_IDIOM, positive = "idiom")
+ cvalues<-rbind(cvalues,c(c,conf$byClass))
+}
+
+plot(cvalues[,1],cvalues[,"F1"],type = "o",col = "green", xlab = "Cutoff", ylab = "F1",ylim=c(0,1),
+ main = "FScore, Recall, Precision")
+lines(cvalues[,1],cvalues[,"Recall"], type = "o", col = "blue")
+lines(cvalues[,1],cvalues[,"Precision"],type="o", col="red")
+legend("bottomleft",legend=c("FScore","Recall","Precision"),col=c("green","blue","red"),pch=c(1,1,1),lty=c(1,1,1))
+
# Using estimates by random forest on entire dataset
library(randomForest)