text_plain_output_1.png
from sklearn import datasets

from sklearn.model_selection import cross_val_score

from sklearn.naive_bayes import BernoulliNB, MultinomialNB, GaussianNB

digits = datasets.load_digits()
breast = datasets.load_breast_cancer()

X_digits = digits.data
y_digits = digits.target
X_breast = breast.data
y_breast = breast.target

Bern_clf = BernoulliNB()
Mult_clf = MultinomialNB()
Gauss_clf = GaussianNB()

Bern_val_score_digits = cross_val_score(Bern_clf, X_digits, y_digits).mean()
Mult_val_score_digits = cross_val_score(Mult_clf, X_digits, y_digits).mean()
Gauss_val_score_digits = cross_val_score(Gauss_clf, X_digits, y_digits).mean()
Bern_val_score_breast = cross_val_score(Bern_clf, X_breast, y_breast).mean()
Mult_val_score_breast = cross_val_score(Mult_clf, X_breast, y_breast).mean()
Gauss_val_score_breast = cross_val_score(Gauss_clf, X_breast, y_breast).mean()

print('BernoulliNB, digits = ', Bern_val_score_digits)
print('MultinomialNB, digits = ', Mult_val_score_digits)
print('GaussianNB, digits = ', Gauss_val_score_digits)
print('')
print('BernoulliNB, breast = ', Bern_val_score_breast)
print('MultinomialNB, breast = ', Mult_val_score_breast)
print('GaussianNB, breast = ', Gauss_val_score_breast)