tidyclust_update: Update a cluster specification

update.hier_clustR Documentation

Update a cluster specification

Description

If parameters of a cluster specification need to be modified, update() can be used in lieu of recreating the object from scratch.

Usage

## S3 method for class 'hier_clust'
update(
  object,
  parameters = NULL,
  num_clusters = NULL,
  cut_height = NULL,
  linkage_method = NULL,
  fresh = FALSE,
  ...
)

## S3 method for class 'k_means'
update(object, parameters = NULL, num_clusters = NULL, fresh = FALSE, ...)

Arguments

object

A cluster specification.

parameters

A 1-row tibble or named list with main parameters to update. Use either parameters or the main arguments directly when updating. If the main arguments are used, these will supersede the values in parameters. Also, using engine arguments in this object will result in an error.

num_clusters

Positive integer, number of clusters in model.

cut_height

Positive double, height at which to cut dendrogram to obtain cluster assignments (only used if num_clusters is NULL)

linkage_method

the agglomeration method to be used. This should be (an unambiguous abbreviation of) one of "ward.D", "ward.D2", "single", "complete", "average" (= UPGMA), "mcquitty" (= WPGMA), "median" (= WPGMC) or "centroid" (= UPGMC).

fresh

A logical for whether the arguments should be modified in-place or replaced wholesale.

...

Not used for update().

Value

An updated cluster specification.

Examples

kmeans_spec <- k_means(num_clusters = 5)
kmeans_spec
update(kmeans_spec, num_clusters = 1)
update(kmeans_spec, num_clusters = 1, fresh = TRUE)

param_values <- tibble::tibble(num_clusters = 10)

kmeans_spec %>% update(param_values)

tidyclust documentation built on July 3, 2024, 1:06 a.m.