-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.py
138 lines (95 loc) · 3.64 KB
/
temp.py
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
138
from extrap.entities.coordinate import Coordinate
import numpy as np
def add_measurements_to_gpr(gaussian_process,
selected_coordinates,
measurements,
callpath,
metric,
normalization_factors,
parameters,
eval_point):
X = []
Y = []
for coordinate in selected_coordinates:
x = []
eval_cord = None
if len(parameters) == 2:
eval_cord = Coordinate(float(eval_point[0]), float(eval_point[1]))
elif len(parameters) == 3:
eval_cord = Coordinate(float(eval_point[0]), float(eval_point[1]), float(eval_point[2]))
elif len(parameters) == 4:
eval_cord = Coordinate(float(eval_point[0]), float(eval_point[1]), float(eval_point[2]), float(eval_point[3]))
else:
return 1
if coordinate != eval_cord:
parameter_values = coordinate.as_tuple()
for j in range(len(parameter_values)):
temp = 0
if len(normalization_factors) != 0:
temp = parameter_values[j] * normalization_factors[parameters[j]]
else:
temp = parameter_values[j]
while temp < 1:
temp = temp * 10
x.append(temp)
for measurement in measurements[(callpath, metric)]:
if measurement.coordinate == coordinate:
Y.append(measurement.mean)
break
X.append(x)
gaussian_process.fit(X, Y)
return gaussian_process
def add_measurement_to_gpr(gaussian_process,
coordinate,
measurements,
callpath,
metric,
normalization_factors,
parameters):
X = []
Y = []
x = []
parameter_values = coordinate.as_tuple()
for j in range(len(parameter_values)):
temp = 0
if len(normalization_factors) != 0:
temp = parameter_values[j] * normalization_factors[parameters[j]]
else:
temp = parameter_values[j]
while temp < 1:
temp = temp * 10
x.append(temp)
for measurement in measurements[(callpath, metric)]:
if measurement.coordinate == coordinate:
#print("DEBUG3:",measurement.values)
# append only the first value in the list, until none left
#Y.append(measurement.mean)
Y.append(np.mean(measurement.values[0]))
break
X.append(x)
#print("GPR: x,y:", X, Y)
gaussian_process.fit(X, Y)
return gaussian_process
def add_measurement_to_gpr_test(gaussian_process,
coordinate,
new_value,
normalization_factors,
parameters):
X = []
Y = []
x = []
parameter_values = coordinate.as_tuple()
for j in range(len(parameter_values)):
temp = 0
if len(normalization_factors) != 0:
temp = parameter_values[j] * normalization_factors[parameters[j]]
else:
temp = parameter_values[j]
while temp < 1:
temp = temp * 10
x.append(temp)
Y.append(new_value)
X.append(x)
#print("GPR: x,y:", X, Y)
gaussian_process.fit(X, Y)
return gaussian_process