如何转换此数据,将map()转换为tune()

时间:2020-10-20 06:31:29

标签: r dplyr tidymodels

使用迭代过程比较机器学习模型。

我能够在防风草中找到k邻居方法,但是我可以将其修改为 k均值可以创建类似于上述代码的内容?
您是否有任何有用的信息?

为了使代码更易于理解,我想使用tune()来调整K。

poi <- tibble(
  cluster = factor(1:3),num_points = c(100, 150, 50),
  x1 = c(5, 0, -3),x2 = c(-1, 1, -2))%>%
  mutate(
    x1 = map2(num_points, x1, rnorm),
    x2 = map2(num_points, x2, rnorm)) %>% 
  unnest(cols = c(x1, x2)) %>%
  select(-cluster,-num_points)

res <- 
  tibble(k = 1:9) %>%
  mutate(
    kclust = map(k, ~kmeans(poi, .x)),
    augmented = map(kclust, augment, poi)
  )

0 个答案:

没有答案
相关问题