R/plot_method_scatter.R

Defines functions plotAggrResult

plotAggrResult = function(data, full_pred) {
  data = data %>%
    dplyr::group_by(ids, classifier, dataset) %>%
    dplyr::summarise(acc = mean(acc), feats = mean(feats)) %>%
    dplyr::filter(ids != "full_predictor")

  plot = data %>%
    ggplot2::ggplot(ggplot2::aes(x = feats, y = acc, colour = ids, classifier)) +
    ggplot2::geom_point() +
    ggplot2::theme_linedraw() +
    ggrepel::geom_text_repel(ggplot2::aes(label = ids)) +
    ggplot2::geom_hline(data = full_pred, ggplot2::aes(yintercept = acc), linetype = "dashed", color = "gray50") +
    # ggplot2::ggtitle(paste("Number of features vs. accuracy", "dataset_name", sep = " ")) +
    ggplot2::xlab("Number of Features") +
    ggplot2::ylab("Accuracy") +
    ggplot2::theme(
      legend.position = "none",
      text = ggplot2::element_text(size = 16)
      )

  # create a plot with two rows when only one data set is selected
  # otherwise create grid
  if(length(unique(data$dataset)) > 1) {
    plot = plot + ggplot2::facet_grid(dataset ~ classifier)
  }
  else {
    plot = plot + ggplot2::facet_wrap(~ classifier, ncol = 2)
  }

  return(plot)
}

# plotAggrResult(test)
# test = loadAggrResults("~/Documents/Uni/MA/small_scripts/dashboardPackage/testing/results")
# test2 = loadFullPredResults("~/Documents/Uni/MA/small_scripts/dashboardPackage/testing/results")
#
# test3 = test %>% filter(dataset == "credit")
# test4 = test2 %>% filter(dataset == "credit")
#
# plotAggrResult(test3, test4)
creil94/FeatureSelectionDashboard documentation built on Nov. 4, 2019, 9:17 a.m.