mpckmSSLR: General Interface MPC K-Means Algorithm

Description Usage Arguments Note References Examples

View source: R/pairwise_constraints_clustering.R

Description

Model from conclust
This function takes an unlabeled dataset and two lists of must-link and cannot-link constraints as input and produce a clustering as output.

Usage

1
mpckmSSLR(n_clusters = NULL, mustLink = NULL, cantLink = NULL, max_iter = 10)

Arguments

n_clusters

A number of clusters to be considered. Default is NULL (num classes)

mustLink

A list of must-link constraints. NULL Default, constrints same label

cantLink

A list of cannot-link constraints. NULL Default, constrints with different label

max_iter

maximum iterations in KMeans. Default is 10

Note

This models only returns labels, not centers

References

Bilenko, Basu, Mooney
Integrating Constraints and Metric Learning in Semi-Supervised Clustering
2004

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 <- mpckmSSLR() %>% fit(Species ~ ., data)

#Get labels (assing clusters), type = "raw" return factor
labels <- m %>% cluster_labels()

print(labels)

SSLR documentation built on July 22, 2021, 9:08 a.m.