8000 fix tests. Add whats new on the current changes · scikit-learn/scikit-learn@827f795 · GitHub
[go: up one dir, main page]

Skip to content

Commit 827f795

Browse files
author
ciku
committed
fix tests. Add whats new on the current changes
1 parent 525b48c commit 827f795

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

doc/whats_new/v1.1.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Changelog
6060
add this information to the plot.
6161
:pr:`21038` by :user:`Guillaume Lemaitre <glemaitre>`.
6262

63-
- |Enhancement| :class:`cluster.SpectralClustering` and :func:`cluster.spectral`
63+
- |Enhancement| :class:`cluster.SpectralClustering` and :func:`cluster.spectral`
6464
now include the new `'cluster_qr'` method from :func:`cluster.cluster_qr`
6565
that clusters samples in the embedding space as an alternative to the existing
6666
`'kmeans'` and `'discrete'` methods.
@@ -105,12 +105,12 @@ Changelog
105105
- |API| Adds :meth:`get_feature_names_out` to :class:`impute.SimpleImputer`,
106106
:class:`impute.KNNImputer`, :class:`impute.IterativeImputer`, and
107107
:class:`impute.MissingIndicator`. :pr:`21078` by `Thomas Fan`_.
108-
108+
109109
- |API| The `verbose` parameter was deprecated for :class:`impute.SimpleImputer`.
110110
A warning will always be raised upon the removal of empty columns.
111111
:pr:`21448` by :user:`Oleh Kozynets <OlehKSS>` and
112112
:user:`Christian Ritter <chritter>.
113-
113+
114114
- |Fix| Fix a bug in :class:`linear_model.RidgeClassifierCV` where the method
115115
`predict` was performing an `argmax` on the scores obtained from
116116
`decision_function` instead of returning the multilabel indicator matrix.
@@ -163,11 +163,17 @@ Changelog
163163
instead of `__init__`.
164164
:pr:`21434` by :user:`Krum Arnaudov <krumeto>`.
165165

166+
167+
:mod: `sklearn.decomposition.KernelPCA`
168+
..........................
169+
-[Fix] :class:`decomposition.KernelPCA` now validates input parameters in `fit` instead of `__init__`
170+
:pr:`21567` by :user: `Maggie Chege <MaggieChege>`
171+
166172
:mod:`sklearn.svm`
167173
..................
168174

169175
- |Fix| :class:`smv.NuSVC`, :class:`svm.NuSVR`, :class:`svm.SVC`,
170-
:class:`svm.SVR`, :class:`svm.OneClassSVM` now validate input
176+
:class:`svm.SVR`, :class:`svm.OneClassSVM` now validate input
171177
parameters in `fit` instead of `__init__`.
172178
:pr:`21436` by :user:`Haidar Almubarak <Haidar13 >`.
173179

sklearn/decomposition/_kernel_pca.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,13 @@ def fit(self, X, y=None):
427427
self : object
428428
Returns the instance itself.
429429
"""
430+
if self.fit_inverse_transform and self.kernel == "precomputed":
431+
raise ValueError("Cannot fit_inverse_transform with a precomputed kernel.")
430432
X = self._validate_data(X, accept_sparse="csr", copy=self.copy_X)
431433
self._centerer = KernelCenterer()
432434
K = self._get_kernel(X)
433435
self._fit_transform(K)
434436

435-
if self.fit_inverse_transform and self.kernel == "precomputed":
436-
raise ValueError("Cannot fit_inverse_transform with a precomputed kernel.")
437-
438437
if self.fit_inverse_transform:
439438
# no need to use the kernel to transform X, use shortcut expression
440439
X_transformed = self.eigenvectors_ * np.sqrt(self.eigenvalues_)

sklearn/decomposition/tests/test_kernel_pca.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ def test_kernel_pca_invalid_parameters():
7979
ValueError.
8080
"""
8181
with pytest.raises(ValueError):
82-
KernelPCA(10, fit_inverse_transform=True, kernel="precomputed")
82+
estimator = KernelPCA(
83+
n_components=10, fit_inverse_transform=True, kernel="precomputed"
84+
)
85+
estimator.fit(np.random.randn(10, 10))
8386

8487

8588
def test_kernel_pca_consistent_transform():

0 commit comments

Comments
 (0)
0