Skip to content

Conversation

@Borda
Copy link
Contributor

@Borda Borda commented Dec 24, 2016

Description

Adding option to use some init parameters for model fitting and RANDSAC initial inliers, eg, you have some a priory knowledge, you do not want to use some default parameters.

NOTE: this is copy of last version PR #2371 (because I had problems with rebase and made some mistakes)

Checklist

@Borda Borda changed the title copy last version from PR #2371 add init params for Ellipse & Circle and RANSAC Dec 24, 2016
@codecov-io
Copy link

codecov-io commented Dec 24, 2016

Codecov Report

Merging #2415 into master will increase coverage by 4.66%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2415      +/-   ##
=========================================
+ Coverage   86.04%   90.7%   +4.66%     
=========================================
  Files         337     304      -33     
  Lines       27050   21536    -5514     
  Branches        0    1861    +1861     
=========================================
- Hits        23274   19534    -3740     
+ Misses       3776    1660    -2116     
- Partials        0     342     +342
Impacted Files Coverage Δ
skimage/measure/tests/test_fit.py 99.43% <100%> (-0.57%) ⬇️
skimage/measure/fit.py 81.88% <100%> (-14.58%) ⬇️
skimage/_shared/tests/test_interpolation.py 0% <0%> (-100%) ⬇️
skimage/_shared/tests/test_geometry.py 0% <0%> (-100%) ⬇️
skimage/_shared/tests/test_safe_as_int.py 0% <0%> (-100%) ⬇️
skimage/_shared/tests/test_version_requirements.py 0% <0%> (-95.66%) ⬇️
skimage/_shared/tests/test_testing.py 0% <0%> (-94.55%) ⬇️
skimage/_shared/tests/test_utils.py 0% <0%> (-90%) ⬇️
skimage/_shared/tests/__init__.py 0% <0%> (-60%) ⬇️
skimage/_shared/version_requirements.py 43.39% <0%> (-41.51%) ⬇️
... and 265 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5de268...43b1cbf. Read the comment docs.

N points with ``(x, y)`` coordinates, respectively.
init_params : tuple of 3 values, optional
(x_center, y_center, r) is initial guess of parameters.
If they are not specified initial guess use a circle model.
Copy link
Member

Choose a reason for hiding this comment

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

If None, use a circle with parameters based on mean values.

N points with ``(x, y)`` coordinates, respectively.
init_params : tuple of 5 values, optional
(x_center, y_center, a, b, theta) is initial guess of parameters.
If they are not specified initial guess use a circle model.
Copy link
Member

Choose a reason for hiding this comment

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

If None, use a circle with parameters based on mean values.

A[1, :] = -(y - yc) / d
# same for all iterations, so not changed in each iteration
#A[2, :] = -1
# A[2, :] = -1
Copy link
Member

Choose a reason for hiding this comment

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

Why this commented line?

Copy link
Contributor Author

@Borda Borda Dec 24, 2016

Choose a reason for hiding this comment

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

no clue, it was there already before... I will remove it.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Please rewrite the comment as

# A[2, :] = -1 is the same for all iterations, not re-affected.

xc0 = x.mean()
yc0 = y.mean()
r0 = dist(xc0, yc0).mean()
init_params = (xc0, yc0, r0)
Copy link
Member

Choose a reason for hiding this comment

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

Concatenate these 4 lines into a single one.

if not (0 < min_samples <= 1):
raise ValueError("`min_samples` as ration must be in range (0, 1)")
min_samples = int(min_samples * len(data))
if min_samples <= 0:
Copy link
Member

Choose a reason for hiding this comment

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

This is inconsistent with the docstring (zero included).

by `np.random`.
init_inliers : [list, tuple of] (N) array of bool or None, optional
Initial samples selection for model estimation
Copy link
Member

Choose a reason for hiding this comment

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

estimation.

@sciunto
Copy link
Member

sciunto commented Dec 24, 2016

Can you squash your commits and then edit the commit message to be explicit, ie add init params for Ellipse & Circle and RANSAC

@Borda Borda force-pushed the init_params_fit_models branch from f6f4105 to ed06419 Compare December 24, 2016 16:03
@Borda
Copy link
Contributor Author

Borda commented Dec 24, 2016

squash commits is nice feature I have not used before... :)

random_state = check_random_state(random_state)

if isinstance(min_samples, float):
if not (0 < min_samples <= 1):
Copy link
Member

Choose a reason for hiding this comment

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

0 <= min_samples <= 1

@sciunto
Copy link
Member

sciunto commented Dec 26, 2016

looks correct to me, but I'm not using this feature. Anyone to review this PR?

@Borda
Copy link
Contributor Author

Borda commented Dec 26, 2016

Does anyone have an idea why it fails with "The build has been terminated" even on my personal branch Borda / scikit-image it passes?

@soupault
Copy link
Member

@Borda I guess it just got overwhelmed :).

@Borda Borda force-pushed the init_params_fit_models branch from 674160e to 5c62f8e Compare December 29, 2016 17:57
@Borda
Copy link
Contributor Author

Borda commented Jan 2, 2017

@soupault @sciunto do you have anything else to this review?

@sciunto sciunto added this to the 0.14 milestone Jan 2, 2017
@ahojnnes
Copy link
Member

ahojnnes commented Jan 2, 2017

I have some concerns regarding this contribution:

  1. It is not straightforward what to do when there are a priori inliers in RANSAC. The chosen strategy is certainly not "optimal" and could simply be replaced by 2 or 3 lines of code manually, if it is really needed. I am against adding this feature.
  2. The documentation should motivate why init_params is useful (non-linear, iterative estimation). Currently, it is not clear what the purpose of the initialization is.

@Borda
Copy link
Contributor Author

Borda commented Jan 2, 2017

@ahojnnes regarding the 2) you are talking about description of init_params for RANSAC or also Circle? And do you mean adding just a short description or also an example?

@ahojnnes
Copy link
Member

ahojnnes commented Jan 3, 2017

@Borda I mean to extend the doc string for init_params with a short one sentence description why a good set of starting parameters is useful (for convergence...).

@Borda Borda changed the title add init params for Ellipse & Circle and RANSAC update RANSAC, ratio of inliers Jan 27, 2017
@Borda
Copy link
Contributor Author

Borda commented Jan 30, 2017

it seems it crashs on building doc for scikit-image/doc/source/api/skimage.filters.rank.rst

@sciunto
Copy link
Member

sciunto commented Jan 30, 2017

random failures due to travis. No worries.

@sciunto sciunto requested a review from ahojnnes January 30, 2017 19:36
@Borda Borda force-pushed the init_params_fit_models branch 6 times, most recently from 0fe32ff to cec7b4e Compare February 5, 2017 12:42
@Borda
Copy link
Contributor Author

Borda commented Aug 14, 2017

@sciunto @ahojnnes any update? :)

Copy link
Member

@stefanv stefanv left a comment

Choose a reason for hiding this comment

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

Looking at the diff, I am a bit confused how it implements the description from the PR?

However, these changes also seem fine to me, so no objection; just please update the commit message when merging the PR.

@@ -1,4 +1,5 @@
import numpy as np
from scipy import spatial
Copy link
Member

Choose a reason for hiding this comment

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

Why is spatial added here?

@Borda Borda force-pushed the init_params_fit_models branch from cec7b4e to 76da430 Compare August 17, 2017 02:30
@Borda
Copy link
Contributor Author

Borda commented Aug 17, 2017

@sciunto it seems that there are some errors which came with merge upstream/master

  • appveyor: Cython.Compiler.Errors.CompileError: C:\projects\scikit-image\skimage\measure_ccomp.pyx
  • shippable: ```
    if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source tools/travis_osx_install.sh ; fi
    ccache -s /root/102194d2-8a8b-4b47-9362-5695898aa651.sh: line 73: ccache: command not found
  • travis: The executable /usr/bin/python3.6 (from --python=/usr/bin/python3.6) does not exist

@Borda Borda force-pushed the init_params_fit_models branch from ee73666 to d8e16c8 Compare January 13, 2018 18:39
@soupault
Copy link
Member

I think it's time to let this PR go 😄 .
@Borda maybe try to select the related commits from the list in https://github.com/scikit-image/scikit-image/pull/2371/commits ? We could then make a rebase onto master and cherry pick them.

@Borda
Copy link
Contributor Author

Borda commented Jan 13, 2018

May I ask what happens with Travis CI, I am not able to build even the master...
https://travis-ci.org/Borda/scikit-image/builds/321960550

@soupault
Copy link
Member

soupault commented Jan 13, 2018

@Borda your master diverges from the upstream one:

/home/travis/.travis/job_stages: line 57: tools/travis/before_install.sh: No such file or directory

@Borda
Copy link
Contributor Author

Borda commented Jan 14, 2018

ok, this seems to be solved...
but there appears an issue with space in doctest such as (this is from travis)

381     >>> np.round(ellipse.params, 2)
Expected:
    array([ 10.  ,  15.  ,   4.  ,   8.  ,   0.52])
Got:
    array([10.  , 15.  ,  4.  ,  8.  ,  0.52])

@soupault
Copy link
Member

@Borda yet, that is known. See #2935

@Borda
Copy link
Contributor Author

Borda commented Jan 14, 2018

I see I was thinking about correcting these test with correcting the output and set # doctest: +NORMALIZE_WHITESPACE and do it as new PR from master... what do you think?

@Borda Borda mentioned this pull request Jan 14, 2018
@soupault
Copy link
Member

From what I understood, it is not just a matter of whitespaces - see https://github.com/numpy/numpy/blob/master/doc/release/1.14.0-notes.rst#many-changes-to-array-printing-disableable-with-the-new-legacy-printing-mode . Floating point precision could be different, bool ndarrays dtype is not printed anymore, etc.

@Borda
Copy link
Contributor Author

Borda commented Jan 15, 2018

yes, I noticed it also while I tried to solve it in #2938, but the difficulty comes with the configurations because in some configurations seems to be used the old formatting...

@Borda Borda force-pushed the init_params_fit_models branch from d8e16c8 to 217969b Compare January 28, 2018 05:50
# Conflicts:
#	.coveragerc
#	DEPENDS.txt
#	TASKS.txt
#	appveyor.yml
#	bento.info
#	doc/ext/sphinx_gallery/LICENSE
#	doc/ext/sphinx_gallery/README.txt
#	doc/ext/sphinx_gallery/__init__.py
#	doc/ext/sphinx_gallery/_static/broken_example.png
#	doc/ext/sphinx_gallery/_static/broken_stamp.svg
#	doc/ext/sphinx_gallery/_static/gallery.css
#	doc/ext/sphinx_gallery/_static/no_image.png
#	doc/ext/sphinx_gallery/backreferences.py
#	doc/ext/sphinx_gallery/docs_resolv.py
#	doc/ext/sphinx_gallery/downloads.py
#	doc/ext/sphinx_gallery/gen_gallery.py
#	doc/ext/sphinx_gallery/gen_rst.py
#	doc/ext/sphinx_gallery/notebook.py
#	doc/ext/sphinx_gallery/py_source_parser.py
#	optional_requirements.txt
#	skimage/io/_plugins/freeimage_plugin.ini
#	skimage/io/_plugins/freeimage_plugin.py
#	skimage/util/montage.py
#	tools/appveyor/install.ps1
#	tools/appveyor/run_with_env.cmd
@Borda Borda closed this Mar 22, 2018
@Borda
Copy link
Contributor Author

Borda commented Mar 22, 2018

It seems that I lost the commits... :-/

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants