Skip to content

Add OPTICS clustering algorithm - #15781

Open
dhanu86 wants to merge 1 commit into
TheAlgorithms:masterfrom
dhanu86:add-new-aiml-algorithm
Open

dhanu86 wants to merge 1 commit into
TheAlgorithms:masterfrom
dhanu86:add-new-aiml-algorithm

Conversation

@dhanu86

@dhanu86 dhanu86 commented Nov 22, 2026

Copy link
Copy Markdown

Describe your change

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests?
  • Documentation change?

Implementation

Added OPTICS (Ordering Points To Identify the Clustering Structure), a density-based clustering algorithm.

The implementation includes:

  • Core distance calculation.
  • Neighborhood identification.
  • Reachability distance updates using a priority queue.
  • OPTICS ordering generation.
  • DBSCAN-style cluster extraction.

Testing

  • 31 doctests passed.
  • Ruff checks passed.
  • Code formatted using Ruff.

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is my own work.
  • I understand that pull requests must pass automated tests.
  • This PR only changes one algorithm file.
  • All new Python files are placed inside an existing directory.
  • All filenames are lowercase with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass.
  • The algorithm includes a reference URL.

@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Nov 22, 2026

@algorithms-keeper algorithms-keeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Comment thread machine_learning/optics.py Outdated
from heapq import heappop, heappush
from math import dist, inf, isfinite, isnan

Point = list[float]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Point

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated the type alias from Point to point_type to follow the snake_case naming convention. The correction is included in commit 0d4eb42. Thank you!

@dhanu86
dhanu86 force-pushed the add-new-aiml-algorithm branch from 74d5635 to 0d4eb42 Compare November 22, 2026 18:38

This branch has not been deployed

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

Labels

awaiting reviews This PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant