Skip to content

Commit

Permalink
first implementation of the normalization min_max and z_score
Browse files Browse the repository at this point in the history
  • Loading branch information
qnater committed Sep 18, 2024
1 parent 23e168b commit 65ab647
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
15 changes: 8 additions & 7 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified imputegap/assets/min_max_ground_truth_normalized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified imputegap/imputation/__pycache__/_imputation.cpython-38.pyc
Binary file not shown.
9 changes: 7 additions & 2 deletions imputegap/imputation/_imputation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import toml
from imputegap.algorithms.cdrec import native_cdrec_param
from imputegap.evaluation._evaluation import EvaluationGAP
Expand All @@ -13,12 +15,15 @@ def __init__(self):
"""
self.config = self.load_toml()

def load_toml(self):
def load_toml(self, filepath = "../env/default_values.toml"):
"""
Load default values of algorithms
:return: the config of default values
"""
with open("../env/default_values.toml", "r") as file:
if os.path.exists(filepath) == False:
filepath = "./env/default_values.toml"

with open(filepath, "r") as file:
config = toml.load(file)
return config

Expand Down
Binary file modified imputegap/manager/__pycache__/_manager.cpython-38.pyc
Binary file not shown.
8 changes: 7 additions & 1 deletion imputegap/manager/_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ def normalization_min_max(self):
"""
print("Normalization of the original time series dataset with min/max...")

data_normalized = (self.ts - self.ts.min()) / (self.ts.max() - self.ts.min())
ts_min = self.ts.min(axis=0) # Min for each series
ts_max = self.ts.max(axis=0) # Max for each series

range_ts = ts_max - ts_min
range_ts[range_ts == 0] = 1 # To avoid division by zero for constant series

data_normalized = (self.ts - ts_min) / range_ts
self.normalized_ts = data_normalized

return self.normalized_ts
Expand Down

0 comments on commit 65ab647

Please sign in to comment.