Description Usage Arguments References Examples
The initialization is the same as seeded kmeans, the difference is that in the following steps the allocation of the clusters in the labelled data does not change
1 | constrained_kmeans(max_iter = 10, method = "euclidean")
|
max_iter |
maximum iterations in KMeans. Default is 10 |
method |
distance method in KMeans: "euclidean", "maximum", "manhattan", "canberra", "binary" or "minkowski" |
Sugato Basu, Arindam Banerjee, Raymond Mooney
Semi-supervised clustering by seeding
July 2002
In Proceedings of 19th International Conference on Machine Learning
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | library(tidyverse)
library(caret)
library(SSLR)
library(tidymodels)
data <- iris
set.seed(1)
#% LABELED
cls <- which(colnames(iris) == "Species")
labeled.index <- createDataPartition(data$Species, p = .2, list = FALSE)
data[-labeled.index,cls] <- NA
m <- constrained_kmeans() %>% fit(Species ~ ., data)
#Get labels (assing clusters), type = "raw" return factor
labels <- m %>% cluster_labels()
print(labels)
#Get centers
centers <- m %>% get_centers()
print(centers)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.