Synthetic

This commit is contained in:
Louis Lacoste 2024-06-18 16:10:44 +02:00
parent ecd3b717ed
commit bf06493174
3 changed files with 9529 additions and 1 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,80 @@
---
format:
html:
embed-resources: true
title: Clustering avec `colSBM` des données synthétiques
execute:
echo: false
warning: false
---
# Analyse
```{r}
library(colSBM)
library(here)
library(stringr)
library(tidyr)
library(dplyr)
library(aricode)
library(reshape2)
library(ggplot2)
library(profvis)
```
```{r}
root_app_folder <- file.path(here(), "code", "applications")
source(file.path(root_app_folder, "utils.R"))
data_folder <- file.path(here(), "code", "results", "simulations", "clustering", "synthetic")
files_vec <- get_recent_files(data_folder, n = 16L, pattern = ".Rds")
files_vec <- identify_models(files_vec, pattern = "(iid|pirho|pi|rho)")
names(files_vec) <- names(files_vec) %>% str_replace_all(pattern = "_", "~")
list_clustering <- files_vec
# list_collection <- readRDS(file.path(data_folder, "dore_collection_iid_24-05-24_18-07-50.Rds"))
```
## Analyse par modèle
Les clustering donne le critère suivant :
```{r}
vec_bicl <- sapply(list_clustering, function(clustering) {
list_collection <- readRDS(clustering)
unlisted_best_partition <- unlist(
extract_best_bipartite_partition(list_collection)
)
BICL <- sum(sapply(unlisted_best_partition, function(col) col$BICL))
BICL
})
names(vec_bicl) <- names(files_vec)
knitr::kable(vec_bicl,
caption = "BICL par modèle", col.names = "$BICL$",
row.names = TRUE
)
```
:::{.panel-tabset}
```{r write_tabs}
#| warning: false
#| output: asis
# Generate content for each model using knit_expand
for (clustering_idx in seq_len(length(list_clustering))) {
clustering <- list_clustering[clustering_idx]
model <- names(clustering)
expanded_content <- knitr::knit_expand(file = file.path(root_app_folder, "base_analysis.qmd"), clustering = clustering, model = model)
res <- knitr::knit_child(text = expanded_content, quiet = TRUE)
cat(res, sep = "\n")
cat("\n")
}
```
:::
## Profiling
```{r}
profvis(prof_input = file.path(data_folder, "profiling_17-06-24_11-59-35.out"))
```

View file

@ -96,7 +96,8 @@ profvis(
save_file <- file.path(
save_folder, paste0(
sprintf("%s_collection_", application_name),
model, "_eps_", eps, "_", start_time, "_maxsteps_500.Rds"
model, "_seed_", seed, "_eps_",
eps, "_", start_time, "_maxsteps_500.Rds"
)
)