Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCA: remove a sklearn 1.4.0 workaround #6940

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Orange/projection/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ def fit(self, X, Y=None):
if sp.issparse(X) and params["n_components"] == min(X.shape):
X = X.toarray()

# In scikit-learn==1.4.0, only the arpack solver is supported for sparse
# data and `svd_solver="auto"` doesn't auto-resolve to this. This is
# fixed in scikit-learn 1.5.0, but for the time being, override these
# settings here
if sp.issparse(X) and params["svd_solver"] == "auto":
params["svd_solver"] = "arpack"

proj = self.__wraps__(**params)
proj = proj.fit(X, Y)
return PCAModel(proj, self.domain, len(proj.components_))
Expand Down
9 changes: 2 additions & 7 deletions Orange/widgets/unsupervised/tests/test_owpca.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,8 @@ def test_normalized_gives_correct_result(self, prepare_table):
U, S, Va = U[:, :2], S[:2], Va[:2]
x_pca = U * S

# In scikit-learn==1.4.0, the svd_flip function requires a `V` matrix,
# therefore, we provide a dummy matrix of the correct size, so we can
# call the function. In scikit-learn==1.5.0, we can remove this since
# V can be None if we are passing `u_based_decision=True`.
dummy_v = np.zeros_like(x_pca.T)
x_pca, _ = svd_flip(x_pca, dummy_v, u_based_decision=True)
x_widget, _ = svd_flip(widget_result.X.copy(), dummy_v, u_based_decision=True)
x_pca, _ = svd_flip(x_pca, None, u_based_decision=True)
x_widget, _ = svd_flip(widget_result.X.copy(), None, u_based_decision=True)

np.testing.assert_almost_equal(x_widget, x_pca)

Expand Down
Loading