extract-tidyclust | R Documentation |
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 using k_means()
with the "lm"
engine, this returns the underlying kmeans
object.
extract_parameter_set_dials()
returns a set of dials parameter objects.
## S3 method for class 'cluster_fit'
extract_fit_engine(x, ...)
## S3 method for class 'cluster_spec'
extract_parameter_set_dials(x, ...)
x |
A |
... |
Not currently used. |
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)
The extracted value from the tidyclust object, x
, as described in the
description section.
kmeans_spec <- k_means(num_clusters = 2)
kmeans_fit <- fit(kmeans_spec, ~., data = mtcars)
extract_fit_engine(kmeans_fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.