How to do it...

Perform the following steps to predict labels based on the trained neural network:

  1. Generate the predictions of the testing dataset based on the model, iris.nn:
        > iris.predict = predict(iris.nn, testset, type="class")
  1. Generate a classification table based on the predicted labels and labels of the testing dataset:
> nn.table = table(testset$Species, iris.predict)
iris.predict
setosa versicolor virginica
setosa 17 0 0
versicolor 0 14 0
virginica 0 1 14
  1. Lastly, generate a confusion matrix based on the classification table:
> confusionMatrix(nn.table)
Output:
Confusion Matrix and Statistics

iris.predict
setosa versicolor virginica
setosa 17 0 0
versicolor 0 14 0
virginica 0 1 14

Overall Statistics

Accuracy : 0.9782609
95% CI : (0.8847282, 0.9994498)
No Information Rate : 0.3695652
P-Value [Acc> NIR] :< 0.00000000000000022204

Kappa : 0.9673063
Mcnemar's Test P-Value : NA

Statistics by Class:

Class: setosa Class: versicolor
Sensitivity 1.0000000 0.9333333
Specificity 1.0000000 1.0000000
PosPred Value 1.0000000 1.0000000
Neg Pred Value 1.0000000 0.9687500
Prevalence 0.3695652 0.3260870
Detection Rate 0.3695652 0.3043478
Detection Prevalence 0.3695652 0.3043478
Balanced Accuracy 1.0000000 0.9666667
Class: virginica
Sensitivity 1.0000000
Specificity 0.9687500
PosPred Value 0.9333333
Neg Pred Value 1.0000000
Prevalence 0.3043478
Detection Rate 0.3043478
Detection Prevalence 0.3260870
Balanced Accuracy 0.9843750
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset