Skip to content

Comments

Fix OPTICS min_samples casting to int to avoid NN TypeError (swev-id: scikit-learn__scikit-learn-14496)#43

Open
casey-brooks wants to merge 1 commit intoscikit-learn__scikit-learn-14496from
fix/optics-min-samples-cast
Open

Fix OPTICS min_samples casting to int to avoid NN TypeError (swev-id: scikit-learn__scikit-learn-14496)#43
casey-brooks wants to merge 1 commit intoscikit-learn__scikit-learn-14496from
fix/optics-min-samples-cast

Conversation

@casey-brooks
Copy link

Summary

  • normalize OPTICS min_samples and min_cluster_size via ceil/clip and reuse ints throughout the graph build
  • surface the normalized values on the estimator, cover fractional inputs in docstrings, and update the changelog referencing issue [BUG] Optics float min_samples NN instantiation #41 and Emerson’s research
  • add regression tests for fractional and invalid parameters plus protection in cluster_optics_xi

Testing

  • LD_LIBRARY_PATH=/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/gh2dd8vimringn726ndall19gbm77prj-openblas-0.3.30/lib:/nix/store/y6zrr7dfg051mz4dpjvaldy4g9cy6wmq-lapack-3/lib:/nix/store/4wdz42ns29ys6fm1xak68bnp51nxhd2s-zlib-1.3.1/lib: /workspace/sklearn-py37/bin/python -m pytest sklearn/cluster/tests/test_optics.py
  • /workspace/sklearn-py37/bin/flake8 --ignore=E121,E123,E126,E24,E704,W503,W504,E731,E303 sklearn/cluster/optics_.py sklearn/cluster/tests/test_optics.py

Resolves #41.

@casey-brooks casey-brooks requested a review from a team December 26, 2025 03:15
@casey-brooks
Copy link
Author

Test & Lint

  • LD_LIBRARY_PATH=/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/gh2dd8vimringn726ndall19gbm77prj-openblas-0.3.30/lib:/nix/store/y6zrr7dfg051mz4dpjvaldy4g9cy6wmq-lapack-3/lib:/nix/store/4wdz42ns29ys6fm1xak68bnp51nxhd2s-zlib-1.3.1/lib: /workspace/sklearn-py37/bin/python -m pytest sklearn/cluster/tests/test_optics.py (49 passed)
  • /workspace/sklearn-py37/bin/flake8 --ignore=E121,E123,E126,E24,E704,W503,W504,E731,E303 sklearn/cluster/optics_.py sklearn/cluster/tests/test_optics.py (no issues)

@rowan-stein rowan-stein changed the title Fix OPTICS fractional min_samples coercion Fix OPTICS min_samples casting to int to avoid NN TypeError (swev-id: scikit-learn__scikit-learn-14496) Dec 26, 2025
Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

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

Looks good to me. Fractional parameters are now normalized before building the neighbor graph, downstream helpers reuse the integer counts, and the regression plus validation tests catch the prior TypeError scenario. Docs and what's new entries are in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants