<jupyter_start><jupyter_text><jupyter_code># Installing all the important libraries
!pip install numpy
!pip install pandas
!pip install sklearn
# Importing important libraries
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from sklearn.naive_bayes import GaussianNB
from sklearn import model_selection
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
from google.colab import files
uploaded = files.upload()
import io
data = pd.read_csv(io.BytesIO(uploaded['Iris.csv']))
data.head()
#Replace Species type with numbers
data.Species.replace(['Iris-setosa', 'Iris-versicolor', 'Iris-virginica'], [1, 2, 3], inplace=True)
# Split-out validation dataset
split_data = data.values
train_data = split_data[:,1:5]
target = split_data[:,5]
train_feature, test_feature , train_label, test_label = train_test_split(train_data, target, 
                                                    test_size=0.3, 
                                                    random_state=7)
train_feature.shape, test_feature.shape, train_label.shape, test_label.shape
#Initialize Gaussian Naive Bayes
clf = GaussianNB()
# Test options and evaluation metric
scoring = 'accuracy'

#Fitting the training set
clf.fit(train_feature, train_label) 

#Predicting for the Test Set
pred_clf = clf.predict(test_feature)
#Prediction Probability
prob_pos_clf = clf.predict_proba(test_feature)[:, 1]
#Model Performance
#setting performance parameters
kfold = model_selection.KFold(n_splits=10, random_state=7)

#calling the cross validation function
cv_results = model_selection.cross_val_score(GaussianNB(), train_feature, train_label, cv=kfold, scoring=scoring)

#displaying the mean and standard deviation of the prediction
msg = "%s: %f (%f)" % ('NB accuracy', cv_results.mean(), cv_results.std())
print(msg)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09104552276138068, 'fraction_numerical': 0.0065032516258129065, 'mean_word_length': 4.9523809523809526, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '126792', 'license': 'MIT', 'n_tokens_mistral': 617, 'n_tokens_neox': 595, 'n_words': 171, 'path': 'Iris_DS9.ipynb', 'repo_name': 'Jitender46559/IMD-Project', 'size': '1999'}