library(caret)
# Определим условия перекрестной проверки:
train_control <- trainControl(method = 'cv', number = 10)
Test <- train(Species ~ ., data = iris, trControl = train_control, method = "nb")
print(Test)
## Naive Bayes
##
## 150 samples
## 4 predictor
## 3 classes: 'setosa', 'versicolor', 'virginica'
##
## No pre-processing
## Resampling: Cross-Validated (10 fold)
## Summary of sample sizes: 135, 135, 135, 135, 135, 135, ...
## Resampling results across tuning parameters:
##
## usekernel Accuracy Kappa
## FALSE 0.9533333 0.93
## TRUE 0.9600000 0.94
##
## Tuning parameter 'fL' was held constant at a value of 0
## Tuning
## parameter 'adjust' was held constant at a value of 1
## Accuracy was used to select the optimal model using the largest value.
## The final values used for the model were fL = 0, usekernel = TRUE
## and adjust = 1.
Acc <- mean(predict(Test$finalModel, iris[, -5])$class == iris$Species)
paste("Точность=", round(100*Acc, 2), "%", sep="")
## [1] "Точность=96%"
O'zaro tekshirish natijasida yaxshiroq modelni yaratishning iloji bo'lmadi, ammo o'quv va nazorat namunalarida tasniflagichning aniqligi doimiy ravishda yuqori bo'lib qoldi.
Xulosa:
Naive Bayes sinflashtilari yuqori darajada masshtabli boʻlib, oʻquv muammosidagi oʻzgaruvchilar soni boʻyicha chiziqli qator parametrlarni talab qiladi. Maksimal ehtimollik o'rgatish boshqa ko'plab klassifikatorlar uchun qo'llaniladigan qimmat iterativ yaqinlashish yo'li bilan emas, balki chiziqli vaqtni talab qiladigan yopiq shakldagi ifodani [3]: 718 baholash orqali amalga oshirilishi mumkin. muammoli misollarga sinf belgilarini tayinlaydigan modellar, xususiyat qiymatlari vektorlari sifatida taqdim etiladi ba'zi bir chekli to'plamdan olinadi.
Adabiyotlar:
https://en.wikipedia.org/wiki/Naive_Bayes_classifier
http://gerardnico.com/wiki/data_mining/naive_bayes
http://scikit-learn.org/stable/modules/naive_bayes.html
https://ranalytics.github.io/data-mining/072-NBC.html
Do'stlaringiz bilan baham: |