<jupyter_start><jupyter_text>Выбор семейства распределений в наивном байесе<jupyter_code>from sklearn import datasets, metrics
from sklearn.model_selection import cross_val_score
from sklearn.naive_bayes import BernoulliNB, MultinomialNB, GaussianNB
import numpy as np
digits = datasets.load_digits()
breast_cancer = datasets.load_breast_cancer()
X_digits = digits.data
y_digits = digits.target
X_cancer = breast_cancer.data
y_cancer = breast_cancer.target
print(cross_val_score(BernoulliNB(), X_cancer, y_cancer).mean())
print(cross_val_score(MultinomialNB(), X_cancer, y_cancer).mean())
print(cross_val_score(GaussianNB(), X_cancer, y_cancer).mean())
print(cross_val_score(BernoulliNB(), X_digits, y_digits).mean())
print(cross_val_score(MultinomialNB(), X_digits, y_digits).mean())
print(cross_val_score(GaussianNB(), X_digits, y_digits).mean())
print(X_digits)
print(X_cancer)<jupyter_output>[[1.799e+01 1.038e+01 1.228e+02 ... 2.654e-01 4.601e-01 1.189e-01]
 [2.057e+01 1.777e+01 1.329e+02 ... 1.860e-01 2.750e-01 8.902e-02]
 [1.969e+01 2.125e+01 1.300e+02 ... 2.430e-01 3.613e-01 8.758e-02]
 ...
 [1.660e+01 2.808e+01 1.083e+02 ... 1.418e-01 2.218e-01 7.820e-02]
 [2.060e+01 2.933e+01 1.401e+02 ... 2.650e-01 4.087e-01 1.240e-01]
 [7.760e+00 2.454e+01 4.792e+01 ... 0.000e+00 2.871e-01 7.039e-02]]
{'fraction_non_alphanumeric': 0.15809669992325404, 'fraction_numerical': 0.16577129700690713, 'mean_word_length': 5.585858585858586, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '518054', 'license': 'MIT', 'n_tokens_mistral': 736, 'n_tokens_neox': 571, 'n_words': 91, 'path': 'LearningOnMarkedData/week5/c02_w05_ex02.ipynb', 'repo_name': 'ishatserka/MachineLearningAndDataAnalysisCoursera', 'size': '1303'}