Skip to content

Extract cluster assignments from model

Usage

extract_cluster_assignment(object, ...)

Arguments

object

An cluster_spec object.

...

Other arguments passed to methods.

Value

A tibble::tibble() with 1 column .cluster.

Examples

kmeans_spec <- k_means(num_clusters = 5) %>%
  set_engine("stats")

kmeans_fit <- fit(kmeans_spec, ~., mtcars)

kmeans_fit %>%
  extract_cluster_assignment()
#> # A tibble: 32 × 1
#>    .cluster 
#>    <fct>    
#>  1 Cluster_1
#>  2 Cluster_1
#>  3 Cluster_1
#>  4 Cluster_2
#>  5 Cluster_3
#>  6 Cluster_2
#>  7 Cluster_4
#>  8 Cluster_1
#>  9 Cluster_1
#> 10 Cluster_1
#> # … with 22 more rows