Skip to content

FIX silence warning in IterativeImputer when constant feature in data#14234

Merged
thomasjpfan merged 1 commit intoscikit-learn:masterfrom
glemaitre:is/runtimewarning
Jul 2, 2019
Merged

FIX silence warning in IterativeImputer when constant feature in data#14234
thomasjpfan merged 1 commit intoscikit-learn:masterfrom
glemaitre:is/runtimewarning

Conversation

@glemaitre
Copy link
Copy Markdown
Member

Follow-up on #14148

If a feature is constant, a true_divide RuntimeWarning is raised. This PR silent it.

ping @jnothman @sergeyf @adrinjalali

@glemaitre
Copy link
Copy Markdown
Member Author

@rth as well ;)

Copy link
Copy Markdown
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

I can't think of a better solution, except perhaps to find constant columns (e.g. with np.ptp) and handle them specially.

@jnothman jnothman added this to the 0.21.3 milestone Jul 2, 2019
@jnothman jnothman changed the title FIX silent warning in IterativeImputer when constant feature in data FIX silence warning in IterativeImputer when constant feature in data Jul 2, 2019
@glemaitre
Copy link
Copy Markdown
Member Author

Actually, the case of std. dev. equal to 0 was already covered in the code: https://github.com/scikit-learn/scikit-learn/pull/14234/files#diff-159cd18cad859590dab36b15d3e5c2baR438

The only thing missing was to catch the warning

Copy link
Copy Markdown
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasjpfan thomasjpfan merged commit de30404 into scikit-learn:master Jul 2, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
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.

4 participants