<jupyter_start><jupyter_text>Naive Bayes Classification Using "Pima Indians Dieabetes Database" Here we will se some basic pandas functions and then perform Naive Bayes classification on the formentioned datasetNaive Bayes is a Supervised Machine Learning algorithm based on the Bayes Theorem that is used to solve classification problems by following a probabilistic approach. It is based on the idea that the predictor variables in a Machine Learning model are independent of each other. Meaning that the outcome of a model depends on a set of independent variables that have nothing to do with each other. I.&nbsp; Firstly we will discuss some pandas dataframe functions.  II. We will see some basic operations that can be performed on pandas dataframe.   &nbsp; &nbsp; (If you wish to skip to the Naive-Bayes classification, go to mark 2.1.)  1.1 First we will import few necessary packages.<jupyter_code>import pandas as pd
from sklearn.metrics import confusion_matrix
from sklearn.naive_bayes import MultinomialNB
from sklearn.model_selection import train_test_split<jupyter_output><empty_output><jupyter_text>1.2 Importing data from CSV to pandas dataframe<jupyter_code>dataset = pd.read_csv('diabetes.csv')<jupyter_output><empty_output><jupyter_text>1.3 Viewing dataset Statistics<jupyter_code>dataset.describe()<jupyter_output><empty_output><jupyter_text>1.4 viewing dataset indexes<jupyter_code>dataset.columns<jupyter_output><empty_output><jupyter_text>1.5 To show first 5 data records use head method of the dataframe class<jupyter_code>dataset.head()<jupyter_output><empty_output><jupyter_text>2.0 Naive Bayes Classification Algorithm 1.  Split Dataset into Training and Testing Datasets2.  Train the Naive Bayes Classifier model3.  Test the trained classifier model for Accuracy4.  Measure Accuracy Score and draw Confusion Matrix<jupyter_code>x_train,x_test,y_train,y_test=train_test_split(dataset.drop('Outcome', axis=1),dataset['Outcome'],test_size=.3)
print(len(x_train))
print(len(y_train))
print(len(x_test))
print(len(y_test))
classifer = MultinomialNB()
classifer.fit(x_train, y_train)

predictions = classifer.predict(x_test)
len(predictions)
from sklearn.metrics import accuracy_score
print(accuracy_score(y_test,predictions))
from sklearn.metrics import confusion_matrix
confusion_matrix(y_test, predictions)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06728734659331359, 'fraction_numerical': 0.008887008040626322, 'mean_word_length': 7.382978723404255, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '106507', 'license': 'MIT', 'n_tokens_mistral': 722, 'n_tokens_neox': 686, 'n_words': 235, 'path': 'classification/naive bayes/naive_bayes.ipynb', 'repo_name': 'knowhere1998/analytics-notebooks', 'size': '2363'}