Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your task: Recall that Naive Bayes assumes all xi s are conditionally independent given y . However, in this assignment, you will be building a

Your task:
Recall that Naive Bayes assumes all xis are conditionally independent given y. However, in this assignment, you will be building a not-so-Naive Bayes model where now xis are correlated. In particular, we will only consider two features x1 and x2, where x1 and x2 are not conditionally independent given y. We assume f(x1,x2|y = k) is a bi-variate Gaussian
1
distribution N(\mu 1k,\mu 2k,\sigma 1,\sigma 2,\rho ), where \mu 1k and \mu 2k are means of x1 and x2 given y = k,\sigma 1 and \sigma 2 are standard deviations of x1 and x2, and \rho is the correlation between x1 and x2. Notethat\mu 1k and\mu 2k dependonthevaluekofy,but\sigma 1,\sigma 2,and\rho donotdependony. Also recall that the density of a bi-variate Gaussian distribution, given (\mu 1k,\mu 2k,\sigma 1,\sigma 2,\rho ), is:
\sigma 2(x1\mu 1k)2+\sigma 12(x2\mu 2k)22\rho \sigma 1\sigma 2(x1\mu 1k)(x2\mu 2k)2(1\rho 2)\sigma 2\sigma 2
12
f(x1,x2|y = k)P(y = k) P(y = k|x1,x2)= Pi f(x1,x2|y = i)P(y = i)
Build a not-so-Naive-Bayes model that uses x1 and x2 as features to predict y. Use train data to build your model and make predictions for the test set. When making predictions use the optimal Bayes classifier idea, i.e., if P(y =1|x1,x2)>=0.5, classify the test instance as 1, else classify the test instance as 0. Finally, report the accuracy of your model in the TEST set.
Function Parameters:
train: This is the training data set used to train your model. Particularly, use train set to determine the necessary parameters of the model \mu 1k,\mu 2k,\sigma 1,\sigma 2,\rho and P(y = i). DO NOT use the training set to make predictions and compute the accuracy of your model as you should do it using the test set. train should be a pandas dataframe, that has three columns x1, x2, y. Please note that you should use the entire train data to build your model, in other words, you DONT need to further split the training data to create another test set. You can find a sample training set in HW5traindata.csv.
test: This is the test data set used to make predictions and test the performance of your model. Please note that test data set should not be used during the training of the model and only be used to make predictions and compute the accuracy. test is also a pandas dataframe, that has three columns x1, x2, y. A sample test data set can be found in HW5testdata.csv
Output: Your function should return class predictions for the test set and overall accu- racy of your model in the test set. The type of predictions should be a numpy array and the type of the reported accuracy should be a numpy float.

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

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

=+ (b) Show that the closure of a trifling set is also trifling.

Answered: 1 week ago

Question

4. Explain key barriers to competent intercultural communication

Answered: 1 week ago