當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


R butcher axe-pls 取消 mixOmics 模型


mixo_pls (通過 pls() )、mixo_spls (通過 spls() )和 mixo_plsda (通過 plsda() )對象是使用 mixOmics 包創建的,用於擬合偏最小二乘模型。

用法

# S3 method for mixo_pls
axe_call(x, verbose = FALSE, ...)

# S3 method for mixo_spls
axe_call(x, verbose = FALSE, ...)

# S3 method for mixo_pls
axe_data(x, verbose = FALSE, ...)

# S3 method for mixo_spls
axe_data(x, verbose = FALSE, ...)

# S3 method for mixo_pls
axe_fitted(x, verbose = FALSE, ...)

# S3 method for mixo_spls
axe_fitted(x, verbose = FALSE, ...)

參數

x

一個模型對象。

verbose

每次執行 ax 方法時打印信息。記錄釋放了多少內存以及禁用了哪些函數。默認為 FALSE

...

與砍伐相關的任何其他參數。

刪除 mixo_plsmixo_splsmixo_plsda 對象。

細節

mixOmics 包在 CRAN 上不可用,但可以通過 remotes::install_bioc("mixOmics") 從 Bioconductor 存儲庫安裝。

例子

library(butcher)
do.call(library, list(package = "mixOmics"))
#> 
#> Loaded mixOmics 6.24.0
#> Thank you for using mixOmics!
#> Tutorials: http://mixomics.org
#> Bookdown vignette: https://mixomicsteam.github.io/Bookdown
#> Questions, issues: Follow the prompts at http://mixomics.org/contact-us
#> Cite us:  citation('mixOmics')
#> 
#> Attaching package: ‘mixOmics’
#> The following objects are masked from ‘package:caret’:
#> 
#>     nearZeroVar, plsda, splsda
#> The following objects are masked from ‘package:parsnip’:
#> 
#>     pls, tune

# pls ------------------------------------------------------------------
fit_mod <- function() {
  boop <- runif(1e6)
  pls(matrix(rnorm(2e4), ncol = 2), rnorm(1e4), mode = "classic")
}

mod_fit <- fit_mod()
mod_res <- butcher(mod_fit)

weigh(mod_fit)
#> # A tibble: 24 × 2
#>    object             size
#>    <chr>             <dbl>
#>  1 X              0.842   
#>  2 Y              0.762   
#>  3 names.sample   0.681   
#>  4 variates.X     0.201   
#>  5 variates.Y     0.201   
#>  6 input.X        0.161   
#>  7 call           0.00129 
#>  8 loadings.X     0.000776
#>  9 loadings.Y     0.000696
#> 10 loadings.star1 0.0006  
#> # ℹ 14 more rows
weigh(mod_res)
#> # A tibble: 24 × 2
#>    object              size
#>    <chr>              <dbl>
#>  1 X               0.842   
#>  2 Y               0.762   
#>  3 variates.X      0.201   
#>  4 variates.Y      0.201   
#>  5 loadings.X      0.000776
#>  6 loadings.Y      0.000696
#>  7 loadings.star1  0.0006  
#>  8 mat.c           0.0006  
#>  9 loadings.star2  0.00052 
#> 10 prop_expl_var.X 0.000352
#> # ℹ 14 more rows

new_data <- matrix(1:2, ncol = 2)
colnames(new_data) <- c("X1", "X2")
predict(mod_fit, new_data)
#> 
#> Call:
#>  predict.mixo_pls(object = mod_fit, newdata = new_data) 
#> 
#>  Main numerical outputs: 
#>  -------------------- 
#>  Prediction values of the test samples for each component: see object$predict 
#>  variates of the test samples: see object$variates 
predict(mod_res, new_data)
#> 
#> Call:
#>  predict.mixo_pls(object = mod_res, newdata = new_data) 
#> 
#>  Main numerical outputs: 
#>  -------------------- 
#>  Prediction values of the test samples for each component: see object$predict 
#>  variates of the test samples: see object$variates 
源代碼:R/mixOmics.R

相關用法


注:本文由純淨天空篩選整理自Davis Vaughan等大神的英文原創作品 Axing mixOmics models。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。