extract-tidyclust {tidyclust}R Documentation

Extract elements of a tidyclust model object

Description

These functions extract various elements from a clustering object. If they do not exist yet, an error is thrown.

Usage

## S3 method for class 'cluster_fit'
extract_fit_engine(x, ...)

## S3 method for class 'cluster_spec'
extract_parameter_set_dials(x, ...)

Arguments

x

A cluster_fit object or a cluster_spec object.

...

Not currently used.

Details

Extracting the underlying engine fit can be helpful for describing the model (via print(), summary(), plot(), etc.) or for variable importance/explainers.

However, users should not invoke the predict() method on an extracted model. There may be preprocessing operations that tidyclust has executed on the data prior to giving it to the model. Bypassing these can lead to errors or silently generating incorrect predictions.

Good:

   tidyclust_fit %>% predict(new_data)

Bad:

   tidyclust_fit %>% extract_fit_engine() %>% predict(new_data)

Value

The extracted value from the tidyclust object, x, as described in the description section.

Examples

kmeans_spec <- k_means(num_clusters = 2)
kmeans_fit <- fit(kmeans_spec, ~., data = mtcars)

extract_fit_engine(kmeans_fit)

[Package tidyclust version 0.2.1 Index]