| FuzzyClassifier | R Documentation |
FuzzyClassifier is the (abstract) R6 class shared by every classifier of
the package. It implements the common workflow:
$new(...) creates an untrained model holding its hyperparameters;
$fit(train, cl) estimates the model and reports the progress;
$predict(newdata, type) classifies new observations;
$set_params(...) changes hyperparameters (the model must be re-trained).
Do not instantiate it directly: use one of the concrete classes, e.g.
FuzzyGaussianNaiveBayesModel, FuzzyGammaNaiveBayesModel or
GauNBFuzzyParamModel. Each of them also has a functional interface (e.g.
FuzzyGaussianNaiveBayes()) that trains and returns the R6 object, and every
classifier is available to tidymodels through fuzzy_naive_bayes().
Since $fit() and $set_params() return the object invisibly, calls can be
chained: FuzzyGammaNaiveBayesModel$new()$fit(x, y)$predict(x_new).
paramsNamed list with the hyperparameters of the classifier.
estimatesList with the quantities estimated by $fit()
(NULL while the model has not been trained).
predictorsNames of the predictors seen during training.
classesClasses (levels of the response) seen during training.
n_obsNumber of training observations.
fit_timeTraining time, in seconds.
labelName of the classifier (read-only); it depends on whether
the membership functions are used (fuzzy).
FuzzyClassifier$new()Create a new (untrained) classifier.
FuzzyClassifier$new(...)
...Named hyperparameters of the classifier.
FuzzyClassifier$fit()Estimate the classifier from training data.
FuzzyClassifier$fit(train, cl, verbose = fuzzy_verbose())
trainMatrix or data frame of training set cases.
clFactor (or vector) of true classifications of the training set.
verboseLogical; if TRUE (default, see fuzzy_verbose()) a
message reports the training progress.
The trained object, invisibly.
FuzzyClassifier$predict()Classify new observations.
FuzzyClassifier$predict(newdata, type = c("class", "prob", "matrix", "raw"))
newdataMatrix or data frame of test set cases, with the predictors in the same order used in training.
type"class" (default) for a factor of predicted classes, or
"prob" for a matrix of class probabilities (one column per class).
"matrix" and "raw" are accepted as synonyms of "prob".
A factor (type = "class") or a numeric matrix.
FuzzyClassifier$set_params()Update hyperparameters. The model is reset and must be
trained again with $fit().
FuzzyClassifier$set_params(...)
...Named hyperparameters, as in $new().
The object, invisibly.
FuzzyClassifier$is_fitted()Has the model been trained?
FuzzyClassifier$is_fitted()
TRUE or FALSE.
FuzzyClassifier$print()Print a summary of the classifier.
FuzzyClassifier$print(...)
...Ignored.
FuzzyClassifier$clone()The objects of this class are cloneable with this method.
FuzzyClassifier$clone(deep = FALSE)
deepWhether to make a deep clone.
model <- FuzzyGaussianNaiveBayesModel$new(fuzzy = TRUE)
model$fit(train = iris[, -5], cl = iris$Species)
model
head(model$predict(iris[, -5]))
head(model$predict(iris[, -5], type = "prob"))
# S3 generics also work
head(predict(model, iris[, -5]))
# Change a hyperparameter and re-train, silently
model$set_params(fuzzy = FALSE)$fit(iris[, -5], iris$Species, verbose = FALSE)
model$label
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.