From 2179f52775780f163657f8b596ca475e248cd310 Mon Sep 17 00:00:00 2001 From: Louis Lacoste Date: Wed, 17 Jul 2024 16:59:47 +0200 Subject: [PATCH] for report : improving code --- code/for_report/inference_analyze.R | 8 +++- code/for_report/network_clustering_analyze.R | 44 ++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 code/for_report/network_clustering_analyze.R diff --git a/code/for_report/inference_analyze.R b/code/for_report/inference_analyze.R index 939cefa..fa39496 100644 --- a/code/for_report/inference_analyze.R +++ b/code/for_report/inference_analyze.R @@ -297,7 +297,11 @@ ARI_plots <- ggplot(averaged_data) + aes(x = epsilon_alpha, y = ARI_mean, color = model) + geom_point(aes(fill = model)) + geom_line() + - geom_ribbon(aes(ymin = ARI_mean - ARI_sd, ymax = ARI_mean + ARI_sd), + geom_ribbon( + aes( + ymin = ARI_mean - ARI_sd, + ymax = ARI_mean + ARI_sd, fill = model + ), alpha = 0.05 ) + scale_color_okabe_ito() + @@ -310,7 +314,7 @@ ARI_plots <- ggplot(averaged_data) + fill = guide_legend(title = "Model"), color = guide_legend(title = "Model") ) + - labs(y = "", x = "$\\epsilon_{\\alpha}$", fill = model.labs) + + labs(y = "", x = "$\\epsilon_{\\alpha}$") + theme_minimal() + theme(aspect.ratio = 1L, axis.text.x = element_text(angle = -45, vjust = .5, hjust = 0)) diff --git a/code/for_report/network_clustering_analyze.R b/code/for_report/network_clustering_analyze.R new file mode 100644 index 0000000..d52c3d7 --- /dev/null +++ b/code/for_report/network_clustering_analyze.R @@ -0,0 +1,44 @@ +## ----libraries, echo = FALSE, include = FALSE---------------------------------------------------------------------------------------------------------------------------------------- +library("ggplot2") +library("ggokabeito") +library("tidyr") +library("dplyr") +library("stringr") +library("knitr") +library("kableExtra") +library("stringr") +library("here") +library("tikzDevice") + + + +## ----impoting-data, echo = FALSE---------------------------------------------------------------------------------------------------------------------------- +filenames <- list.files( + path = here("code", "results", "simulations", "clustering", "synthetic"), + pattern = "synthetic", + full.names = TRUE +) + +filenames <- filenames[order(file.info(filenames)$ctime, decreasing = TRUE)] +# data_list <- lapply(filenames, function(file) lapply(readRDS(file), function(model) model$list_clustering)) +df_netclust <- do.call("rbind", lapply(filenames, readRDS)) +df_netclust$model <- factor(df_netclust$model, levels = c( + "iid", "pi", + "rho", "pirho" +)) + + + +## ----netclustering-ARI-boxplot, echo = FALSE---------------------------------------------------------------------------------------------------------------- +#| dpi = 300, +#| fig.asp = 0.5, +#| fig.cap = "\\label{}ARI of the partition obtained by clustering in function of $\\eps$" +df_netclust %>% + ggplot() + + aes(x = as.factor(epsilon), y = ARI) + + scale_color_okabe_ito() + + scale_fill_okabe_ito() + + xlab(TeX("$\\epsilon$")) + + guides(fill = guide_legend(title = "Model")) + + ylab("ARI of obtained netclustering") + + geom_boxplot(aes(fill = model))