Initially, I performed kmeans clustering and obtained some meaningful clusters. To refine these clusters, I ran Fuzzy C Means on the Kmeans center using "e1071" package. Are there any matrices, like the jaccard similarity index that is for the Kmeans clustering, to evaluate the quality of fuzzy clusters? I ran the below code to compute the mean fuzzy rand index (FRI) and the corresponding standard deviation using 1000 bootstrap samples, however, I'm not sure about it since it's my first experience as a biologist.
#parameters
set.seed(123)
num_clusters <- 5 # number of clusters (based on K-means results)
m_fuzziness <- 1.2 # fuzziness parameter for FCM
n_bootstraps <- 1000 # number of bootstrap samples
#run FCM on the K-Means centers
fcm_result <- cmeans(data_scaled, centers = kmeans_centers, m = m_fuzziness)
membership_matrix <- fcm_result$membership # Original fuzzy membership matrix
#Define the function to compute the true Fuzzy Rand Index (FRI)
compute_fri <- function(U1, U2) {
sum_intersection <- sum(U1 * U2)
sum_union <- sum(U1^2) + sum(U2^2) - sum_intersection
return(sum_intersection / sum_union)
}
#Bootstrapping for evaluate stability
fri_scores <- numeric(n_bootstraps) # Initialize vector to store FRI scores
for (i in 1:n_bootstraps) {
#generate a bootstrap sample
boot_indices <- sample(1:nrow(data_scaled), replace = TRUE)
boot_data <- data_scaled[boot_indices, ]
#run FCM on bootstrapped data using the original FCM cluster centers
fcm_boot <- cmeans(boot_data, centers = fcm_result$centers, m = m_fuzziness)
boot_membership <- fcm_boot$membership
#compute the Fuzzy Rand Index (FRI) between original and bootstrapped clusters
fri_scores[i] <- compute_fri(membership_matrix[boot_indices, ], boot_membership)
}
#compute stability
mean_fri <- mean(fri_scores, na.rm = TRUE) # mean FRI
sd_fri <- sd(fri_scores, na.rm = TRUE) # standard deviation of FRI''