knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

celery

Codecov test coverage R-CMD-check

The goal of celery is to provide a tidy, unified interface to clustering models. The packages is closely modeled after the parsnip package.

Installation

You can install the development version of celery from GitHub with:

# install.packages("devtools")
devtools::install_github("EmilHvitfeldt/celery")

Example

The first thing you do is to create a cluster specification. For this example we are creating a K-means model, using the stats engine.

library(celery)

kmeans_spec <- k_means(k = 3) %>%
  set_engine_celery("stats") 

kmeans_spec

This specification can then be fit using data.

kmeans_spec_fit <- kmeans_spec %>%
  fit(~., data = mtcars)
kmeans_spec_fit

Once you have a fitted celery object, you can do a number of things. predict() returns the cluster a new observation belongs to

predict(kmeans_spec_fit, mtcars[1:4, ])

extract_cluster_assignment() returns the cluster assignments of the training observations

extract_cluster_assignment(kmeans_spec_fit)

and extract_clusters() returns the locations of the clusters

extract_clusters(kmeans_spec_fit)


kbodwin/celery documentation built on March 26, 2022, 12:33 a.m.