Skip to content

Commit

Permalink
Adapt to new plugin setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sevisal committed Nov 13, 2023
1 parent c002e86 commit f2cedb2
Show file tree
Hide file tree
Showing 38 changed files with 561 additions and 406 deletions.
27 changes: 16 additions & 11 deletions src/vai_lab/DataProcessing/plugins/binarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,25 @@ class Binarizer(DataProcessingT):
Binarize data (set feature values to 0 or 1) according to a threshold
"""

def __init__(self, config = {}, data_in = [None]):
def __init__(self, config = {}, data_in = [None], ini = False):
"""Initialises parent class.
Passes `globals` dict of all current variables
"""
super().__init__(globals())
self.set_data_in(data_in)
self.configure(config)

try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise

if not ini:
# Model configuration
self.set_data_in(data_in)
self.configure(config)
# Model initialisation
try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise
else:
self.model = model

# Method mapping
self.fit_plugin = self.model.fit
self.transform_plugin = self.model.transform
26 changes: 15 additions & 11 deletions src/vai_lab/DataProcessing/plugins/kbinsdiscretizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ class KBinsDiscretizer(DataProcessingT):
Bin continuous data into interval
"""

def __init__(self, config = {}, data_in = [None]):
def __init__(self, config = {}, data_in = [None], ini = False):
"""Initialises parent class.
Passes `globals` dict of all current variables
"""
super().__init__(globals())
self.set_data_in(data_in)
self.configure(config)

try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise

if not ini:
# Model configuration
self.set_data_in(data_in)
self.configure(config)
# Model initialisation
try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise
else:
self.model = model

self.fit_plugin = self.model.fit
self.transform_plugin = self.model.transform
26 changes: 15 additions & 11 deletions src/vai_lab/DataProcessing/plugins/labelbinarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@ class LabelBinarizer(DataProcessingT):
"""
Binarize labels in a one-vs-all fashion
"""
def __init__(self, config = {}, data_in = [None]):
def __init__(self, config = {}, data_in = [None], ini = False):
"""Initialises parent class.
Passes `globals` dict of all current variables
"""
super().__init__(globals())
self.set_data_in(data_in)
self.configure(config)

try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise

if not ini:
# Model configuration
self.set_data_in(data_in)
self.configure(config)
# Model initialisation
try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise
else:
self.model = model

self.fit_plugin = self.model.fit
self.transform_plugin = self.model.transform
26 changes: 15 additions & 11 deletions src/vai_lab/DataProcessing/plugins/labelencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ class LabelEncoder(DataProcessingT):
Encode target labels with value between 0 and n_classes-1
"""

def __init__(self, config = {}, data_in = [None]):
def __init__(self, config = {}, data_in = [None], ini = False):
"""Initialises parent class.
Passes `globals` dict of all current variables
"""
super().__init__(globals())
self.set_data_in(data_in)
self.configure(config)

try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise

if not ini:
# Model configuration
self.set_data_in(data_in)
self.configure(config)
# Model initialisation
try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise
else:
self.model = model

self.fit_plugin = self.model.fit
self.transform_plugin = self.model.transform
26 changes: 15 additions & 11 deletions src/vai_lab/DataProcessing/plugins/maxabsscaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ class MaxAbsScaler(DataProcessingT):
Scale each feature by its maximum absolute value
"""

def __init__(self, config = {}, data_in = [None]):
def __init__(self, config = {}, data_in = [None], ini = False):
"""Initialises parent class.
Passes `globals` dict of all current variables
"""
super().__init__(globals())
self.set_data_in(data_in)
self.configure(config)

try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise

if not ini:
# Model configuration
self.set_data_in(data_in)
self.configure(config)
# Model initialisation
try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise
else:
self.model = model

self.fit_plugin = self.model.fit
self.transform_plugin = self.model.transform
26 changes: 15 additions & 11 deletions src/vai_lab/DataProcessing/plugins/minmaxscaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ class MinMaxScaler(DataProcessingT):
is in the given range on the training set, e.g. between zero and one
"""

def __init__(self, config = {}, data_in = [None]):
def __init__(self, config = {}, data_in = [None], ini = False):
"""Initialises parent class.
Passes `globals` dict of all current variables
"""
super().__init__(globals())
self.set_data_in(data_in)
self.configure(config)

try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise

if not ini:
# Model configuration
self.set_data_in(data_in)
self.configure(config)
# Model initialisation
try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise
else:
self.model = model

self.fit_plugin = self.model.fit
self.transform_plugin = self.model.transform
26 changes: 15 additions & 11 deletions src/vai_lab/DataProcessing/plugins/multilabelbinarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ class MultiLabelBinarizer(DataProcessingT):
Transform between iterable of iterables and a multilabel format
"""

def __init__(self, config = {}, data_in = [None]):
def __init__(self, config = {}, data_in = [None], ini = False):
"""Initialises parent class.
Passes `globals` dict of all current variables
"""
super().__init__(globals())
self.set_data_in(data_in)
self.configure(config)

try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise

if not ini:
# Model configuration
self.set_data_in(data_in)
self.configure(config)
# Model initialisation
try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise
else:
self.model = model

self.fit_plugin = self.model.fit
self.transform_plugin = self.model.transform
26 changes: 15 additions & 11 deletions src/vai_lab/DataProcessing/plugins/normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,24 @@ class Normalizer(DataProcessingT):
Normalize samples individually to unit norm
"""

def __init__(self, config = {}, data_in = [None]):
def __init__(self, config = {}, data_in = [None], ini = False):
"""Initialises parent class.
Passes `globals` dict of all current variables
"""
super().__init__(globals())
self.set_data_in(data_in)
self.configure(config)

try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise

if not ini:
# Model configuration
self.set_data_in(data_in)
self.configure(config)
# Model initialisation
try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise
else:
self.model = model

self.fit_plugin = self.model.fit
self.transform_plugin = self.model.transform
26 changes: 15 additions & 11 deletions src/vai_lab/DataProcessing/plugins/onehotencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ class OneHotEncoder(DataProcessingT):
Encode categorical features as a one-hot numeric array
"""

def __init__(self, config = {}, data_in = [None]):
def __init__(self, config = {}, data_in = [None], ini = False):
"""Initialises parent class.
Passes `globals` dict of all current variables
"""
super().__init__(globals())
self.set_data_in(data_in)
self.configure(config)

try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise

if not ini:
# Model configuration
self.set_data_in(data_in)
self.configure(config)
# Model initialisation
try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise
else:
self.model = model

self.fit_plugin = self.model.fit
self.transform_plugin = self.model.transform
26 changes: 15 additions & 11 deletions src/vai_lab/DataProcessing/plugins/ordinalencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ class OrdinalEncoder(DataProcessingT):
Encode categorical features as an integer array
"""

def __init__(self, config = {}, data_in = [None]):
def __init__(self, config = {}, data_in = [None], ini = False):
"""Initialises parent class.
Passes `globals` dict of all current variables
"""
super().__init__(globals())
self.set_data_in(data_in)
self.configure(config)

try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise

if not ini:
# Model configuration
self.set_data_in(data_in)
self.configure(config)
# Model initialisation
try:
self.model = model(**self._config["options"])
except Exception as exc:
print('The plugin encountered an error on the parameters of '
+str(list(self._PLUGIN_READABLE_NAMES.keys())[list(self._PLUGIN_READABLE_NAMES.values()).index('default')])+': '+str(exc)+'.')
raise
else:
self.model = model

self.fit_plugin = self.model.fit
self.transform_plugin = self.model.transform
Loading

0 comments on commit f2cedb2

Please sign in to comment.