| fuzzy_naive_bayes | R Documentation |
fuzzy_naive_bayes() defines a classification model, estimated by one of the
FuzzyClass classifiers, that can be used with the tidymodels ecosystem
(parsnip, workflows, recipes, rsample, tune, yardstick, ...).
The classifier is chosen through the engine:
| Engine | Classifier | Main arguments |
"gaussian" (default) | FuzzyGaussianNaiveBayes() | fuzzy |
"gamma" | FuzzyGammaNaiveBayes() | fuzzy |
"beta" | FuzzyBetaNaiveBayes() | fuzzy |
"exponential" | FuzzyExponentialNaiveBayes() | fuzzy |
"binomial" | FuzzyBinomialNaiveBayes() | fuzzy |
"poisson" | FuzzyPoissonNaiveBayes() | fuzzy |
"geometric" | FuzzyGeoNaiveBayes() | fuzzy |
"trapezoidal" | FuzzyTrapezoidalNaiveBayes() | fuzzy |
"triangular" | FuzzyTriangularNaiveBayes() | fuzzy |
"hypergeometric" | FuzzyHipergeometricNaiveBayes() | fuzzy |
"bayes_rule" | FuzzyBayesRule() | fuzzy |
"naive" | FuzzyNaiveBayes() | fuzzy |
"dw_gamma" | DWFuzzyGammaNaiveBayes() | fuzzy |
"dw_hypergeometric" | DWFuzzyHipergeometricNaiveBayes() | fuzzy |
"gaussian_fuzzy_param" | GauNBFuzzyParam() | alpha_cut, ranking_method |
"exponential_fuzzy_param" | ExpNBFuzzyParam() | alpha_cut, ranking_method |
"poisson_fuzzy_param" | PoiNBFuzzyParam() | alpha_cut, ranking_method |
Main arguments that do not apply to the chosen engine are ignored. Any other
argument of the classifier (e.g. wdelta and weta for the double weighted
classifiers, alp and w for ranking_method = 4, or verbose) can be
passed through parsnip::set_engine().
The predictors are passed to the classifier as they are (no dummy
variables are created), so use a recipe to prepare them when needed. Each
fit prints a training message; set options(FuzzyClass.verbose = FALSE)
(see fuzzy_verbose()) or set_engine(..., verbose = FALSE) to silence it,
for example when tuning.
This function requires the parsnip package.
fuzzy_naive_bayes(
mode = "classification",
engine = "gaussian",
fuzzy = NULL,
alpha_cut = NULL,
ranking_method = NULL
)
## S3 method for class 'fuzzy_naive_bayes'
update(
object,
parameters = NULL,
fuzzy = NULL,
alpha_cut = NULL,
ranking_method = NULL,
fresh = FALSE,
...
)
mode |
A single character string for the type of model. The only
possible value is |
engine |
A single character string specifying the classifier (see the table above). |
fuzzy |
Logical; whether the membership functions are used (argument
|
alpha_cut |
Smallest alpha-cut of the fuzzy parameters (argument
|
ranking_method |
Integer from 1 to 5: method used to rank the fuzzy
numbers (argument |
object |
A |
parameters |
A 1-row data frame (or |
fresh |
Logical; replace all the arguments ( |
... |
Engine-specific arguments to update. |
A model specification object with classes fuzzy_naive_bayes and
model_spec.
library(parsnip)
spec <- fuzzy_naive_bayes(fuzzy = TRUE) |>
set_engine("gaussian")
spec
model_fit <- fit(spec, Species ~ ., data = iris)
predict(model_fit, iris[c(1, 51, 101), ])
predict(model_fit, iris[c(1, 51, 101), ], type = "prob")
# Fuzzy parameters with the GTFN ranking method
fuzzy_naive_bayes(ranking_method = 5) |>
set_engine("gaussian_fuzzy_param") |>
fit(Species ~ ., data = iris)
# Engine-specific arguments
data(GamWeightData)
fuzzy_naive_bayes() |>
set_engine("dw_gamma", wdelta = rep(1/3, 3), weta = c(0.3, 0.2, 0.5)) |>
fit(class ~ ., data = GamWeightData)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.