Program -9
Program -9
9. Develop a program to implement the Naive Bayesian classifier considering Olivetti Face Data set for
training. Compute the accuracy of the classifier, considering a few test data sets.
gnb = GaussianNB()
gnb.fit(X_train, y_train)
y_pred = gnb.predict(X_test)
print("\nClassification Report:")
print(classification_report(y_test, y_pred, zero_division=1))
print("\nConfusion Matrix:")
print(confusion_matrix(y_test, y_pred))
plt.show()
output :
Accuracy: 80.83%
Classification Report:
precision recall f1-score support
Confusion Matrix:
[[2 0 0 ... 0 0 0]
[0 2 0 ... 0 0 0]
[0 0 2 ... 0 0 1]
...
[0 0 0 ... 1 0 0]
[0 0 0 ... 0 3 0]
[0 0 0 ... 0 0 5]]
File "C:\Users\gecrcse\anaconda3\gec\lib\site-packages\sklearn\datasets\
_olivetti_faces.py", line 115, in fetch_olivetti_faces
mat_path = _fetch_remote(FACES, dirname=data_home)
File "C:\Users\gecrcse\anaconda3\gec\lib\site-packages\sklearn\datasets\_base.py",
line 1454, in _fetch_remote
urlretrieve(remote.url, file_path)