From f2cedb21622266dabb3f568f0e29c03ba950935f Mon Sep 17 00:00:00 2001 From: Carlos Sevilla Salcedo Date: Mon, 13 Nov 2023 14:19:54 +0100 Subject: [PATCH] Adapt to new plugin setting --- .../DataProcessing/plugins/binarizer.py | 27 +++++++++++-------- .../plugins/kbinsdiscretizer.py | 26 ++++++++++-------- .../DataProcessing/plugins/labelbinarizer.py | 26 ++++++++++-------- .../DataProcessing/plugins/labelencoder.py | 26 ++++++++++-------- .../DataProcessing/plugins/maxabsscaler.py | 26 ++++++++++-------- .../DataProcessing/plugins/minmaxscaler.py | 26 ++++++++++-------- .../plugins/multilabelbinarizer.py | 26 ++++++++++-------- .../DataProcessing/plugins/normalizer.py | 26 ++++++++++-------- .../DataProcessing/plugins/onehotencoder.py | 26 ++++++++++-------- .../DataProcessing/plugins/ordinalencoder.py | 26 ++++++++++-------- .../plugins/polynomialfeatures.py | 26 ++++++++++-------- .../plugins/quantiletransformer.py | 26 ++++++++++-------- .../DataProcessing/plugins/standardscaler.py | 26 ++++++++++-------- .../Modelling/plugins/affinitypropagation.py | 26 ++++++++++-------- .../Modelling/plugins/bayesianridge.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/birch.py | 26 ++++++++++-------- .../plugins/decisiontreeclassifier.py | 26 ++++++++++-------- .../plugins/decisiontreeregressor.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/elasticnet.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/gpclassifier.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/gpregressor.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/kernelridge.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/kmeans.py | 26 ++++++++++-------- .../Modelling/plugins/knnclassifier.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/knnregressor.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/lasso.py | 26 ++++++++++-------- .../Modelling/plugins/linearregression.py | 26 ++++++++++-------- .../Modelling/plugins/logisticregression.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/meanshift.py | 26 ++++++++++-------- .../plugins/passiveaggressiveclassifier.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/perceptron.py | 26 ++++++++++-------- .../plugins/randomforestclassifier.py | 26 ++++++++++-------- .../plugins/randomforestregressor.py | 26 ++++++++++-------- .../Modelling/plugins/ridgeregression.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/svc.py | 26 ++++++++++-------- src/vai_lab/Modelling/plugins/svr.py | 26 ++++++++++-------- .../xml_files/k-mean_clustering_demo.xml | 25 +++++++++++------ src/vai_lab/utils/plugins/pluginCanvas.py | 5 ++-- 38 files changed, 561 insertions(+), 406 deletions(-) diff --git a/src/vai_lab/DataProcessing/plugins/binarizer.py b/src/vai_lab/DataProcessing/plugins/binarizer.py index 4dab8267..73ce1b88 100644 --- a/src/vai_lab/DataProcessing/plugins/binarizer.py +++ b/src/vai_lab/DataProcessing/plugins/binarizer.py @@ -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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/kbinsdiscretizer.py b/src/vai_lab/DataProcessing/plugins/kbinsdiscretizer.py index 99aa302f..ffcce6a0 100644 --- a/src/vai_lab/DataProcessing/plugins/kbinsdiscretizer.py +++ b/src/vai_lab/DataProcessing/plugins/kbinsdiscretizer.py @@ -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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/labelbinarizer.py b/src/vai_lab/DataProcessing/plugins/labelbinarizer.py index f5c76520..df88bac6 100644 --- a/src/vai_lab/DataProcessing/plugins/labelbinarizer.py +++ b/src/vai_lab/DataProcessing/plugins/labelbinarizer.py @@ -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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/labelencoder.py b/src/vai_lab/DataProcessing/plugins/labelencoder.py index a1dd209f..88e22aa3 100644 --- a/src/vai_lab/DataProcessing/plugins/labelencoder.py +++ b/src/vai_lab/DataProcessing/plugins/labelencoder.py @@ -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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/maxabsscaler.py b/src/vai_lab/DataProcessing/plugins/maxabsscaler.py index c7664835..545d40cc 100644 --- a/src/vai_lab/DataProcessing/plugins/maxabsscaler.py +++ b/src/vai_lab/DataProcessing/plugins/maxabsscaler.py @@ -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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/minmaxscaler.py b/src/vai_lab/DataProcessing/plugins/minmaxscaler.py index 1cdb349d..516c265e 100644 --- a/src/vai_lab/DataProcessing/plugins/minmaxscaler.py +++ b/src/vai_lab/DataProcessing/plugins/minmaxscaler.py @@ -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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/multilabelbinarizer.py b/src/vai_lab/DataProcessing/plugins/multilabelbinarizer.py index 5bbeaa06..cb1c4b9d 100644 --- a/src/vai_lab/DataProcessing/plugins/multilabelbinarizer.py +++ b/src/vai_lab/DataProcessing/plugins/multilabelbinarizer.py @@ -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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/normalizer.py b/src/vai_lab/DataProcessing/plugins/normalizer.py index 05812b33..9b517397 100644 --- a/src/vai_lab/DataProcessing/plugins/normalizer.py +++ b/src/vai_lab/DataProcessing/plugins/normalizer.py @@ -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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/onehotencoder.py b/src/vai_lab/DataProcessing/plugins/onehotencoder.py index 44edd661..70b274be 100644 --- a/src/vai_lab/DataProcessing/plugins/onehotencoder.py +++ b/src/vai_lab/DataProcessing/plugins/onehotencoder.py @@ -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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/ordinalencoder.py b/src/vai_lab/DataProcessing/plugins/ordinalencoder.py index 7e48d568..206fb2cc 100644 --- a/src/vai_lab/DataProcessing/plugins/ordinalencoder.py +++ b/src/vai_lab/DataProcessing/plugins/ordinalencoder.py @@ -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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/polynomialfeatures.py b/src/vai_lab/DataProcessing/plugins/polynomialfeatures.py index b1bcd423..93a467a4 100644 --- a/src/vai_lab/DataProcessing/plugins/polynomialfeatures.py +++ b/src/vai_lab/DataProcessing/plugins/polynomialfeatures.py @@ -18,20 +18,24 @@ class PolynomialFeatures(DataProcessingT): Generate polynomial and interaction features """ - 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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/quantiletransformer.py b/src/vai_lab/DataProcessing/plugins/quantiletransformer.py index 306d4724..43118dc5 100644 --- a/src/vai_lab/DataProcessing/plugins/quantiletransformer.py +++ b/src/vai_lab/DataProcessing/plugins/quantiletransformer.py @@ -16,20 +16,24 @@ class QuantileTransformer(DataProcessingT): Transform features using quantiles information """ - 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 \ No newline at end of file diff --git a/src/vai_lab/DataProcessing/plugins/standardscaler.py b/src/vai_lab/DataProcessing/plugins/standardscaler.py index 029f49c5..1c8708d7 100644 --- a/src/vai_lab/DataProcessing/plugins/standardscaler.py +++ b/src/vai_lab/DataProcessing/plugins/standardscaler.py @@ -16,20 +16,24 @@ class StandardScaler(DataProcessingT): Standardize features by removing the mean and scaling to unit variance """ - 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 \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/affinitypropagation.py b/src/vai_lab/Modelling/plugins/affinitypropagation.py index d1c0d115..21a7e906 100644 --- a/src/vai_lab/Modelling/plugins/affinitypropagation.py +++ b/src/vai_lab/Modelling/plugins/affinitypropagation.py @@ -14,20 +14,24 @@ class AffinityPropagation(ModellingPluginT): Perform Affinity Propagation Clustering of data """ - 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.predict_plugin = self.model.predict \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/bayesianridge.py b/src/vai_lab/Modelling/plugins/bayesianridge.py index 7853e1c6..69a4c094 100644 --- a/src/vai_lab/Modelling/plugins/bayesianridge.py +++ b/src/vai_lab/Modelling/plugins/bayesianridge.py @@ -13,21 +13,25 @@ class BayesianRidge(ModellingPluginT): """ Bayesian ridge regression """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/birch.py b/src/vai_lab/Modelling/plugins/birch.py index dc0ac4f8..a2b0b0f7 100644 --- a/src/vai_lab/Modelling/plugins/birch.py +++ b/src/vai_lab/Modelling/plugins/birch.py @@ -15,20 +15,24 @@ class Birch(ModellingPluginT): Implements the BIRCH clustering algorithm """ - 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.predict_plugin = self.model.predict \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/decisiontreeclassifier.py b/src/vai_lab/Modelling/plugins/decisiontreeclassifier.py index 15c1f284..f47dde08 100644 --- a/src/vai_lab/Modelling/plugins/decisiontreeclassifier.py +++ b/src/vai_lab/Modelling/plugins/decisiontreeclassifier.py @@ -15,21 +15,25 @@ class DecisionTreeClassifier(ModellingPluginTClass): A decision tree classifier """ - 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.predict_plugin = self.model.predict self.predict_proba_plugin = self.model.predict_proba diff --git a/src/vai_lab/Modelling/plugins/decisiontreeregressor.py b/src/vai_lab/Modelling/plugins/decisiontreeregressor.py index f5f8b705..75ec0572 100644 --- a/src/vai_lab/Modelling/plugins/decisiontreeregressor.py +++ b/src/vai_lab/Modelling/plugins/decisiontreeregressor.py @@ -15,21 +15,25 @@ class DecisionTreeRegressor(ModellingPluginT): A decision tree regressor """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/elasticnet.py b/src/vai_lab/Modelling/plugins/elasticnet.py index c986b309..2b93e67b 100644 --- a/src/vai_lab/Modelling/plugins/elasticnet.py +++ b/src/vai_lab/Modelling/plugins/elasticnet.py @@ -14,21 +14,25 @@ class ElasticNet(ModellingPluginT): Linear regression with combined L1 and L2 priors as regularizer """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/gpclassifier.py b/src/vai_lab/Modelling/plugins/gpclassifier.py index a8b25126..7a66253b 100644 --- a/src/vai_lab/Modelling/plugins/gpclassifier.py +++ b/src/vai_lab/Modelling/plugins/gpclassifier.py @@ -17,21 +17,25 @@ class GPClassifier(ModellingPluginTClass): Gaussian process Classifier (GPC) based on Laplace approximation """ - 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.predict_plugin = self.model.predict self.predict_proba_plugin = self.model.predict_proba diff --git a/src/vai_lab/Modelling/plugins/gpregressor.py b/src/vai_lab/Modelling/plugins/gpregressor.py index ee83e8a5..900a1638 100644 --- a/src/vai_lab/Modelling/plugins/gpregressor.py +++ b/src/vai_lab/Modelling/plugins/gpregressor.py @@ -17,21 +17,25 @@ class GPRegressor(ModellingPluginT): Gaussian process regressor """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/kernelridge.py b/src/vai_lab/Modelling/plugins/kernelridge.py index 864c6c39..428f37b7 100644 --- a/src/vai_lab/Modelling/plugins/kernelridge.py +++ b/src/vai_lab/Modelling/plugins/kernelridge.py @@ -17,21 +17,25 @@ class KernelRidge(ModellingPluginT): Kernel ridge regression. """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/kmeans.py b/src/vai_lab/Modelling/plugins/kmeans.py index 0fa2a9f4..5040757c 100644 --- a/src/vai_lab/Modelling/plugins/kmeans.py +++ b/src/vai_lab/Modelling/plugins/kmeans.py @@ -14,21 +14,25 @@ class KMeans(ModellingPluginT): K-Means clustering """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/knnclassifier.py b/src/vai_lab/Modelling/plugins/knnclassifier.py index 25fe692c..f91450c5 100644 --- a/src/vai_lab/Modelling/plugins/knnclassifier.py +++ b/src/vai_lab/Modelling/plugins/knnclassifier.py @@ -15,21 +15,25 @@ class KNNClassifier(ModellingPluginTClass): Classifier implementing the k-nearest neighbors vote """ - 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.predict_plugin = self.model.predict self.predict_proba_plugin = self.model.predict_proba diff --git a/src/vai_lab/Modelling/plugins/knnregressor.py b/src/vai_lab/Modelling/plugins/knnregressor.py index 7b9a5fc3..cbf8abdf 100644 --- a/src/vai_lab/Modelling/plugins/knnregressor.py +++ b/src/vai_lab/Modelling/plugins/knnregressor.py @@ -15,21 +15,25 @@ class KNNRegressor(ModellingPluginT): Regression based on k-nearest neighbors """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/lasso.py b/src/vai_lab/Modelling/plugins/lasso.py index 081f6d88..e8938cf6 100644 --- a/src/vai_lab/Modelling/plugins/lasso.py +++ b/src/vai_lab/Modelling/plugins/lasso.py @@ -13,21 +13,25 @@ class Lasso(ModellingPluginT): Linear Model trained with L1 prior as regularizer """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/linearregression.py b/src/vai_lab/Modelling/plugins/linearregression.py index faee6278..7ddbebd3 100644 --- a/src/vai_lab/Modelling/plugins/linearregression.py +++ b/src/vai_lab/Modelling/plugins/linearregression.py @@ -15,21 +15,25 @@ class LinearRegression(ModellingPluginT): Ordinary least squares Linear Regression """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/logisticregression.py b/src/vai_lab/Modelling/plugins/logisticregression.py index 6e4c0a17..c7c0028e 100644 --- a/src/vai_lab/Modelling/plugins/logisticregression.py +++ b/src/vai_lab/Modelling/plugins/logisticregression.py @@ -16,21 +16,25 @@ class LogisticRegression(ModellingPluginTClass): Logistic regression classification. """ - 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.predict_plugin = self.model.predict self.predict_proba_plugin = self.model.predict_proba diff --git a/src/vai_lab/Modelling/plugins/meanshift.py b/src/vai_lab/Modelling/plugins/meanshift.py index 38f0bd9a..e035d0f5 100644 --- a/src/vai_lab/Modelling/plugins/meanshift.py +++ b/src/vai_lab/Modelling/plugins/meanshift.py @@ -13,20 +13,24 @@ class MeanShift(ModellingPluginT): Mean shift clustering using a flat kernel. """ - 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.predict_plugin = self.model.predict \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/passiveaggressiveclassifier.py b/src/vai_lab/Modelling/plugins/passiveaggressiveclassifier.py index 64531891..4be668ac 100644 --- a/src/vai_lab/Modelling/plugins/passiveaggressiveclassifier.py +++ b/src/vai_lab/Modelling/plugins/passiveaggressiveclassifier.py @@ -15,21 +15,25 @@ class PassiveAggressiveClassifier(ModellingPluginTClass): Passive aggressive classifier """ - 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.predict_plugin = self.model.predict self.predict_proba_plugin = self.model.predict_proba diff --git a/src/vai_lab/Modelling/plugins/perceptron.py b/src/vai_lab/Modelling/plugins/perceptron.py index 69799653..62f12252 100644 --- a/src/vai_lab/Modelling/plugins/perceptron.py +++ b/src/vai_lab/Modelling/plugins/perceptron.py @@ -16,21 +16,25 @@ class Perceptron(ModellingPluginTClass): Linear perceptron classification """ - 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.predict_plugin = self.model.predict self.predict_proba_plugin = self.model.predict_proba diff --git a/src/vai_lab/Modelling/plugins/randomforestclassifier.py b/src/vai_lab/Modelling/plugins/randomforestclassifier.py index 4ac41571..5baa27cd 100644 --- a/src/vai_lab/Modelling/plugins/randomforestclassifier.py +++ b/src/vai_lab/Modelling/plugins/randomforestclassifier.py @@ -16,21 +16,25 @@ class RandomForestClassifier(ModellingPluginTClass): A random forest classifier """ - 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.predict_plugin = self.model.predict self.predict_proba_plugin = self.model.predict_proba diff --git a/src/vai_lab/Modelling/plugins/randomforestregressor.py b/src/vai_lab/Modelling/plugins/randomforestregressor.py index 116a80e5..6aefbede 100644 --- a/src/vai_lab/Modelling/plugins/randomforestregressor.py +++ b/src/vai_lab/Modelling/plugins/randomforestregressor.py @@ -16,21 +16,25 @@ class RandomForestRegressor(ModellingPluginT): A random forest regression """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/ridgeregression.py b/src/vai_lab/Modelling/plugins/ridgeregression.py index 610d87ea..b4ba0f7f 100644 --- a/src/vai_lab/Modelling/plugins/ridgeregression.py +++ b/src/vai_lab/Modelling/plugins/ridgeregression.py @@ -15,21 +15,25 @@ class RidgeRegression(ModellingPluginT): Linear least squares with l2 regularization """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/Modelling/plugins/svc.py b/src/vai_lab/Modelling/plugins/svc.py index 1b8f19a9..60336b8a 100644 --- a/src/vai_lab/Modelling/plugins/svc.py +++ b/src/vai_lab/Modelling/plugins/svc.py @@ -18,21 +18,25 @@ class SVC(ModellingPluginTClass): C-Support Vector Classification """ - 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.predict_plugin = self.model.predict self.predict_proba_plugin = self.model.predict_proba diff --git a/src/vai_lab/Modelling/plugins/svr.py b/src/vai_lab/Modelling/plugins/svr.py index f01ef1c9..265c0d1e 100644 --- a/src/vai_lab/Modelling/plugins/svr.py +++ b/src/vai_lab/Modelling/plugins/svr.py @@ -18,21 +18,25 @@ class SVR(ModellingPluginT): Epsilon-Support Vector Regression """ - 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.predict_plugin = self.model.predict self.score_plugin = self.model.score \ No newline at end of file diff --git a/src/vai_lab/examples/xml_files/k-mean_clustering_demo.xml b/src/vai_lab/examples/xml_files/k-mean_clustering_demo.xml index 1c7ff0b8..75ad944f 100644 --- a/src/vai_lab/examples/xml_files/k-mean_clustering_demo.xml +++ b/src/vai_lab/examples/xml_files/k-mean_clustering_demo.xml @@ -25,20 +25,23 @@ - (0, 1) + (0, 1) + + + - X + X - X + X @@ -58,23 +61,29 @@ - 4 + 4 + + + - 500 + 500 + + + - X + X - X + X @@ -96,7 +105,7 @@ Modelling - .\examples\results\output.pkl + .\examples\results\output.pkl diff --git a/src/vai_lab/utils/plugins/pluginCanvas.py b/src/vai_lab/utils/plugins/pluginCanvas.py index 64095638..c63e5950 100644 --- a/src/vai_lab/utils/plugins/pluginCanvas.py +++ b/src/vai_lab/utils/plugins/pluginCanvas.py @@ -515,6 +515,7 @@ def optionsWindow(self): plugin_meth_list = [meth[0] for meth in getmembers(plugin, isfunction) if meth[0][0] != '_'] # Find available methods for the model model_meth_list = [meth[0] for meth in getmembers(self.model, ismethod) if meth[0][0] != '_'] + model_meth_list += [meth[0] for meth in getmembers(self.model, isfunction) if meth[0][0] != '_'] # List intersection # TODO: use only methods from the model set_2 = frozenset(model_meth_list) @@ -1096,7 +1097,7 @@ def upload(self): arrow = tk.LAST, arrowshape = (12,10,5), tags=('o'+str(parent_id), 'o'+str(1), modout['coordinates'][2][connect[p]])) - self.out_data.iloc[int(parent_id)][1] = 1 + self.out_data.iloc[int(parent_id)].iloc[1] = 1 self.connections[1][ int(parent_id)] = out[0]+str(parent_id) + '-' + ins[0]+str(1) self.m: int = self.id_mod[2] @@ -1206,7 +1207,7 @@ def draw_connection(self, modules): tags = ('o'+str(parent_id), # 'o'+str(self.id_mod[-1]), modules[key]['coordinates'][2][connect[p]])) - self.out_data.iloc[int(parent_id)][int(ins[1:])] = 1 + self.out_data.iloc[int(parent_id)].iloc[int(ins[1:])] = 1 self.connections[int(ins[1:])][ int(parent_id)] = out[0]+str(out[1:]) + '-' + ins[0]+str(ins[1:]) else: