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

Skip to content

FIX Optics paper typo #13750

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

Merged
merged 8 commits into from
Apr 30, 2019
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
5 changes: 4 additions & 1 deletion sklearn/cluster/optics_.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,10 @@ def _xi_cluster(reachability_plot, predecessor_plot, ordering, xi, min_samples,
# Find the first index from the right side which is almost
# at the same level as the beginning of the detected
# cluster.
while (reachability_plot[c_end - 1] < D_max
# Our implementation corrects a mistake in the original
# paper, i.e., in Definition 11 4c, r(x) < r(sD) should be
# r(x) > r(sD).
while (reachability_plot[c_end - 1] > D_max
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a comment "This corrects the paper, which uses >, to use < instead" or something?

and c_end > U_start):
c_end -= 1

Expand Down
7 changes: 4 additions & 3 deletions sklearn/cluster/tests/test_optics.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_extract_xi():
X, expected_labels = shuffle(X, expected_labels, random_state=rng)

clust = OPTICS(min_samples=3, min_cluster_size=2,
max_eps=np.inf, cluster_method='xi',
max_eps=20, cluster_method='xi',
xi=0.4).fit(X)
assert_array_equal(clust.labels_, expected_labels)

Expand All @@ -108,7 +108,7 @@ def test_extract_xi():
X, expected_labels = shuffle(X, expected_labels, random_state=rng)

clust = OPTICS(min_samples=3, min_cluster_size=3,
max_eps=np.inf, cluster_method='xi',
max_eps=20, cluster_method='xi',
xi=0.1).fit(X)
# this may fail if the predecessor correction is not at work!
assert_array_equal(clust.labels_, expected_labels)
Expand All @@ -127,9 +127,10 @@ def test_extract_xi():


def test_cluster_hierarchy_():
rng = np.random.RandomState(0)
n_points_per_cluster = 100
C1 = [0, 0] + 2 * rng.randn(n_points_per_cluster, 2)
C2 = [0, 0] + 10 * rng.randn(n_points_per_cluster, 2)
C2 = [0, 0] + 50 * rng.randn(n_points_per_cluster, 2)
X = np.vstack((C1, C2))
X = shuffle(X, random_state=0)

Expand Down