无法在整洁模型中调整朴素贝叶斯平滑度超参数



我似乎无法将smoothness设置为naive_Bayes()中的超参数,而我可以使用其他模型(如multinom_reg)这样做。我做错了什么?

library(tidymodels)
library(reprex)


nb_spec <- naive_Bayes(smoothness = tune()) %>%
set_engine('klaR') %>%
set_mode('classification')
nb_spec %>% extract_parameter_set_dials()
#> Collection of 0 parameters for tuning
#> 
#> [1] identifier type       object    
#> <0 rows> (or 0-length row.names)

multinom_spec <- multinom_reg(penalty = tune(), mixture = tune()) %>%
set_engine('glmnet') %>% 
set_mode('classification')
multinom_spec %>% extract_parameter_set_dials()
#> Collection of 2 parameters for tuning
#> 
#>  identifier    type    object
#>     penalty penalty nparam[+]
#>     mixture mixture nparam[+]

由reprex包(v2.0.1)创建于2022-06-08

naive_Bayes()引擎由鉴别包提供,因此您需要加载该包才能提取参数集。

library(tidymodels)
library(discrim)
nb_spec <- naive_Bayes(smoothness = tune()) %>%
set_engine('klaR') %>%
set_mode('classification')
nb_spec %>% extract_parameter_set_dials()
#> Collection of 1 parameters for tuning
#> 
#>  identifier       type    object
#>  smoothness smoothness nparam[+]

最新更新