Answered step by step
Verified Expert Solution
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 notsoNaive Bayes model where now xis are correlated. In particular, we will only consider two features x and x where x and x are not conditionally independent given y We assume fxxy k is a bivariate Gaussian
distribution Nmu kmu ksigma sigma rho where mu k and mu k are means of x and x given y ksigma and sigma are standard deviations of x and x and rho is the correlation between x and x Notethatmu k andmu k dependonthevaluekofy,butsigma sigma andrho donotdependony. Also recall that the density of a bivariate Gaussian distribution, given mu kmu ksigma sigma rho is:
sigma xmu ksigma xmu krho sigma sigma xmu kxmu krho sigma sigma
fxxy kPy k Py kxx Pi fxxy iPy i
Build a notsoNaiveBayes model that uses x and x 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, ie if Py xx classify the test instance as else classify the test instance as 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 kmu ksigma sigma rho and Py 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 x x 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 HWtraindata.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 x x y A sample test data set can be found in HWtestdata.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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started