tests/testthat/test-predict_formats.R

test_that("partition predictions", {
  kmeans_fit <-
    k_means(num_clusters = 3, mode = "partition") %>%
    set_engine("stats") %>%
    fit(~., data = mtcars)

  expect_true(tibble::is_tibble(predict(kmeans_fit, new_data = mtcars)))
  expect_true(
    is.factor(
      tidyclust:::predict_cluster.cluster_fit(kmeans_fit, new_data = mtcars)
    )
  )
  expect_equal(names(predict(kmeans_fit, new_data = mtcars)), ".pred_cluster")
})

Try the tidyclust package in your browser

Any scripts or data that you put into this service are public.

tidyclust documentation built on Sept. 26, 2023, 1:08 a.m.