<jupyter_start><jupyter_text>Library import<jupyter_code>import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn import metrics
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
print ("Hello Dhaka")<jupyter_output>Hello Dhaka<jupyter_text>Dataset Load<jupyter_code>data_frame = pd.read_csv('pima-data.csv')
data_frame.head(3)<jupyter_output><empty_output><jupyter_text>Level Encoding<jupyter_code># Mapping the values
map_diabetes = {True : 1, False : 0}

# Setting the map to the data_frame
data_frame['diabetes'] = data_frame['diabetes'].map(map_diabetes)

# Let's see what we have done

data_frame.head(3)<jupyter_output><empty_output><jupyter_text>Training, Test Data Preparing<jupyter_code>feature_column_names = ['num_preg', 'glucose_conc', 'diastolic_bp', 'insulin', 'bmi', 'diab_pred', 'age', 'skin']
predicted_class_name = ['diabetes']

# Getting feature variable values
X = data_frame[feature_column_names].values
y = data_frame[predicted_class_name].values

# Splitting using scikit-learn train_test_split function
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.30, random_state = 42)<jupyter_output><empty_output><jupyter_text>Create and Train Model (GaussianNB)<jupyter_code># create GaussianNBr model object and train it with the data
from sklearn.naive_bayes import GaussianNB
nb_model= GaussianNB()
nb_model.fit(X_train, y_train.ravel())  # ravel() return 1-D array<jupyter_output><empty_output><jupyter_text>Performance on Training data<jupyter_code># get current accuracy of the model
prediction_from_trained_data = nb_model.predict(X_train)
accuracy = metrics.accuracy_score(y_train, prediction_from_trained_data)
print ("Accuracy of our GaussianNB model is : {0:.4f}".format(accuracy))<jupyter_output>Accuracy of our GaussianNB model is : 0.7672<jupyter_text>Performance on Test data<jupyter_code># this returns array of predicted results from test_data
prediction_from_test_data = nb_model.predict(X_test)

accuracy = metrics.accuracy_score(y_test, prediction_from_test_data)

print ("Accuracy of our GaussianNB model is: {0:0.4f} %".format(accuracy))


print ("Confusion Matrix")
print ("{0}".format(metrics.confusion_matrix(y_test, prediction_from_test_data, labels=[1, 0])))

print ("Classification Report")
# labels for set 1=True to upper left and 0 = False to lower right
print ("{0}".format(metrics.classification_report(y_test, prediction_from_test_data, labels=[1, 0])))<jupyter_output>Accuracy of our GaussianNB model is: 0.7446 %
Confusion Matrix
[[ 53  27]
 [ 32 119]]
Classification Report
              precision    recall  f1-score   support

           1       0.62      0.66      0.64        80
           0       0.82      0.79      0.80       151

   micro avg       0.74      0.74      0.74       231
   macro avg       0.72      0.73      0.72       231
weighted avg       0.75      0.74      0.75       231
{'fraction_non_alphanumeric': 0.0973630831643002, 'fraction_numerical': 0.03515889114266396, 'mean_word_length': 5.014227642276423, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '660186', 'license': 'MIT', 'n_tokens_mistral': 1080, 'n_tokens_neox': 990, 'n_words': 244, 'path': 'Hello World with pima.ipynb', 'repo_name': 'mahemon/pima-diabetes-dataset-machine-learning-approach', 'size': '2958'}