-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel_parameter.py
More file actions
34 lines (23 loc) · 814 Bytes
/
model_parameter.py
File metadata and controls
34 lines (23 loc) · 814 Bytes
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
import math
class ModelParameter():
"""
This class will be used as a data structure for passing dataset records to the prediction model
"""
def __init__(self, name, value, mean=0.0, std=0.0):
self.name = name
self.value = value
self.mean = mean
self.std = std
def normalize(self):
"""
There are 2 cases: computing z-score or sin, depending if the column represents the time
"""
if self.name == "Time":
return math.sin(math.pi * self.value / (24 * 3600))
else:
nvalue = (self.value - self.mean) / self.std
return nvalue
@staticmethod
def denormalize(nvalue, mean, std):
dvalue = nvalue * std + mean
return dvalue