<jupyter_start><jupyter_text>Bernoulli Naive Bayes Classifier<jupyter_code>from sklearn.naive_bayes import BernoulliNB

bnb = BernoulliNB()

bnb.fit(X_train_transformed, Y_train)

Y_pred_class = bnb.predict(X_test_transfromed)

Y_pred_proba = bnb.predict_proba(X_test_transfromed)

# Checking accuracy
from sklearn import metrics

metrics.accuracy_score(Y_test, Y_pred_class)
metrics.confusion_matrix(Y_test, Y_pred_class)
confusion = metrics.confusion_matrix(Y_test, Y_pred_class)

TP = confusion[1,1]
TN = confusion[0,0]
FP = confusion[0,1]
FN = confusion[1,0]
sensitivity = TP/ (TP + FN)
print("Sensitivity ", sensitivity)
specificity = TN/(TN + FP)
print("specificity", specificity)
precision = TP / (TP + FP)
print("pricision ", precision)
print("Precision Score:",metrics.precision_score(Y_test, Y_pred_class))
print("Recall Score:", metrics.recall_score(Y_test, Y_pred_class))
print("F1 Score:", metrics.f1_score(Y_test, Y_pred_class))<jupyter_output>F1 Score: 0.9058823529411765
{'fraction_non_alphanumeric': 0.11764705882352941, 'fraction_numerical': 0.028397565922920892, 'mean_word_length': 8.4, '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': '331375', 'license': 'MIT', 'n_tokens_mistral': 404, 'n_tokens_neox': 372, 'n_words': 66, 'path': 'SMSClassifierNaiveBayes.ipynb', 'repo_name': 'aryancodify/NaiveBayesClassification', 'size': '986'}