I have this
library(MASS)
mydata.qda <- qda(Sp ~ ., prior = c(1,1,1)/3, data = mydata.learn)
I would like to plot my results like http://scikit-learn.org/0.10/auto_examples/plot_lda_vs_qda.html
I have this
library(MASS)
mydata.qda <- qda(Sp ~ ., prior = c(1,1,1)/3, data = mydata.learn)
I would like to plot my results like http://scikit-learn.org/0.10/auto_examples/plot_lda_vs_qda.html
You should explain what you want to plot , here are some examples
https://tgmstat.wordpress.com/2014/01/15/computing-and-visualizing-lda-in-r/ http://www.statmethods.net/advstats/discriminant.html
in case you post an example data and say what you want to plot, you can get more help
You can plot the line that discriminates between clusters using contour
. Here's an example. I made it following http://www.cbcb.umd.edu/~hcorrada/PracticalML/src/prostate.R
set.seed(357)
Ng <- 100
group.a.x <- seq(from = -3, to = 4, length.out = Ng)
group.a.y <- 6 + 0.3 * group.a.x - 0.3 * group.a.x^2 + rnorm(Ng, sd = 1)
group.a <- data.frame(x = group.a.x, y = group.a.y, group = "A")
group.b.x <- rnorm(n = Ng, mean = 0.5, sd = 0.8)
group.b.y <- rnorm(n = Ng, mean = 2, sd = 0.8)
group.b <- data.frame(x = group.b.x, y = group.b.y, group = "B")
my.xyc <- rbind(group.a, group.b)
plot(my.xyc[, 1:2], col = my.xyc$group)
library(MASS)
mdl <- qda(group ~ x + y, data = my.xyc)
np <- 300
nd.x <- seq(from = min(my.xyc$x), to = max(my.xyc$x), length.out = np)
nd.y <- seq(from = min(my.xyc$y), to = max(my.xyc$y), length.out = np)
nd <- expand.grid(x = nd.x, y = nd.y)
prd <- as.numeric(predict(mdl, newdata = nd)$class)
plot(my.xyc[, 1:2], col = my.xyc$group)
contour(x = nd.x, y = nd.y, z = matrix(prd, nrow = np, ncol = np),
levels = c(1, 2), add = TRUE, drawlabels = FALSE)