<jupyter_start><jupyter_text>Now put heading according to the description mentioned in the dataset<jupyter_code>data.columns = ["sepal length", "sepal width", "petal length", "petal width", "Class"]
data.head()<jupyter_output><empty_output><jupyter_text>Make sure that all the datatypes are correct and consistent<jupyter_code>data.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 149 entries, 0 to 148
Data columns (total 5 columns):
sepal length    149 non-null float64
sepal width     149 non-null float64
petal length    149 non-null float64
petal width     149 non-null float64
Class           149 non-null object
dtypes: float64(4), object(1)
memory usage: 5.9+ KB<jupyter_text>Dividing the dataset in X and Y (Attributes and Classes)<jupyter_code>X = data.drop(['Class'], axis = 1)
Y = data['Class']
X.head()
Y.head()<jupyter_output><empty_output><jupyter_text>Now split the data into training and test data<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(X, Y, random_state = 0, test_size = 0.30)
classifier = GaussianNB()
classifier.fit(X_train, y_train)<jupyter_output><empty_output><jupyter_text>__The class prior shows the probability of each class. This can be set before building the model manually. If not then it is handled by the function.In the above cas the priors are not set. So it is adjusted according to the data.__ __The priors adjusted according to the data are as follows__<jupyter_code>classifier.class_prior_<jupyter_output><empty_output><jupyter_text>__Var_smoothing is the portion of the largest variance of all features that is added to variances for calculation stability.In this case the parameter has been set to default.__<jupyter_code>classifier.get_params()
y_pred = classifier.predict(X_test)
cm = confusion_matrix(y_test, y_pred)
print("Confusion matrix: ", cm)
print("Accuracy of the model: " ,accuracy_score(y_test, y_pred))<jupyter_output>Accuracy of the model:  0.8888888888888888
{'fraction_non_alphanumeric': 0.08859470468431772, 'fraction_numerical': 0.03004073319755601, 'mean_word_length': 6.224264705882353, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '668248', 'license': 'MIT', 'n_tokens_mistral': 678, 'n_tokens_neox': 631, 'n_words': 207, 'path': 'Naive_Bayes/Naive_bayes_classifier.ipynb', 'repo_name': 'Ajith013/Machine_learning', 'size': '1964'}