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

Add circle model to the RANSAC gallery example #5208

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sciunto
Copy link
Member

@sciunto sciunto commented Jan 29, 2021

Description

To investigate #5186 I wrote this example that I propose to add to the gallery.

Checklist

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.

@pep8speaks
Copy link

pep8speaks commented Jan 29, 2021

Hello @sciunto! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 124:1: E402 module level import not at top of file
Line 140:1: E101 indentation contains mixed spaces and tabs
Line 140:1: W191 indentation contains tabs
Line 140:5: E128 continuation line under-indented for visual indent
Line 147:1: E101 indentation contains mixed spaces and tabs
Line 150:20: E712 comparison to False should be 'if cond is False:' or 'if not cond:'

Comment last updated at 2021-01-29 09:29:19 UTC

@sciunto sciunto marked this pull request as draft January 29, 2021 08:58
Copy link
Contributor

@grlee77 grlee77 left a comment

Choose a reason for hiding this comment

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

Thanks @sciunto. I have some minor comments, but this looks pretty good to me.

return x, y


# Generate three types of data points
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you briefly describer what the purpose of these 3 are and which one we are expecting to estimate with the circle model?

xy = np.stack([x, y], axis=1).astype(float)

# Fit with RANSAC
ransac_kwarg = {'min_samples': 100,
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not familiar with RANSAC, but looking at the output qualitatively I was wondering why only about half of the circle shows up as inliers in the right panel of the plot?

empirically it seems that changing min_samples to a value <= 80 helps get many more inliers along the circle boundary.

ax[0].plot(x2, y2, '.')
ax[0].plot(x1, y1, '.')

circle = plt.Circle((cy, cx), radius=r, alpha=0.1)
Copy link
Contributor

Choose a reason for hiding this comment

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

increase alpha to 0.3 or so? I didn't really even see the disk at first!

ax[1].add_patch(circle)
ax[1].plot(xy[inliers, 0], xy[inliers, 1],
'bo', markersize=1, label='inliers')
ax[1].plot(xy[~inliers, 0], xy[~inliers, 1],
Copy link
Contributor

Choose a reason for hiding this comment

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

outliers was defined above. Did you intend to use that here instead of ~inliers?

Base automatically changed from master to main February 18, 2021 18:23
@grlee77 grlee77 added the 📄 type: Documentation Updates, fixes and additions to documentation label Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📄 type: Documentation Updates, fixes and additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants