11.3 KNN

knn_spec <- parsnip::nearest_neighbor() %>%
  parsnip::set_engine("kknn") %>%
  parsnip::set_mode("regression")
knn_wf <- rt_wf %>%
  workflows::update_model(knn_spec)
knn_wf %>% tune::last_fit(ames_split) %>%
  tune::collect_metrics()
## # A tibble: 2 x 3
##   .metric .estimator .estimate
##   <chr>   <chr>          <dbl>
## 1 rmse    standard   58943.   
## 2 rsq     standard       0.418
lm_wf %>% tune::last_fit(ames_split) %>%
  tune::collect_metrics()
## # A tibble: 2 x 3
##   .metric .estimator .estimate
##   <chr>   <chr>          <dbl>
## 1 rmse    standard   56478.   
## 2 rsq     standard       0.435
rt_wf %>% tune::last_fit(ames_split) %>%
  tune::collect_metrics()
## # A tibble: 2 x 3
##   .metric .estimator .estimate
##   <chr>   <chr>          <dbl>
## 1 rmse    standard   54906.   
## 2 rsq     standard       0.452