getAccDiffData = function(results, full_pred_results) {
# group and summarise
results = results %>%
dplyr::group_by(dataset, classifier, ids) %>%
dplyr::summarise(acc = mean(acc), feats = mean(feats)) %>%
dplyr::filter(ids != "full_predictor")
# get all classifiers all datasets
classifiers = unique(results$classifier)
datasets = unique(results$dataset)
for (dataset in datasets) {
for (classifier in classifiers) {
# skip if the classifier does not exist for this dataset
if(nrow(results[results$classifier == classifier & results$dataset == dataset,]) <= 0) {
next
}
# get full pred results
full = full_pred_results[full_pred_results$classifier == classifier & full_pred_results$dataset == dataset,]
# if doesnt exist transform everything to 0
if (nrow(full) == 0) {
results[results$classifier == classifier & results$dataset == dataset,]$acc_diff = 0
next
}
# else calc acc difference
results[results$classifier == classifier & results$dataset == dataset,"acc_diff"] = results[results$classifier == classifier & results$dataset == dataset,]$acc - full_pred_results[full_pred_results$classifier == classifier & full_pred_results$dataset == dataset,]$acc
}
}
results$acc_diff = as.numeric(format(round(results$acc_diff, 4), digits = 4))
return(results)
}
createAccDiffBarPlot = function(acc_diff_data) {
# create bar chart
plot = ggplot2::ggplot(acc_diff_data, ggplot2::aes(x = ids, y = acc_diff, fill = classifier)) +
ggplot2::geom_col(position = ggplot2::position_dodge(width = 0.5), width = 0.5) +
# facet_wrap(~classifier) +
ggplot2::ylab("Accuracy difference to All Features") +
ggplot2::xlab("") +
ggplot2::facet_wrap(dataset ~ ., ncol = 2) +
ggplot2::theme(
axis.text.x = ggplot2::element_text(angle = 45),
legend.position = "bottom"
) +
ggplot2::labs(fill = "Classifier")
return(plotly::ggplotly(plot))
}
# asf = getAccDiffData(test)
# createAccDiffBarPlot(asf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.