Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@glemaitre
Copy link
Member

@glemaitre glemaitre commented Oct 23, 2023

closes #27626

This PR makes sure to convert to CSR the validated CSC matrix when contamination is a floating number. We still don't want to call score_samples because it will cost an additional validation, more expensive than the expected X.asformat("csr").

@github-actions
Copy link

github-actions bot commented Oct 23, 2023

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: e5cb229. Link to the linter CI: here

Copy link
Member

@adam2392 adam2392 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me.

"""
X, _ = make_classification(n_samples=50, n_features=4, random_state=0)
X = sparse_container(X)
X.sort_indices()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why do we need to sort the indices?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea. I took back the minimum reproducer but it was probably failing without sorting indices.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorting indices allows getting into a canonical representation (e.g. with no duplicates' ambiguity).

Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @glemaitre

@OmarManzoor OmarManzoor enabled auto-merge (squash) December 2, 2023 06:31
@OmarManzoor OmarManzoor merged commit 9371cec into scikit-learn:main Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Isolation Forest Bug with Sparse Matrix and Contamination as Float

4 participants