Last active
November 19, 2025 13:45
-
-
Save wleoncio/8e073aac063ed72fb1025e6f6c71d79f to your computer and use it in GitHub Desktop.
Error from BayesMallows::assign_cluster()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(BayesMallows) | |
| library(tidyverse) | |
| library(parallel) | |
| #load our data | |
| data <- read.csv("data.csv") | |
| #we reshape it to fit BayesMallows package | |
| flavours <- c( | |
| "Banan", "Caramel", "Chocolate Toffee", "Cocos", "Daim", | |
| "Eclairs", "Fransk nougat", "Golden Toffee", "Japp", "Lakris", | |
| "Marsipan", "Nougatcrisp", "NC8tti" | |
| ) | |
| data_num <- apply(data[5:17], 2, function(x) match(x, flavours)) #replace characters with numbers | |
| data_num_ord <- create_ordering(data_num) #replace ranking with ordering | |
| colnames(data_num_ord) <- flavours #colnames and rownames just to remember | |
| rownames(data_num_ord) <- paste0("Assessor", 1:dim(data_num)[1]) #colnames and rownames just to remember | |
| data_BM <- setup_rank_data(rankings = data_num_ord) | |
| #step 1 - observe and select burning | |
| cl <- makeCluster(detectCores()) | |
| bmm <- compute_mallows_mixtures( | |
| n_clusters = c(1, 2, 3, 4), | |
| data = data_BM, | |
| compute_options = set_compute_options(nmc = 10000, include_wcd = FALSE), | |
| cl = cl) | |
| stopCluster(cl) | |
| assess_convergence(bmm) | |
| selected_burnin <- 5000L | |
| thinning <- 10L | |
| #step 2 - observe and select the number of clusters | |
| cl <- makeCluster(detectCores()) | |
| bmm <- compute_mallows_mixtures( | |
| n_clusters = 1:4, | |
| data = data_BM, | |
| compute_options = | |
| set_compute_options(nmc = 11000, burnin = selected_burnin, | |
| rho_thinning = thinning, include_wcd = TRUE), | |
| cl = cl) | |
| stopCluster(cl) | |
| plot_elbow(bmm) | |
| selected_n_clusters <- 3 | |
| #step 3 - compute clustering and see the results | |
| bmm <- compute_mallows( | |
| data = data_BM, | |
| model_options = set_model_options(n_cluster = selected_n_clusters), | |
| compute_options = set_compute_options( | |
| nmc = 11000, burnin = selected_burnin, | |
| clus_thinning = thinning, rho_thinning = thinning, include_wcd = TRUE) #save_ind_clus = TRUE | |
| ) | |
| assign_cluster(bmm) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Time | Gender | Generation | Time in Norway | Rank1 | Rank2 | Rank3 | Rank4 | Rank5 | Rank6 | Rank7 | Rank8 | Rank9 | Rank10 | Rank11 | Rank12 | Rank13 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2025-11-17 19:18:41 | Female | Gen Z | >15 years | Lakris | Eclairs | Marsipan | Caramel | Banan | Japp | Daim | Notti | ||||||
| 2025-11-17 19:25:22 | Male | Boomer | >15 years | Lakris | Cocos | Japp | Marsipan | Daim | Caramel | Notti | |||||||
| 2025-11-17 19:28:10 | Female | Generation X | >15 years | Eclairs | Caramel | Lakris | Marsipan | Notti | Japp | ||||||||
| 2025-11-17 19:28:38 | Male | Gen Z | >15 years | Caramel | Lakris | Cocos | Marsipan | Notti | Daim | Japp | |||||||
| 2025-11-17 19:55:12 | Female | Generation X | >15 years | Banan | Lakris | Eclairs | Japp | Marsipan | Daim | Notti | Caramel | ||||||
| Male | Millenial | >15 years | Cocos | Japp | Marsipan | Lakris | Notti | Caramel | |||||||||
| Female | Gen Z | >15 years | Lakris | Marsipan | Eclairs | Japp | Notti | ||||||||||
| Male | Boomer | >15 years | Marsipan | Cocos | Lakris | Daim | Japp | Notti | |||||||||
| Female | Generation X | >15 years | Eclairs | Lakris | Marsipan | Caramel | Japp | Notti | |||||||||
| Male | Gen Z | >15 years | Lakris | Japp | Marsipan | Cocos | Caramel | Daim | Notti | ||||||||
| Female | Generation X | <5 years | Caramel | Eclairs | Japp | Notti | Marsipan | Lakris | |||||||||
| Male | Millenial | <5 years | Daim | Japp | Cocos | Caramel | Banan | Notti | Marsipan | Lakris | |||||||
| Female | Gen Z | <5 years | Daim | Eclairs | Caramel | Notti | Japp | Marsipan | Lakris | ||||||||
| Male | Boomer | <5 years | Cocos | Caramel | Japp | Notti | Lakris | Marsipan | |||||||||
| Female | Generation X | <5 years | Eclairs | Daim | Japp | Notti | Lakris | Caramel | |||||||||
| Male | Gen Z | <5 years | Cocos | Japp | Banan | Daim | Notti | Marsipan | Lakris | Caramel | |||||||
| Female | Generation X | <5 years | Eclairs | Notti | Japp | Caramel | Banan | Lakris | Marsipan | ||||||||
| Male | Millenial | <5 years | Japp | Cocos | Daim | Notti | Caramel | Lakris | Marsipan | ||||||||
| Female | Generation X | <5 years | Daim | Notti | Eclairs | Japp | Caramel | Marsipan | Lakris | ||||||||
| Male | Millenial | <5 years | Cocos | Banan | Notti | Daim | Caramel | Lakris | Marsipan | Japp | |||||||
| Female | Gen Z | >15 years | Lakris | Marsipan | Eclairs | Japp | Caramel | Daim | |||||||||
| Male | Boomer | >15 years | Marsipan | Lakris | Cocos | Caramel | Banan | Daim | |||||||||
| Female | Generation X | >15 years | Eclairs | Lakris | Marsipan | Caramel | Daim | ||||||||||
| Male | Gen Z | >15 years | Cocos | Lakris | Marsipan | Banan | Caramel | Daim | |||||||||
| Female | Generation X | >15 years | Lakris | Marsipan | Eclairs | Banan | Caramel | Daim | |||||||||
| Male | Millenial | >15 years | Lakris | Marsipan | Banan | Cocos | Caramel | ||||||||||
| Female | Gen Z | >15 years | Eclairs | Lakris | Marsipan | Banan | Daim | Caramel | |||||||||
| Male | Boomer | >15 years | Marsipan | Cocos | Lakris | Banan | Daim | Caramel | |||||||||
| Female | Generation X | >15 years | Marsipan | Lakris | Banan | Eclairs | Daim | Caramel | |||||||||
| Male | Gen Z | >15 years | Lakris | Marsipan | Cocos | Banan | Daim | Caramel | |||||||||
| Female | Generation X | <5 years | Eclairs | Banan | Daim | Caramel | Lakris | Marsipan | |||||||||
| Male | Millenial | <5 years | Japp | Cocos | Banan | Caramel | Daim | Marsipan | Lakris | ||||||||
| Female | Gen Z | <5 years | Eclairs | Japp | Banan | Caramel | Marsipan | Lakris | |||||||||
| Male | Boomer | <5 years | Cocos | Banan | Caramel | Daim | Lakris | ||||||||||
| Female | Generation X | <5 years | Eclairs | Banan | Caramel | Daim | Lakris | Marsipan | |||||||||
| Male | Gen Z | <5 years | Cocos | Caramel | Japp | Daim | Lakris | Marsipan | |||||||||
| Female | Generation X | <5 years | Eclairs | Caramel | Banan | Daim | Lakris | Marsipan | |||||||||
| Male | Millenial | <5 years | Cocos | Banan | Caramel | Japp | Daim | Marsipan | Lakris | ||||||||
| Female | Generation X | <5 years | Eclairs | Caramel | Daim | Lakris | Marsipan | ||||||||||
| Male | Millenial | <5 years | Cocos | Caramel | Japp | Lakris | Marsipan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment