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.

cclsSSLR(
  n_clusters = NULL,
  mustLink = NULL,
  cantLink = NULL,
  max_iter = 1,
  tabuIter = 100,
  tabuLength = 20
)

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 1

tabuIter

Number of iteration in Tabu search

tabuLength

The number of elements in the Tabu list

Note

This models only returns labels, not centers

References

Tran Khanh Hiep, Nguyen Minh Duc, Bui Quoc Trung
Pairwise Constrained Clustering by Local Search
2016

Examples

#> -- Attaching packages -------------------------------------------------------------------- tidyverse 1.3.0 --
#> v ggplot2 3.3.2 v purrr 0.3.4 #> v tibble 3.0.3 v dplyr 1.0.2 #> v tidyr 1.1.2 v stringr 1.4.0 #> v readr 1.4.0 v forcats 0.5.0
#> -- Conflicts ----------------------------------------------------------------------- tidyverse_conflicts() -- #> x dplyr::filter() masks stats::filter() #> x dplyr::lag() masks stats::lag()
#> Loading required package: lattice
#> #> Attaching package: 'caret'
#> The following object is masked from 'package:purrr': #> #> lift
#> -- Attaching packages ------------------------------------------------------------------- tidymodels 0.1.1 --
#> v broom 0.7.1 v recipes 0.1.13 #> v dials 0.0.9 v rsample 0.0.8 #> v infer 0.5.3 v tune 0.1.1 #> v modeldata 0.0.2 v workflows 0.2.0 #> v parsnip 0.1.3 v yardstick 0.0.7
#> -- Conflicts ---------------------------------------------------------------------- tidymodels_conflicts() -- #> x scales::discard() masks purrr::discard() #> x dplyr::filter() masks stats::filter() #> x recipes::fixed() masks stringr::fixed() #> x dplyr::lag() masks stats::lag() #> x caret::lift() masks purrr::lift() #> x yardstick::precision() masks caret::precision() #> x yardstick::recall() masks caret::recall() #> x yardstick::sensitivity() masks caret::sensitivity() #> x yardstick::spec() masks readr::spec() #> x yardstick::specificity() masks caret::specificity() #> x recipes::step() masks stats::step()
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 <- cclsSSLR(max_iter = 1) %>% fit(Species ~ ., data) #Get labels (assing clusters), type = "raw" return factor labels <- m %>% cluster_labels() print(labels)
#> # A tibble: 150 x 1 #> .pred_class #> <fct> #> 1 1 #> 2 1 #> 3 1 #> 4 1 #> 5 1 #> 6 1 #> 7 1 #> 8 1 #> 9 1 #> 10 1 #> # ... with 140 more rows