Quadratic Optimal QDA (QOQ)

2018-02-05

Data for this notebook will be n=100 examples of d=100 dimensions.

QOQ

We first visualize the first 2 dimensions:

testdat <- lol.sims.qdtoep(n, d)
X <- testdat$X Y <- testdat$Y

data <- data.frame(x1=X[,1], x2=X[,2], y=Y)
data$y <- factor(data$y)
ggplot(data, aes(x=x1, y=x2, color=y)) +
geom_point() +
xlab("x1") +
ylab("x2") +
ggtitle("Simulated Data")

Projecting with LR-CCA to 5 dimensions and visualizing the first 2:

result <- lol.project.qoq(X, Y, r)

data <- data.frame(x1=result$Xr[,1], x2=result$Xr[,2], y=Y)
data$y <- factor(data$y)
ggplot(data, aes(x=x1, y=x2, color=y)) +
geom_point() +
xlab("x1$") + ylab("x2") + ggtitle("Projected Data using QOQ") Classifying with QDA: quaddy <- MASS::qda(result$Xr, Y)
result <- predict(quaddy, result$Xr) lhat <- 1 - sum(result$class == Y)/length(Y)

print(sprintf("QOQ, QDA L =%.3f", lhat))
## [1] "QOQ, QDA L =0.070"

which as we can see performs better than LOL with either a linear or quadratic discriminant classifier:

resultl <- lol.project.lol(X, Y, r)

data <- data.frame(x1=resultl$Xr[,1], x2=resultl$Xr[,2], y=Y)
data$y <- factor(data$y)
ggplot(data, aes(x=x1, y=x2, color=y)) +
geom_point() +
xlab("x1") +
ylab("x2") +
ggtitle("Projected Data using LOL")

liney <- MASS::qda(resultl$Xr, Y) result <- predict(liney, resultl$Xr)
lhat <- 1 - sum(result$class == Y)/length(Y) print(sprintf("LOL, LDA L =%.3f", lhat)) ## [1] "LOL, LDA L =0.110" quaddy <- MASS::qda(resultl$Xr, Y)
result <- predict(quaddy, resultl$Xr) lhat <- 1 - sum(result$class == Y)/length(Y)

print(sprintf("LOL, QDA  L =%.3f", lhat))
## [1] "LOL, QDA  L =0.110"