当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。