Skip to content
Snippets Groups Projects
Commit e837df89 authored by Raphael's avatar Raphael
Browse files

Error in normalisation argument raises error

parent ff0fad14
No related branches found
No related tags found
3 merge requests!15Resolve "normalisation should raise exception when bad arguments given",!14Resolve "normalisation should raise exception when bad arguments given",!13Draft: Develop
This commit is part of merge request !13. Comments created here will be created in the context of that merge request.
...@@ -44,6 +44,9 @@ class AISPoints: ...@@ -44,6 +44,9 @@ class AISPoints:
def normalize(self, min_max_features=(), standardization_features=(), third_quartile_features=(), def normalize(self, min_max_features=(), standardization_features=(), third_quartile_features=(),
divide_by_value=(), divide_by_max=(), normalization_dict=None): divide_by_value=(), divide_by_max=(), normalization_dict=None):
if normalization_dict is 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 = {} normalization_dict = {}
for f in min_max_features: for f in min_max_features:
if f in self.df.columns: if f in self.df.columns:
...@@ -94,7 +97,7 @@ class AISPoints: ...@@ -94,7 +97,7 @@ class AISPoints:
normalization_dict[f] = {'type': 'divide by max', normalization_dict[f] = {'type': 'divide by max',
'maximum': maximum} 'maximum': maximum}
self.df[f] = self.df[f] / maximum self.df[f] = self.df[f] / maximum
else: elif type(normalization_dict) == dict:
for f in normalization_dict: for f in normalization_dict:
if f in self.df.columns: if f in self.df.columns:
if normalization_dict[f]['type'] == 'min-max': if normalization_dict[f]['type'] == 'min-max':
...@@ -125,6 +128,8 @@ class AISPoints: ...@@ -125,6 +128,8 @@ class AISPoints:
raise ValueError( raise ValueError(
f"{normalization_dict[f]['type']} not a valid normalization method. Must be on of [min-max," f"{normalization_dict[f]['type']} not a valid normalization method. Must be on of [min-max,"
f" standardization, 3rd quartile, divide by value]") f" standardization, 3rd quartile, divide by value]")
else:
raise ValueError("normalization_dict not a dictionary")
return normalization_dict return normalization_dict
# New features # New features
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment