R Under development (unstable) (2024-11-07 r87302 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # Test script for ensemble clustering functionality > > library(bootcluster) > > # Generate test data > set.seed(123) > n <- 150 # number of points > centers <- matrix(c(0,0, 2,2, -2,2), ncol=2, byrow=TRUE) > clusters <- sample(1:3, n, replace=TRUE) > x <- matrix(0, nrow=n, ncol=2) > for(i in 1:n) { + x[i,] <- centers[clusters[i],] + rnorm(2, 0, 0.3) + } > > # Test ensemble clustering with different k values > test_ensemble <- function() { + # Test case 1: Equal k values + res1 <- ensemble_clustering(x, k_km=3, k_hc=3, k_sc=3) + cat("Test 1 - Equal k values:\n") + cat("Number of clusters found:", length(unique(res1$membership)), "\n") + cat("Modularity:", res1$modularity, "\n\n") + + # Test case 2: Different k values + res2 <- ensemble_clustering(x, k_km=3, k_hc=4, k_sc=2) + cat("Test 2 - Different k values:\n") + cat("Number of clusters found:", length(unique(res2$membership)), "\n") + cat("Modularity:", res2$modularity, "\n\n") + + # Test visualization + plots <- plot_clustering_results(x, res1, pca=FALSE) + print(plots$ensemble) + + # Test Smin analysis + smin_plot <- plot_smin_analysis(res1) + print(smin_plot) + } > > # Run tests > test_ensemble() Error in ensemble_clustering(x, k_km = 3, k_hc = 3, k_sc = 3) : could not find function "ensemble_clustering" Calls: test_ensemble Execution halted