image_output_1.png
from sklearn.naive_bayes import MultinomialNB

from sklearn.neighbors import KNeighborsClassifier

import matplotlib.pylab as plt

import matplotlib.pylab as plt

import seaborn as sns

import seaborn as sns

import sklearn.metrics as pm

import sklearn.metrics as pm

knn_model = KNeighborsClassifier(n_neighbors=7)
knn_model.fit(X_train, y_train)
y_pred = knn_model.predict(X_test)

import sklearn.metrics as pm
pm.confusion_matrix(y_test, y_pred)

tn, fp, fn, tp = pm.confusion_matrix(y_test, y_pred).ravel()

predictions = knn_model.predict(X_train)

#show the confusion matrix is using heatmap from the seaborn library.

import seaborn as sns
import numpy as np
from sklearn.metrics import confusion_matrix

#Generate the confusion matrix
cf_matrix = pm.confusion_matrix(y_test, y_pred)
ax = sns.heatmap(cf_matrix, annot=True, cmap='Blues', fmt='.2f')
ax.set_title('Confusion Matrix\n\n');
ax.set_xlabel('\nActual Values')
ax.set_ylabel('Predicted Values ');
ax.xaxis.set_ticklabels(['healthy (0)','diabetic (1)'])
ax.yaxis.set_ticklabels(['healthy (0)','diabetic (1)'])

# Display the visualization of the Confusion Matrix.
plt.show()

nb_model = MultinomialNB()
nb_model.fit(X_train, y_train)
y_pred = nb_model.predict(X_test)

import sklearn.metrics as pm
tn, fp, fn, tp = pm.confusion_matrix(y_test, y_pred).ravel()

predictions = nb_model.predict(X_train)

import seaborn as sns
import numpy as np
from sklearn.metrics import confusion_matrix
cf_matrix = pm.confusion_matrix(y_test, y_pred)
ax = sns.heatmap(cf_matrix, annot=True, cmap='Greens', fmt='.2f')
ax.set_title('Confusion Matrix\n\n')
ax.set_xlabel('\nActual Values')
ax.set_ylabel('Predicted Values ')
ax.xaxis.set_ticklabels(['healthy (0)', 'diabetic (1)'])
ax.yaxis.set_ticklabels(['healthy (0)', 'diabetic (1)'])
plt.show()