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


R butcher axe-NaiveBayes 砍掉天真的人。

NaiveBayes 對象是從克拉R包,用於擬合樸素貝葉斯分類器。

用法

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

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

參數

x

一個模型對象。

verbose

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

...

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

砍掉NaiveBayes對象。

例子

library(klaR)
#> Loading required package: MASS

fit_mod <- function() {
  boop <- runif(1e6)
  NaiveBayes(
    y ~ x,
    data = data.frame(y = as.factor(rep(letters[1:4], 1e4)), x = rnorm(4e4))
  )
}

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

weigh(mod_fit)
#> # A tibble: 7 × 2
#>   object        size
#>   <chr>        <dbl>
#> 1 x.x       0.320   
#> 2 apriori   0.00118 
#> 3 tables.x  0.00076 
#> 4 call      0.000448
#> 5 levels    0.000304
#> 6 varnames  0.000112
#> 7 usekernel 0.000056
weigh(mod_res)
#> # A tibble: 6 × 2
#>   object        size
#>   <chr>        <dbl>
#> 1 apriori   0.00118 
#> 2 tables.x  0.00076 
#> 3 levels    0.000304
#> 4 call      0.000112
#> 5 varnames  0.000112
#> 6 usekernel 0.000056

源代碼:R/klaR.R

相關用法


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