-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathdp.Rmd
119 lines (95 loc) · 2.28 KB
/
dp.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
title: "Data Piling"
author: "Eric Bridgeford"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{dp}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r}
require(lolR)
require(ggplot2)
require(MASS)
n=400
d=30
r=3
```
Data for this notebook will be `n=400` examples of `d=30` dimensions.
# DP
## Stacked Cigar Simulation
We first visualize the first `2` dimensions:
```{r, fig.width=5}
testdat <- lol.sims.cigar(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 MDP to `K-1=1` dimension and visualizing:
```{r, fig.width=5}
result <- lol.project.dp(X, Y)
data <- data.frame(x1=result$Xr[,1], y=Y)
data$y <- factor(data$y)
ggplot(data, aes(x=x1, y=y, color=y)) +
geom_point() +
xlab("x1") +
ylab("Class") +
ggtitle("Projected Data using MDP")
```
## Trunk Simulation
We visualize the first `2` dimensions:
```{r, fig.width=5}
testdat <- lol.sims.rtrunk(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 MDP to `K-1=1` dimensions and visualizing:
```{r, fig.width=5}
result <- lol.project.dp(X, Y)
data <- data.frame(x1=result$Xr[,1], y=Y)
data$y <- factor(data$y)
ggplot(data, aes(x=x1, y=y, color=y)) +
geom_point() +
xlab("x1") +
ylab("Class") +
ggtitle("Projected Data using MDP")
```
## Rotated Trunk Simulation
We visualize the first `2` dimensions:
```{r, fig.width=5}
testdat <- lol.sims.rtrunk(n, d, rotate=TRUE)
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 MDP to `K-1=1` dimensions and visualizing:
```{r, fig.width=5}
result <- lol.project.dp(X, Y)
data <- data.frame(x1=result$Xr[,1], y=Y)
data$y <- factor(data$y)
ggplot(data, aes(x=x1, y=y, color=y)) +
geom_point() +
xlab("x1") +
ylab("Class") +
ggtitle("Projected Data using MDP")
```