Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Predict using Bayes theorem Now you have all the probabilities you need. Next, let's use Bayes theorem (see equation in the Computure Priors section above)

Predict using Bayes theorem

Now you have all the probabilities you need. Next, let's use Bayes theorem (see equation in the "Computure Priors" section above) and compute, for each representative, that probability that they are a democrat, and the probability that they are a republican, given their vote.

- Compute the probability of interest (=|8) . Use the plain Bayes theorem here and the conditional probablities you calculated above. Do not compute it using the counts directly (that will not scale to naive bayes!).Note: you have to pick the correct conditional probability. For instance, when computing the probability that the representative is a democrat, you have to choose either (=|=) or (=|=) , and the correct normalizer, either (=) or (=) , depending on whether she voted yea or nay.

- categorize the representatives to democrats and republicans using threshold 0.5. It means those representatives who have (=|=)>0.5 will be considered democrats and the way around.

- Print the confusion matrix and accuracy. (Note: it may help to use the confusion_matrix fucntion from sklearn.metrics)

- Compare your accuracy with accuracy of the naive model that predict every representative to the majority class. How much better is your classifier?

- Repeat the process with other bills. Which bill will give you the best accuracy? Which one the worst?

Hint: you may want to write a function and loop over columns of the dataset.

Hint2: Bills 2,10, 16 will give the lowest accuracy.

USE PYTON JUPYTER

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

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

4 How can you create a better online image for yourself?

Answered: 1 week ago