From c921439cded2cbe1f9c43948a5f27b9820f1f829 Mon Sep 17 00:00:00 2001
From: alexbacce <alessio.baccelli95@gmail.com>
Date: Wed, 18 Dec 2019 16:58:32 +0100
Subject: [PATCH] Fix in check_is_fitted method

---
 .../causality_tests/shifted_linear_coefficient.py    |  2 +-
 .../causality_tests/shifted_pearson_correlation.py   |  2 +-
 .../experimental/trend_models/exponential_trend.py   |  2 +-
 .../experimental/trend_models/polynomial_trend.py    |  2 +-
 .../standard_features/standard_features.py           |  4 ++--
 giottotime/models/regressors/linear_regressor.py     |  2 +-
 giottotime/models/time_series_models/gar.py          | 12 ++++++------
 7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/giottotime/causality_tests/shifted_linear_coefficient.py b/giottotime/causality_tests/shifted_linear_coefficient.py
index a29d1b7..f1ffaa0 100644
--- a/giottotime/causality_tests/shifted_linear_coefficient.py
+++ b/giottotime/causality_tests/shifted_linear_coefficient.py
@@ -94,7 +94,7 @@ def transform(self, data: pd.DataFrame) -> pd.DataFrame:
             fit coefficients between each timeseries. The shift is indicated in rows.
 
         """
-        check_is_fitted(self, ["best_shifts_", "max_corrs_"])
+        check_is_fitted(self)
         data_t = data.copy()
 
         for col in data_t:
diff --git a/giottotime/causality_tests/shifted_pearson_correlation.py b/giottotime/causality_tests/shifted_pearson_correlation.py
index a6eb6d5..3cfef70 100644
--- a/giottotime/causality_tests/shifted_pearson_correlation.py
+++ b/giottotime/causality_tests/shifted_pearson_correlation.py
@@ -92,7 +92,7 @@ def transform(self, data: pd.DataFrame) -> pd.DataFrame:
             between each timeseries The shift is indicated in rows.
 
         """
-        check_is_fitted(self, ["best_shifts_", "max_corrs_"])
+        check_is_fitted(self)
         data_t = data.copy()
 
         for col in data_t:
diff --git a/giottotime/experimental/trend_models/exponential_trend.py b/giottotime/experimental/trend_models/exponential_trend.py
index b5bf246..74f79d5 100644
--- a/giottotime/experimental/trend_models/exponential_trend.py
+++ b/giottotime/experimental/trend_models/exponential_trend.py
@@ -90,7 +90,7 @@ def predict(self, time_series: pd.DataFrame) -> pd.DataFrame:
             Raised if the model is not fitted yet.
 
         """
-        check_is_fitted(self, ["model_exponent_"])
+        check_is_fitted(self)
 
         predictions = np.exp(time_series * self.model_exponent_)
         return predictions
diff --git a/giottotime/experimental/trend_models/polynomial_trend.py b/giottotime/experimental/trend_models/polynomial_trend.py
index d5151d9..68bc7df 100644
--- a/giottotime/experimental/trend_models/polynomial_trend.py
+++ b/giottotime/experimental/trend_models/polynomial_trend.py
@@ -95,7 +95,7 @@ def predict(self, ts: pd.DataFrame) -> pd.DataFrame:
             Raised if the model is not fitted yet.
 
         """
-        check_is_fitted(self, ["model_weights_"])
+        check_is_fitted(self)
 
         p = np.poly1d(self.model_weights_)
         predictions = p(ts.values)
diff --git a/giottotime/feature_creation/standard_features/standard_features.py b/giottotime/feature_creation/standard_features/standard_features.py
index 1feba99..36b7dd2 100644
--- a/giottotime/feature_creation/standard_features/standard_features.py
+++ b/giottotime/feature_creation/standard_features/standard_features.py
@@ -180,7 +180,7 @@ def __init__(
         self, constant: int = 2, length: int = 50, output_name: str = "ConstantFeature"
     ):
         super().__init__(output_name)
-        self._length = length
+        self.length = length
         self.constant = constant
 
     def transform(self, time_series: Optional[pd.DataFrame] = None) -> pd.DataFrame:
@@ -204,7 +204,7 @@ def transform(self, time_series: Optional[pd.DataFrame] = None) -> pd.DataFrame:
                 data=self.constant, index=time_series.index
             ).to_frame()
         else:
-            constant_series = pd.Series(data=[self.constant] * self._length).to_frame()
+            constant_series = pd.Series(data=[self.constant] * self.length).to_frame()
 
         constant_series_renamed = self._rename_columns(constant_series)
         return constant_series_renamed
diff --git a/giottotime/models/regressors/linear_regressor.py b/giottotime/models/regressors/linear_regressor.py
index 609724c..26a5262 100644
--- a/giottotime/models/regressors/linear_regressor.py
+++ b/giottotime/models/regressors/linear_regressor.py
@@ -74,7 +74,7 @@ def predict(self, X: pd.DataFrame) -> pd.DataFrame:
             The predictions of the model
 
         """
-        check_is_fitted(self, ["model_weights_"])
+        check_is_fitted(self)
 
         predictions = self.model_weights_[0] + np.dot(X, self.model_weights_[1:])
         return predictions
diff --git a/giottotime/models/time_series_models/gar.py b/giottotime/models/time_series_models/gar.py
index 22358bd..14a6d0e 100644
--- a/giottotime/models/time_series_models/gar.py
+++ b/giottotime/models/time_series_models/gar.py
@@ -25,8 +25,8 @@ def __init__(self, base_model: object, feed_forward: bool = False):
                 f"{base_model} must implement both 'fit' " f"and 'predict' methods"
             )
 
-        self._base_model = base_model
-        self._feed_forward = feed_forward
+        self.base_model = base_model
+        self.feed_forward = feed_forward
 
     def fit(self, X: pd.DataFrame, y: pd.DataFrame, **kwargs: object) -> "GAR":
         """Fit the GAR model according to the training data.
@@ -49,13 +49,13 @@ def fit(self, X: pd.DataFrame, y: pd.DataFrame, **kwargs: object) -> "GAR":
 
         """
         features = X.copy()
-        models_per_predstep = [deepcopy(self._base_model) for _ in range(y.shape[1])]
+        models_per_predstep = [deepcopy(self.base_model) for _ in range(y.shape[1])]
 
         for pred_step, model_for_pred_step in enumerate(models_per_predstep):
             target_y = y[f"y_{pred_step}"]
             model_for_pred_step.fit(features, target_y, **kwargs)
 
-            if self._feed_forward:
+            if self.feed_forward:
                 predictions = model_for_pred_step.predict(features)
                 features[f"preds_{pred_step}"] = predictions
 
@@ -83,7 +83,7 @@ def predict(self, X: pd.DataFrame) -> pd.DataFrame:
             Thrown if the model has not been previously fitted.
 
         """
-        check_is_fitted(self, ["models_per_predstep_", "train_features_"])
+        check_is_fitted(self)
 
         test_features = X.copy()
 
@@ -93,7 +93,7 @@ def predict(self, X: pd.DataFrame) -> pd.DataFrame:
             model_predictions = model_for_pred_step.predict(test_features)
             predictions[f"y_{pred_step}"] = model_predictions
 
-            if self._feed_forward:
+            if self.feed_forward:
                 test_features[f"preds_{pred_step}"] = model_predictions
 
         return predictions