From eb186d4ab2a4e06a307ea592127623105a09431a Mon Sep 17 00:00:00 2001 From: Badr Date: Tue, 31 Oct 2023 10:25:45 -0400 Subject: [PATCH 1/5] Correcting linear models hierarchy - correct: get_attributes --- .../machine_learning/vertica/linear_model.py | 32 ++----------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/verticapy/machine_learning/vertica/linear_model.py b/verticapy/machine_learning/vertica/linear_model.py index 9452f0a8e..bdb41764c 100755 --- a/verticapy/machine_learning/vertica/linear_model.py +++ b/verticapy/machine_learning/vertica/linear_model.py @@ -49,20 +49,6 @@ class LinearModel: def _attributes(self) -> list[str]: return ["coef_", "intercept_", "features_importance_"] - # System & Special Methods. - - @abstractmethod - def __init__(self) -> None: - """Must be overridden in the child class""" - return None - # self.input_relation = None - # self.test_relation = None - # self.X = None - # self.y = None - # self.parameters = {} - # for att in self._attributes: - # setattr(self, att, None) - # Attributes Methods. def _compute_attributes(self) -> None: @@ -208,18 +194,6 @@ class LinearModelClassifier(LinearModel): def _attributes(self) -> list[str]: return ["coef_", "intercept_", "classes_", "features_importance_"] - # System & Special Methods. - - @abstractmethod - def __init__(self) -> None: - """Must be overridden in the child class""" - return None - # self.input_relation = None - # self.test_relation = None - # self.X = None - # self.y = None - # self.classes_ = None - # Attributes Methods. def _compute_attributes(self) -> None: @@ -283,7 +257,7 @@ def plot( """ -class ElasticNet(Regressor, LinearModel): +class ElasticNet(LinearModel, Regressor): """ Creates an ElasticNet object using the Vertica Linear Regression algorithm. The Elastic Net @@ -1162,7 +1136,7 @@ def __init__( } -class LinearRegression(Regressor, LinearModel): +class LinearRegression(LinearModel, Regressor): """ Creates a LinearRegression object using the Vertica Linear Regression algorithm. @@ -2091,7 +2065,7 @@ def __init__( """ -class LogisticRegression(BinaryClassifier, LinearModelClassifier): +class LogisticRegression(LinearModelClassifier, BinaryClassifier): """ Creates a LogisticRegression object using the Vertica Logistic Regression algorithm. From 0be47cfb410bc534aa82deca78d5dd63fd2e1962 Mon Sep 17 00:00:00 2001 From: Badr Date: Tue, 31 Oct 2023 11:25:04 -0400 Subject: [PATCH 2/5] Update linear_model.py --- verticapy/machine_learning/vertica/linear_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/verticapy/machine_learning/vertica/linear_model.py b/verticapy/machine_learning/vertica/linear_model.py index bdb41764c..e348b1515 100755 --- a/verticapy/machine_learning/vertica/linear_model.py +++ b/verticapy/machine_learning/vertica/linear_model.py @@ -694,7 +694,7 @@ def __init__( } -class Lasso(Regressor, LinearModel): +class Lasso(LinearModel, Regressor): """ Creates a Lasso object using the Vertica Linear Regression algorithm. @@ -1595,7 +1595,7 @@ def __init__( } -class Ridge(Regressor, LinearModel): +class Ridge(LinearModel, Regressor): """ Creates a Ridge object using the Vertica Linear Regression algorithm. From 9d2aaca61e4d13875abfba3b6ff74e1ab7029274 Mon Sep 17 00:00:00 2001 From: Badr Date: Tue, 31 Oct 2023 19:51:00 -0400 Subject: [PATCH 3/5] Update test_base_model_methods.py --- .../machine_learning/vertica/test_base_model_methods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verticapy/tests_new/machine_learning/vertica/test_base_model_methods.py b/verticapy/tests_new/machine_learning/vertica/test_base_model_methods.py index c5e475e31..86b2d4c20 100644 --- a/verticapy/tests_new/machine_learning/vertica/test_base_model_methods.py +++ b/verticapy/tests_new/machine_learning/vertica/test_base_model_methods.py @@ -805,7 +805,7 @@ def test_get_attributes(self, get_models, model_class): "features_importance_trees_", ] else: - vpy_model_attributes = [] + vpy_model_attributes = ['coef_', 'intercept_', 'features_importance_'] assert get_models.vpy.model.get_attributes() == vpy_model_attributes From 77755be3cca2203c013a50d98871fbed920fa5ac Mon Sep 17 00:00:00 2001 From: Badr Date: Tue, 31 Oct 2023 21:17:18 -0400 Subject: [PATCH 4/5] Update test_base_model_methods.py --- .../machine_learning/vertica/test_base_model_methods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verticapy/tests_new/machine_learning/vertica/test_base_model_methods.py b/verticapy/tests_new/machine_learning/vertica/test_base_model_methods.py index 86b2d4c20..a8a16e6db 100644 --- a/verticapy/tests_new/machine_learning/vertica/test_base_model_methods.py +++ b/verticapy/tests_new/machine_learning/vertica/test_base_model_methods.py @@ -805,7 +805,7 @@ def test_get_attributes(self, get_models, model_class): "features_importance_trees_", ] else: - vpy_model_attributes = ['coef_', 'intercept_', 'features_importance_'] + vpy_model_attributes = ["coef_", "intercept_", "features_importance_"] assert get_models.vpy.model.get_attributes() == vpy_model_attributes From 6553b1a71676843d6bc2aa7d1f2af8da4761baf7 Mon Sep 17 00:00:00 2001 From: Badr Date: Wed, 1 Nov 2023 04:24:27 -0400 Subject: [PATCH 5/5] Update linear_model.py --- verticapy/machine_learning/vertica/linear_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verticapy/machine_learning/vertica/linear_model.py b/verticapy/machine_learning/vertica/linear_model.py index a505995e4..3700df290 100755 --- a/verticapy/machine_learning/vertica/linear_model.py +++ b/verticapy/machine_learning/vertica/linear_model.py @@ -2031,7 +2031,7 @@ def __init__( } -class Ridge(Regressor, LinearModel): +class Ridge(LinearModel, Regressor): """ Creates a Ridge object using the Vertica Linear Regression algorithm.