[R] Naive Bayes in R
Saeed Abu Nimeh
sabunime at gmail.com
Thu Aug 2 18:31:33 CEST 2012
You can use a table to compare your predicted values and the response.
Here is an example: http://www.cyclismo.org/tutorial/R/tables.html
On Thu, Aug 2, 2012 at 5:52 AM, Abraham Mathew <abmathewks at gmail.com> wrote:
> I'm developing a naive bayes in R. I have the following data and am trying
> to predict on returned (class).
>
> dat = data.frame(home=c(0,1,1,0,0), gender=c("M","M","F","M","F"),
> returned=c(0,0,1,1,0))
> str(dat)
>
> dat$home <- as.factor(dat$home)
> dat$returned <- as.factor(dat$returned)
>
> library(e1071)
>
> m <- naiveBayes(returned ~ ., dat)
> m
>
> predict(m, dat[1:5,-3])
> table(predict=predict(m, dat[1:5,-3]), true=dat[1:5,3])
> predict(m, dat[1:5,-3], type = "raw")
>
>
> So far, so good I think (???).
>
> I want to know if there is any diagnostic test to determine the overall
> misclassification rate
> of a NB classifier, and if there is a function in R that is available to
> implement it?
>
>
> Thanks,
> Abraham
>
>
> --
> *Abraham Mathew
> Statistical Analyst
> www.amathew.com
> 720-648-0108
> @abmathewks*
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list