Skip to content
Snippets Groups Projects

Resolve "normalisation should raise exception when bad arguments given"

2 files
+ 40
1
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 6
1
@@ -44,6 +44,9 @@ class AISPoints:
def normalize(self, min_max_features=(), standardization_features=(), third_quartile_features=(),
divide_by_value=(), divide_by_max=(), normalization_dict=None):
if normalization_dict is None:
if len(min_max_features) == len(standardization_features) == len(third_quartile_features) == len(
divide_by_value) == len(divide_by_max) == 0:
raise ValueError("All arguments are empty")
normalization_dict = {}
for f in min_max_features:
if f in self.df.columns:
@@ -94,7 +97,7 @@ class AISPoints:
normalization_dict[f] = {'type': 'divide by max',
'maximum': maximum}
self.df[f] = self.df[f] / maximum
else:
elif type(normalization_dict) == dict:
for f in normalization_dict:
if f in self.df.columns:
if normalization_dict[f]['type'] == 'min-max':
@@ -125,6 +128,8 @@ class AISPoints:
raise ValueError(
f"{normalization_dict[f]['type']} not a valid normalization method. Must be on of [min-max,"
f" standardization, 3rd quartile, divide by value]")
else:
raise ValueError("normalization_dict not a dictionary")
return normalization_dict
# New features
Loading