Answered step by step
Verified Expert Solution
Question
1 Approved Answer
B Naive Bayesian classifier The Naive Bayesian Classifier algorithm is a classification algorithm based on calculating the probability of belonging to each class. That is
B Naive Bayesian classifier
The Naive Bayesian Classifier algorithm is a classification algorithm based on calculating the probability of belonging to each class. That is to say that the test data to be classified will be assigned to the most likely class. The probability of belonging to each class is calculated from the learning data as follows:
class
Here is the a priori probability of belonging to the class in other words its the probability of obtaining a data of class if we draw a data at random. is the probability that a data has the value for the variable if we know its class Here we will calculate this probability by calculating the distance between the data and each barycenter of the classes ie the class average divided by the sum distances between this data and each barycenter.
List of useful functions:
mean, sum: calculate the mean and the sum of a list of values.
unique: returns the list of list values, without repeating values.
asarray: transforms a list into a vector.
vector.prod: makes the product of the values of a vector.
naivebayes.GaussianNB: the naive Bayesian Classifier from sklearn.
Create a function that takes data and labels as input and which returns a label, for each data, predicted from class la more likely according to equation Here again, we take each data, one by one, as test data and we consider all data as training data. It is advisable to first calculate the barycentres and the a priori probabilities for each class, then calculate the conditional probabilities for each class and each variable.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started