lda_fit<-MASS::lda(default~balance, data =Default)lda_pred<-predict(lda_fit, data =Default)table(lda_pred$class, Default$default, dnn =c("Predicted", "Actual"))
Actual
Predicted No Yes
No 9643 257
Yes 24 76
Code
qda_fit<-MASS::qda(default~balance, data =Default)qda_pred<-predict(qda_fit, data =Default)table(qda_pred$class, Default$default, dnn =c("Predicted", "Actual"))
Actual
Predicted No Yes
No 9639 246
Yes 28 87
Code
nb_fit<-e1071::naiveBayes(default~balance, data =Default)nb_pred<-predict(nb_fit, Default)(nb_conf<-table(nb_pred, Default$default))
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
LinearDiscriminantAnalysis()
Code
lda_pred = lda.predict(X)lda_conf_df = pd.DataFrame( confusion_matrix(y_true=y, y_pred=lda_pred), index=[f"Actual: {cls}"for cls in lda.classes_], columns=[f"Predicted: {cls}"for cls in lda.classes_])lda_conf_df
Predicted: No Predicted: Yes
Actual: No 9643 24
Actual: Yes 257 76
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
QuadraticDiscriminantAnalysis()
Code
qda_pred = qda.predict(X)qda_conf_df = pd.DataFrame( confusion_matrix(y, qda_pred), index=[f"Actual: {cls}"for cls in qda.classes_], columns=[f"Predicted: {cls}"for cls in qda.classes_])qda_conf_df
Predicted: No Predicted: Yes
Actual: No 9639 28
Actual: Yes 246 87
Code
nb = GaussianNB()nb.fit(X, y)
GaussianNB()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
GaussianNB()
Code
nb_pred = nb.predict(X)nb_conf_df = pd.DataFrame( confusion_matrix(y, nb_pred), index=[f"Actual: {cls}"for cls in nb.classes_], columns=[f"Predicted: {cls}"for cls in nb.classes_])nb_conf_df
Predicted: No Predicted: Yes
Actual: No 9639 28
Actual: Yes 246 87