Naïve Bayes Classification Model
Tasks
Task 1
Develop a python program to implement Bayesian classification model for the following dataset and classify the given test vector:
Age |
Loan |
Class |
25 |
40000 |
0 |
35 |
60000 |
0 |
45 |
80000 |
0 |
20 |
20000 |
0 |
35 |
120000 |
0 |
52 |
18000 |
0 |
23 |
95000 |
1 |
40 |
62000 |
1 |
60 |
100000 |
1 |
48 |
220000 |
1 |
33 |
150000 |
1 |
48 |
142000 |
? |
CODE:
Task 2
Use the given cancer dataset and classify it using Bayesian classification model:
a) First create a python script and load
‘cancer’ file.
b) Identify features and classes from the
loaded dataset.
c) Perform 2-fold cross validation on the
dataset by splitting it into testing and training parts.
d) Implement a Bayesian classifier using the
above algorithm and use training dataset to classify each of the sample within
testing dataset.
e) Compute the accuracy from the predicted
test samples.
CODE:
classification is a probabilistic machine learning model used for classification
task.
P(A∣B)=P(B∣A)P(A)/ P(B)
In this Bayes theorem, we can find the probability of A happening, given
that B has occurred. Here, B is the evidence and A is the hypothesis. The
assumption made here is that the predictors/features are independent. That is
presence of one particular feature does not affect the other that is why it is
called “naive”. Also we implemented this theorem in python. This is all we have studied in this week.