if (requireNamespace("ggplot2", quietly = TRUE)) {
# Generate dummy data
class1 <- matrix(rnorm(100, mean = 0, sd = 1), ncol = 2) +
matrix(rep(c(1, 1), each = 50), ncol = 2)
class2 <- matrix(rnorm(100, mean = 0, sd = 1), ncol = 2) +
matrix(rep(c(-1, -1), each = 50), ncol = 2)
datanew <- rbind(class1, class2)
training <- data.frame(datanew, class = factor(c(rep(1, 50), rep(2, 50))))
# Plot the dummy data to visualize overlaps
p <- ggplot2::ggplot(training, ggplot2::aes(x = X1, y = X2, color = class)) +
ggplot2::geom_point() +
ggplot2::labs(title = "Dummy Data with Overlapping Classes")
print(p)
# Perform clustering
cluster_result <- perform_clustering(training, class_column = class)
}
Run the code above in your browser using DataLab