Skip to content

Commit faba3cd

Browse files
committed
pca: avoid "AttributeError: can't set attribute" in ImprovedPCA
n_features_ attribute of decomposition.PCA is deprecated in favor of n_features_in_
1 parent 9c02c20 commit faba3cd

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Orange/projection/pca.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,11 @@ class ImprovedPCA(skl_decomposition.PCA):
9999
# pylint: disable=too-many-branches
100100
def _fit(self, X):
101101
"""Dispatch to the right submethod depending on the chosen solver."""
102-
X = check_array(
102+
X = self._validate_data(
103103
X,
104-
accept_sparse=["csr", "csc"],
105104
dtype=[np.float64, np.float32],
106-
ensure_2d=True,
107-
copy=self.copy,
105+
reset=False,
106+
check_params=dict(accept_sparse=["csr", "csc"]),
108107
)
109108

110109
# Handle n_components==None
@@ -201,7 +200,7 @@ def _fit_truncated(self, X, n_components, svd_solver):
201200
random_state=random_state,
202201
)
203202

204-
self.n_samples_, self.n_features_ = n_samples, n_features
203+
self.n_samples_ = n_samples
205204
self.components_ = V
206205
self.n_components_ = n_components
207206

0 commit comments

Comments
 (0)