From a823c860c73058837c40db4078c115c91d1c026c Mon Sep 17 00:00:00 2001 From: Jaka Date: Fri, 9 Dec 2022 10:51:43 +0100 Subject: [PATCH] pca: avoid "AttributeError: can't set attribute" in ImprovedPCA n_features_ attribute of decomposition.PCA is deprecated in favor of n_features_in_ --- Orange/projection/pca.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Orange/projection/pca.py b/Orange/projection/pca.py index 5ba55f49fac..98787557f32 100644 --- a/Orange/projection/pca.py +++ b/Orange/projection/pca.py @@ -99,12 +99,12 @@ class ImprovedPCA(skl_decomposition.PCA): # pylint: disable=too-many-branches def _fit(self, X): """Dispatch to the right submethod depending on the chosen solver.""" - X = check_array( + X = self._validate_data( X, - accept_sparse=["csr", "csc"], dtype=[np.float64, np.float32], - ensure_2d=True, - copy=self.copy, + reset=False, + accept_sparse=["csr", "csc"], + copy=self.copy ) # Handle n_components==None @@ -201,7 +201,7 @@ def _fit_truncated(self, X, n_components, svd_solver): random_state=random_state, ) - self.n_samples_, self.n_features_ = n_samples, n_features + self.n_samples_ = n_samples self.components_ = V self.n_components_ = n_components @@ -221,12 +221,12 @@ def _fit_truncated(self, X, n_components, svd_solver): def transform(self, X): check_is_fitted(self, ["mean_", "components_"], all_or_any=all) - X = check_array( + X = self._validate_data( X, accept_sparse=["csr", "csc"], dtype=[np.float64, np.float32], - ensure_2d=True, - copy=self.copy, + reset=False, + copy=self.copy ) if self.mean_ is not None: