# FuzzyClass

Last update: 19-05-2022

## A family of probabilities-based classifiers Fuzzy and Non-Fuzzy

### Installation

``````# Installation
install.packages("devtools")
devtools::install_github("Jodavid/FuzzyClass")``````

### Usage

``````# package import
library(FuzzyClass)``````

### Data reading and preparation for use

``````library(FuzzyClass)
library(caret)
#> Carregando pacotes exigidos: lattice
#> Carregando pacotes exigidos: ggplot2

#' ---------------------------------------------
#' The following shows how the functions are used:
#' --------------
#'
#' Actual training data:
data(VirtualRealityData)

VirtualRealityData <- as.data.frame(VirtualRealityData)

# Splitting into Training and Testing
split <- caTools::sample.split(t(VirtualRealityData[,1]), SplitRatio = 0.7)
Train <- subset(VirtualRealityData, split == "TRUE")
Test <- subset(VirtualRealityData, split == "FALSE")
# ----------------

test = Test[,-4]``````

#### Fuzzy Gaussian Naive Bayes with Fuzzy Parameters

``````# --------------------------------------------------
# Fuzzy Gaussian Naive Bayes with Fuzzy Parameters

fit_FGNB <- GauNBFuzzyParam(train =  Train[,-4],
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"
saida <- predict(fit_FGNB, test)
confusionMatrix(factor(Test[,4]), saida)
#> Confusion Matrix and Statistics
#>
#>           Reference
#> Prediction  1  2  3
#>          1 42 10  0
#>          2  9 42  9
#>          3  3 10 55
#>
#> Overall Statistics
#>
#>                Accuracy : 0.7722
#>                  95% CI : (0.7039, 0.8313)
#>     No Information Rate : 0.3556
#>     P-Value [Acc > NIR] : <2e-16
#>
#>                   Kappa : 0.6571
#>
#>  Mcnemar's Test P-Value : 0.3757
#>
#> Statistics by Class:
#>
#>                      Class: 1 Class: 2 Class: 3
#> Sensitivity            0.7778   0.6774   0.8594
#> Specificity            0.9206   0.8475   0.8879
#> Pos Pred Value         0.8077   0.7000   0.8088
#> Neg Pred Value         0.9062   0.8333   0.9196
#> Prevalence             0.3000   0.3444   0.3556
#> Detection Rate         0.2333   0.2333   0.3056
#> Detection Prevalence   0.2889   0.3333   0.3778
#> Balanced Accuracy      0.8492   0.7624   0.8737

saida <- predict(fit_FGNB, test, type = "matrix")``````