[英]Get the proportion of the variance explained in a plsda with recipes
我嘗試使用tidymodels
框架計算 PLSDA 中每個組件解釋的方差比例。
這是mixOmics
package 的“黃金標准”結果:
library(mixOmics)
mix_plsda <- plsda(X = iris[-5], Y = iris$Species, ncomp = 4)
mix_var_expl <- mix_plsda$prop_expl_var$X
mix_var_expl
#> comp1 comp2 comp3 comp4
#> 0.729028323 0.227891235 0.037817718 0.005262724
sum(mix_var_expl) # check
#> [1] 1
這里有recipes::step_pls()
:
library(recipes)
tidy_plsda <-
recipe(Species ~ ., data = iris) %>%
step_pls(all_numeric_predictors(), outcome = "Species", num_comp = 4) %>%
prep()
tidy_sd <- tidy_plsda$steps[[1]]$res$sd
tidy_sd
#> [1] 0.8280661 0.4358663 1.7652982 0.7622377
tidy_sd ^2 / sum(tidy_sd^2)
#> [1] 0.14994532 0.04154411 0.68145793 0.12705264
與解釋方差最相似的元素是sd
,但正如您所見,這兩個向量之間沒有明顯的關系。
如何從tidy_plsda
mix_var_expl
謝謝!
由代表 package (v2.0.1) 於 2022 年 9 月 20 日創建
配方 object 不保存 mixOmics model; 只是我們處理新數據所需的部分。 sd
object 是預測變量的標准差。 目前沒有從 object 獲得您想要的東西的方法。
我添加了一個 GitHub 問題以向結果添加更多對象: https://github.com/tidymodels/recipes/issues/1038
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.