Skip to main content
I have changed the title since it seems more about how to turn a logistic regression into a Bayes classifier.
Link
Sextus Empiricus
  • 86.5k
  • 6
  • 115
  • 304

Bayes' classification in Rwith logistic regression

edited tags
Link
kjetil b halvorsen
  • 82.8k
  • 32
  • 201
  • 663
Post Migrated Here from stackoverflow.com (revisions)
Source Link
Ryan Simmons
  • 1.9k
  • 2
  • 19
  • 25

Bayes' classification in R

For a machine learning class I am taking, on our first homework assignment we are given the following problem that has me stuck:

Consider the following simulated data set:

set.seed(123)
n<-100
X<-runif(n)
Y<-rbinom(n,1,exp(0.5+X)/(1+exp(0.5+X)))

a) Find the Bayes' classifier
b) Construct an empirical version of the Bayes' classifier using MLE (you can use 
the glm function)

I don't understand how to find the Bayes' classifier using R. I can find it algebraically, but how do you implement Bayes' classifiers in R? When I search around, the only sources I can find are on "Naive Bayes' classifiers", which don't appear to be the same thing.

This:

http://en.wikipedia.org/wiki/Bayes_classifier

Is the Bayes' classifier I want to find, but I can't find any sources on it for R.

Further, even if I did know how to find the Bayes' classifier, I don't understand what the difference would be between finding it and constructing an empirical version using MLE. The question doesn't even make sense to me. How do I use the glm function to use MLE to construct a classifier? I imagine it has something to do with fitting a logistic model, but I don't understand how to use the glm function in the way I am being asked to? I suspect I might just be getting caught up in the terminology/notation and confusing myself unnecessarily.

Anyone have any pointers for how to get started on this? I'm not asking anyone to code it for me, but it would be nice if someone could point me in the right direction.