Uniform Manifold Approximation and Projection (UMAP)

R 的降維

Matt Pickard

Owner, Pickard Predictives, LLC

PCA、t-SNE 與 UMAP

PCA、t-SNE 與 UMAP 比較

R 的降維

PCA、t-SNE 與 UMAP

PCA、t-SNE 與 UMAP 比較

R 的降維

PCA、t-SNE 與 UMAP

PCA、t-SNE 與 UMAP 比較

R 的降維

PCA、t-SNE 與 UMAP

PCA、t-SNE 與 UMAP 比較

R 的降維

PCA、t-SNE 與 UMAP

PCA、t-SNE 與 UMAP 比較

UMAP 有類似的超參數可供調整。

R 的降維

UMAP 繪圖

library(embed)

set.seed(1234) umap_df <- recipe(Attrition ~ ., data = attrition_df) %>% step_normalize(all_predictors()) %>% step_umap(all_predictors(), num_comp = 2) %>% prep() %>% juice()
umap_df %>% ggplot(aes(x = UMAP1, y = UMAP2, color = Attrition)) + geom_point(alpha = 0.7)
R 的降維

UMAP:員工離職

員工離職的 UMAP 視覺化

R 的降維

tidymodels 中的 UMAP

建立 recipe

umap_recipe <-  recipe(Attrition ~ ., data = train) %>% 
  step_normalize(all_predictors()) %>% 
  step_umap(all_predictors(), num_comp = 4)

建立模型規格

umap_lr_model <- linear_reg()
R 的降維

tidymodels 中的 UMAP

建立 workflow

umap_lr_workflow <-  workflow() %>% 
  add_recipe(umap_recipe) %>% 
  add_model(umap_lr_model)

擬合 workflow

umap_lr_fit <- umap_lr_workflow %>% 
  fit(data = train)
R 的降維

tidymodels 中的 UMAP

評估模型

predict_umap_df <- test %>% 
  bind_cols(predict = predict(umap_lr_fit, test))

rmse(predict_umap_df, Attrition, .pred_class)
R 的降維

一起來練習吧!

R 的降維

Preparing Video For Download...