Exp 10
Exp 10
Bayesian Classifier model to perform this task. Built-in Java classes/API can
be used to write the program. Calculate the accuracy, precision, and recall
for your data set.
Bayes' Theorem:
o Bayes' theorem is also known as Bayes' Rule or Bayes' law, which
is used to determine the probability of a hypothesis with prior
knowledge. It depends on the conditional probability.
o The formula for Bayes' theorem is given as:
Where,
import numpy as np
import pandas as pd
dataset = pd.read_csv('/content/Social_Network_Ads.csv')
dataset.head()
y = dataset.iloc[:, -1].values
# Splitting the dataset into the Training set and Test set
# Feature Scaling
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
classifier = GaussianNB()
classifier.fit(X_train, y_train)
# Predicting the Test set results
y_pred = classifier.predict(X_test)
cm = confusion_matrix(y_test , y_pred)
sns.heatmap(cm , annot=True)
# precision_score
# recall_score
# f1_score