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.
-
extract_fit_engine()
returns the engine specific fit embedded within a tidyclust model fit. For example, when usingk_means()
with the"lm"
engine, this returns the underlyingkmeans
object. -
extract_parameter_set_dials()
returns a set of dials parameter objects.
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 |
... |
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)