Last update: 24-08-2022
# Installation
install.packages("devtools")
::install_github("Jodavid/FuzzyClass") devtools
# package import
library(FuzzyClass)
library(FuzzyClass)
library(caret)
#> Carregando pacotes exigidos: ggplot2
#> Carregando pacotes exigidos: lattice
#> Warning in system("timedatectl", intern = TRUE): execução do comando
#> 'timedatectl' teve status 1
#' ---------------------------------------------
#' The following shows how the functions are used:
#' --------------
#' Reading a database:
#'
#' Actual training data:
data(VirtualRealityData)
<- as.data.frame(VirtualRealityData)
VirtualRealityData
# Splitting into Training and Testing
<- caTools::sample.split(t(VirtualRealityData[,1]), SplitRatio = 0.7)
split <- subset(VirtualRealityData, split == "TRUE")
Train <- subset(VirtualRealityData, split == "FALSE")
Test # ----------------
= Test[,-4] test
# --------------------------------------------------
# Fuzzy Gaussian Naive Bayes with Fuzzy Parameters
<- GauNBFuzzyParam(train = Train[,-4],
fit_FGNB cl = Train[,4], metd = 1, cores = 1)
print(fit_FGNB)
#>
#> Fuzzy Gaussian Naive Bayes Classifier for Discrete Predictors
#>
#> Variables:
#> [1] "V1" "V2" "V3"
#> Class:
#> [1] "1" "2" "3"
<- predict(fit_FGNB, test)
saida confusionMatrix(factor(Test[,4]), saida)
#> Confusion Matrix and Statistics
#>
#> Reference
#> Prediction 1 2 3
#> 1 53 4 0
#> 2 7 48 10
#> 3 1 12 45
#>
#> Overall Statistics
#>
#> Accuracy : 0.8111
#> 95% CI : (0.7462, 0.8655)
#> No Information Rate : 0.3556
#> P-Value [Acc > NIR] : <2e-16
#>
#> Kappa : 0.7163
#>
#> Mcnemar's Test P-Value : 0.5724
#>
#> Statistics by Class:
#>
#> Class: 1 Class: 2 Class: 3
#> Sensitivity 0.8689 0.7500 0.8182
#> Specificity 0.9664 0.8534 0.8960
#> Pos Pred Value 0.9298 0.7385 0.7759
#> Neg Pred Value 0.9350 0.8609 0.9180
#> Prevalence 0.3389 0.3556 0.3056
#> Detection Rate 0.2944 0.2667 0.2500
#> Detection Prevalence 0.3167 0.3611 0.3222
#> Balanced Accuracy 0.9176 0.8017 0.8571
<- predict(fit_FGNB, test, type = "matrix") saida