Tab.ClassifierPoint.confusion_matrix <- function(Classifier){
table(predicted=Classifier@Y_,
actual = Classifier@Y)
}
Tab.ClassifierCurve.confusion_matrix <- function(Classifier)
{
sens_thres = 0.8
pred <- ROCR::prediction(predictions=Classifier@pY, labels=Classifier@Y)
target_cutoff <- pred %>%
ROCR::performance("tpr") %>%
(function(perf) {
data.frame(
tpr = perf %>% slot("y.values") %>% unlist,
cutoff = perf %>% slot("x.values") %>% unlist)}) %>%
filter(tpr >= sens_thres) %>%
head(1) %>%
magrittr::use_series(cutoff)
Classifier@pY %>%
purrr::map_chr(~ifelse(. >= target_cutoff, 'critical', '_routine')) %>%
factor(ordered=T) %>%
table(predicted=.,
actual = Classifier@Y)
}
# From /meta/code/lib/R/MyClassifiers/R/Tables.R
# .Tab.ClassifierCurve.confusion_matrix <- function(Classifier){
# sens_thres = 0.8
# target_cutoff <- Classifier@pred %>%
# performance("tpr") %>%
# (function(perf) {
# data.frame(
# tpr = perf %>% slot("y.values") %>% unlist,
# cutoff = perf %>% slot("x.values") %>% unlist)}) %>%
# filter(tpr >= sens_thres) %>%
# head(1) %>%
# use_series(cutoff)
# Classifier@pY %>%
# map_chr(~ifelse(. >= target_cutoff, 'critical', '_routine')) %>%
# factor(ordered=T) %>%
# table(Classifier@Y)}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.