Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Nave Bayes Classifier in Python Allowed to use NUMPY only (if needed). The goal of this assignment is to implement Nave Bayes Classifier. You will

Nave Bayes Classifier in Python

Allowed to use NUMPY only (if needed).

The goal of this assignment is to implement Nave Bayes Classifier. You will use the Bernoulli nave Bayes model for the classification task. Bernoulli model requires that all attributes value is binary as a result the dataset of SPECT, provided to you, contains only binary values. Explanation of dataset:

Each patient is classified into two categories: Normal and Abnormal, depending on the number of medical tests he/she passes. The database contains 267 patients data, every person underwent 22 medical tests and each test was either pass or fail. As a result, for each patient 22 binary values were extracted. You have been provided with two files, Spect_train and Spect_test. Spect_train has a total 80 data points and Spect_test has 187 data points.

You will use Spect_train patient data to train your nave Bayes classifier and Spect_test to test it.

A single patient in the dataset is described as a single line of the file. So each line has 23 values, the first value of each line describes whether the person was described as normal (value of 1) or abnormal (value of 0). All other 22 values define which test number the patient failed and which he/she passed.

For example:

The first line of SPECT_train is 1,0,0,0,1,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0.

It can be interpreted as:

Patient

Test1

Test2

Test3

Test4

Test5

Test20

Test21

Test22

Normal (1)

Fail (0)

Fail (0)

Fail (0)

Pass (1)

Fail (0)

Fail (0)

Fail (0)

Fail (0)

If the above data point started from zero: 0,0,0,0,1,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0

Patient

Test1

Test2

Test3

Test4

Test5

Test20

Test21

Test22

Abnormal (0)

Fail (0)

Fail (0)

Fail (0)

Pass (1)

Fail (0)

Fail (0)

Fail (0)

Fail (0)

Task:

You have to implement the Bernoulli nave Bayes classifier for the above set such that given 22 medical test reports of a person, your classifier predicts whether the person is normal or abnormal. You will test your classifier using Spect_test file.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago