Python Learning Week 10 (Solution)

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
(Defaulter)

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: 

 

s8++8w9B5MmTcrL4MfnBKQRvU4kPB4FHclDAKEwduxYmzNnjpH2OewRLKEcMGCABS+WQYbNBIkHgeWxI0eOdK+G+knYltD5IiACUSIQOZEQpcZRXURABERABESgKAlIJBQlfd1bBERABERABJKYgERCEjeOHk0EREAEREAEipKAREJR0te9RUAEREAERCCJCUgkJHHj6NFEQAREQAREoCgJSCQUJX3dWwREQAREQASSmIBEQhI3jh5NBERABERABIqSgERCUdLXvUVABERABEQgiQkgEv4fEpea8wvlkr8AAAAASUVORK5CYII= - Python Learning Week 10 (Solution)

h0rAdLuB2ywAAAAASUVORK5CYII= - Python Learning Week 10 (Solution)

qA0RIAJEgAgQgaBA4P8DgB476ovMmIgAAAAASUVORK5CYII= - Python Learning Week 10 (Solution)


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: 

c82sypNDfGoAAAAASUVORK5CYII= - Python Learning Week 10 (Solution)


 

 

wcTMnAMcvxxVQAAAABJRU5ErkJggg== - Python Learning Week 10 (Solution)

dV50HWg60DXga4DXQe6DpxKHdgkPdhfnQddB7oOdB3oOtB1oOvAqdSBTdby+qvzoOtA14GuA10Hug50HTiVOvBfpP1k+D4viVwAAAAASUVORK5CYII= - Python Learning Week 10 (Solution)
APx47ch+yFIGHAAAAAElFTkSuQmCC - Python Learning Week 10 (Solution)

What we studied in week 10:
In this week we studied Naive Bayes Classification Model. Basically Naive Bayes
classification is a probabilistic machine learning model used for classification
task. 
It is based on Bayes theorem.
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.