-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraph plotting.Rmd
137 lines (99 loc) · 4.78 KB
/
Graph plotting.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
title: "Results of anytime S-BP"
output: html_document
---
```{r setup, include=FALSE}
install.packages("ggplot2")
library(ggplot2)
```
```{r}
plotingResults <- function(fileName,title, logScale = FALSE) {
data <- read.csv(file = fileName)
data <- aggregate(.~GraphicalModelName + Iteration,data,mean)
bothAnytime <- data[data$Iteration != -1 ,]
bothSGDPLL <- data[data$Iteration == -1 ,]
p <-ggplot(bothAnytime) + aes( x = Total.Time ,
ymin = MinAndMaxProbabilityofQueryequalsTrue,
ymax= MaxAndMaxProbabilityofQueryequalsTrue,
group = GraphicalModelName,
color = GraphicalModelName ) +
geom_errorbar() +
geom_vline(xintercept = bothSGDPLL$Time[1]) +
geom_hline(yintercept = bothSGDPLL$MinAndMaxProbabilityofQueryequalsTrue[1], color = "black") +
ggtitle(title) +
theme(plot.title = element_text(lineheight=.8, face="bold"))
if(logScale){
bothAnytime <- bothAnytime[bothAnytime$IntervalLength > 10^(-6),]
}
q <- ggplot(bothAnytime) + aes(x = Total.Time,
y = IntervalLength,
group = GraphicalModelName,
color = GraphicalModelName) +
geom_point() + geom_line() + geom_vline(xintercept = bothSGDPLL$Time[1]) +
ggtitle(title) + theme(plot.title = element_text(lineheight=.8, face="bold"))
pdfName <- substr(fileName,1,nchar(fileName) - 4)
pdf(paste("images/", pdfName,"1.pdf"))
print(p)
dev.off()
pdf(paste("images/", pdfName,"2.pdf"))
print(q)
dev.off()
return(list(p,q,data))
}
```
```{r}
plotingResultsWithIncrementalOnly <- function(fileName,title, logScale = FALSE) {
pdfName <- substr(fileName,1,nchar(fileName) - 4)
data <- read.csv(file = fileName)
data <- aggregate(.~GraphicalModelName + Iteration,data,mean)
data <- data[data$GraphicalModelName == paste(pdfName,"Incremental",sep = ""),]
bothAnytime <- data[data$Iteration != -1 ,]
bothSGDPLL <- data[data$Iteration == -1 ,]
p <-ggplot(bothAnytime) + aes( x = Total.Time ,
ymin = MinAndMaxProbabilityofQueryequalsTrue,
ymax= MaxAndMaxProbabilityofQueryequalsTrue,
color = GraphicalModelName ) +
geom_errorbar() +
geom_vline(xintercept = bothSGDPLL$Time[1]) +
geom_hline(yintercept = bothSGDPLL$MinAndMaxProbabilityofQueryequalsTrue[1], color = "black") +
ggtitle(title) +
theme(plot.title = element_text(lineheight=.8, face="bold"))
if(logScale){
bothAnytime <- bothAnytime[bothAnytime$IntervalLength > 10^(-6),]
}
q <- ggplot(bothAnytime) + aes(x = Total.Time,
y = IntervalLength,
color = GraphicalModelName) +
geom_point() + geom_line() + geom_vline(xintercept = bothSGDPLL$Time[1]) +
ggtitle(title) + theme(plot.title = element_text(lineheight=.8, face="bold"))
pdfName <- substr(fileName,1,nchar(fileName) - 4)
pdf(paste("images/", pdfName,"1inc.pdf"))
print(p)
dev.off()
pdf(paste("images/", pdfName,"2inc.pdf"))
print(q)
dev.off()
return(list(p,q,data))
}
data
```
```{r}
plotingResults("lineModel20.csv","Line Model With 20 factors")
plotingResults("lineModel13.csv","Line Model With 13 factors")
plotingResults("lineModel25.csv","Line Model With 25 factors")
plotingResults("BinaryTreeModel5.csv","Binary Tree Model with 5 levels of depth")
plotingResults("IsingModel3X4.csv","Ising Model grid 3 X 4")
plotingResults("IsingModel6X2.csv","Ising Model grid 6 X 2")
```
```{r}
plotingResultsWithIncrementalOnly("lineModel20.csv","Line Model With 20 factors")
plotingResultsWithIncrementalOnly("lineModel13.csv","Line Model With 13 factors")
plotingResultsWithIncrementalOnly("lineModel25.csv","Line Model With 25 factors")
plotingResultsWithIncrementalOnly("BinaryTreeModel5.csv","Binary Tree Model with 5 levels of depth")
plotingResultsWithIncrementalOnly("IsingModel3X4.csv","Ising Model grid 3 X 4")
plotingResultsWithIncrementalOnly("IsingModel6X2.csv","Ising Model grid 6 X 2")
```
```{r}
plotingResultsWithIncrementalOnly("IsingModel4X4.csv","Ising Model grid 4 X 4")
plotingResults("IsingModel4X4.csv","Ising Model grid 4 X 4")
```