-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotErrorInEstimates.py
More file actions
118 lines (94 loc) · 3.83 KB
/
plotErrorInEstimates.py
File metadata and controls
118 lines (94 loc) · 3.83 KB
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
from __future__ import division
import sys
import matplotlib.pyplot as plt
from collections import defaultdict
import numpy as np
# graphType = "g32"
graphType = "g46"
# graphName = "orkut"
graphName = "sinaweibo"
exact = {"g32" : {"orkut": 524643952, "sinaweibo": 212977684}, "g46" : {"orkut": 2427699127, "sinaweibo": 662717336}}
graphTypeToName = {"g32": "Triangle", "g46": "4-Clique"}
staticExact = exact[graphType][graphName]
allEstimates = defaultdict(list)
percInd = 0
f = open("./allOutput/demet-sinaweibo_g46_60_60.out")
# f = open("./allOutput/4-Clique-sinaweibo-moreEdges.out")
# f = open("./allOutput/3-Clique-sinaweibo-DiffStartPoint.out")
# f = open("./allOutput/4-Clique-sinaweibo-singleRW.out")
# f = open("allOutput/4-Clique-sinaweibo-high-newStart.out")
# f = open("allOutput/4-Clique-sinaweibo-high.out")
# f = open("./allOutput/outputFiles/3-Clique-orkut-DiffStartPoint.out")
# f = open("./allOutput/3-Clique-orkut-moreEdges.out")
# f = open("./allOutput/4-Clique-orkut-moreEdges.out")
# f = open("./allOutput/3-Clique-orkut-singleRW.out")
# f = open("./allOutput/4-Clique-orkut-singleRW.out")
# f = open("allOutput/4-Clique-orkut.out")
xarr = []
yarr = []
fivePercentLineXarr = []
fivePercentLineYarr = []
fivePercentLineYarrNeg = []
exactCurve = []
varXarr = []
varYarr = []
valuesYarr = []
valuesStd = []
prevFractionEdges = 0
for line in f:
if line[0] == "%":
flds = line.strip().split()
fractionEdges = float(flds[-1])
if percInd > 0:
# print(xarr)
# print(yarr)
if xarr[0] > 0.0:
plt.plot(xarr, yarr, 'o', label=str(prevFractionEdges)+"%")
plt.plot(xarr[0], np.std(yarr), 'ko', label=str(prevFractionEdges)+"%")
# plt.plot(xarr[0], np.std(valuesYarr), 'o', label=str(prevFractionEdges)+"%")
fivePercentLineXarr.append(xarr[0])
fivePercentLineYarr.append(5.0)
fivePercentLineYarrNeg.append(-5.0)
exactCurve.append(0.0)
varXarr.append(xarr[0])
varYarr.append(np.std(yarr))
valuesStd.append(np.std(valuesYarr))
# allEstimates[xarr[0]] = yarr
percInd += 1
xarr = []
yarr = []
valuesYarr = []
prevFractionEdges = fractionEdges
else:
flds = line.strip().split()
estVal = float(flds[2])
# if estVal > 0:
xarr.append(fractionEdges)
err = 100 * (estVal - staticExact)/staticExact
yarr.append(err)
valuesYarr.append(estVal)
if err > 100:
print("Here ---- ", estVal)
plt.plot(xarr, yarr, 'o', label=str(prevFractionEdges)+"%")
plt.plot(xarr[0], np.std(yarr), 'ko', label=str(prevFractionEdges)+"%")
# plt.plot(xarr[0], np.std(valuesYarr), 'o', label=str(prevFractionEdges)+"%")
fivePercentLineXarr.append(xarr[0])
fivePercentLineYarr.append(5.0)
fivePercentLineYarrNeg.append(-5.0)
exactCurve.append(0.0)
varXarr.append(xarr[0])
varYarr.append(np.std(yarr))
valuesStd.append(np.std(valuesYarr))
plt.plot(fivePercentLineXarr, fivePercentLineYarr, 'r--', label="5% Error")
plt.plot(fivePercentLineXarr, fivePercentLineYarrNeg, 'r--', label="-5% Error")
plt.plot(fivePercentLineXarr, exactCurve, 'r--*', label="Exact")
plt.plot(varXarr, varYarr, 'kD-', label="Std. Dev.")
# plt.plot(varXarr, valuesStd, 'k*-', label="Std. Dev.(Estimate)")
f.close()
# plt.title("soc " + graphName + "-- Error in Estimate for " + graphTypeToName[graphType] + "-- (Single RW)")
# plt.title("soc " + graphName + "-- Error in Estimate for " + graphTypeToName[graphType] + "-- (more edges)")
plt.title("soc " + graphName + "-- Error in Estimate for " + graphTypeToName[graphType] + "-- (Random start node for each run)")
plt.ylabel("% Error in Estimate")
plt.xlabel("% Edges Observed")
plt.legend(loc = "upper right", ncol=4)
plt.show()