Skip to content

[MRG+1] Voting Classifier: predictions are float but np.bincount can only be used on integers#5802

Merged
glouppe merged 1 commit intoscikit-learn:masterfrom
alvarouc:master
Nov 15, 2015
Merged

[MRG+1] Voting Classifier: predictions are float but np.bincount can only be used on integers#5802
glouppe merged 1 commit intoscikit-learn:masterfrom
alvarouc:master

Conversation

@alvarouc
Copy link
Copy Markdown
Contributor

This fix downcasts manually the array of predictions to integers so that np.bincount does not trigger an error

@glouppe
Copy link
Copy Markdown
Contributor

glouppe commented Nov 13, 2015

Looks good to me. +1

Can you confirm @rasbt ?

@glouppe glouppe changed the title Voting Classifier: predictions are float but np.bincount can only be used on integers [MRG+1] Voting Classifier: predictions are float but np.bincount can only be used on integers Nov 13, 2015
@rasbt
Copy link
Copy Markdown
Contributor

rasbt commented Nov 13, 2015

Certainly doesn't hurt in case someone uses float arrays to store class labels. That's actually a good idea, thanks for the fix!

I remember the "type in -- type out" discussion ;)

lr = LogisticRegression() 
>>> lr.fit(np.array([[1.0], [2.9]]), [1, 2]).predict([[1.0], [2.9]]).dtype
dtype('int64')

>>> lr.fit(np.array([[1.0], [2.9]]), [1.0, 2.0]).predict([[1.0], [2.9]]).dtype
dtype('float64')

@glouppe
Copy link
Copy Markdown
Contributor

glouppe commented Nov 13, 2015

I remember the "type in -- type out" discussion ;)

True, except that the classifiers are internally trained on the LabelEncoded outputs, so it should still spit the same format, even with this fix.

@glouppe
Copy link
Copy Markdown
Contributor

glouppe commented Nov 15, 2015

Thanks for the fix @alvarouc. I am merging since @rasbt seems OK with this as well.

glouppe added a commit that referenced this pull request Nov 15, 2015
[MRG+1] Voting Classifier: predictions are float but np.bincount can only be used on integers
@glouppe glouppe merged commit a20b0eb into scikit-learn:master Nov 15, 2015
@amueller
Copy link
Copy Markdown
Member

no regression test? :-/

@rasbt
Copy link
Copy Markdown
Contributor

rasbt commented Jan 24, 2016

@amueller you mean that we should raise an exception if someone tries to seed it with an estimator for regression?

@Sandy4321
Copy link
Copy Markdown

do you have full code example how it works

On Sun, Jan 24, 2016 at 1:37 PM, Sebastian Raschka <notifications@github.com

wrote:

@amueller https://github.com/amueller you mean that we should raise an
exception if someone tries to seed it with an estimator for regression?


Reply to this email directly or view it on GitHub
#5802 (comment)
.

@rasbt
Copy link
Copy Markdown
Contributor

rasbt commented Jan 24, 2016

@Sandy4321

do you have full code example how it works

What do you mean, exactly? A code example for raising the exception?

@Sandy4321
Copy link
Copy Markdown

code example for Voting Classifier

On Sun, Jan 24, 2016 at 1:50 PM, Sebastian Raschka <notifications@github.com

wrote:

@Sandy4321 https://github.com/Sandy4321

do you have full code example how it works

What do you mean, exactly? A code example for raising the exception?


Reply to this email directly or view it on GitHub
#5802 (comment)
.

@rasbt
Copy link
Copy Markdown
Contributor

rasbt commented Jan 24, 2016

@Sandy4321 there are plenty of examples in the documentation at http://scikit-learn.org/stable/modules/ensemble.html#voting-classifier (or also see the respective unit tests)

@jnothman
Copy link
Copy Markdown
Member

(As well as the regression test), I think this needs a what's new entry.

glemaitre added a commit to glemaitre/scikit-learn that referenced this pull request Jun 8, 2017
raghavrv pushed a commit that referenced this pull request Jun 10, 2017
…9063)

* FIX/TST revert #5802 and raise error for faulty classifier

* FIX check_estimator take care of the rest
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 2017
… classifier (scikit-learn#9063)

* FIX/TST revert scikit-learn#5802 and raise error for faulty classifier

* FIX check_estimator take care of the rest
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
… classifier (scikit-learn#9063)

* FIX/TST revert scikit-learn#5802 and raise error for faulty classifier

* FIX check_estimator take care of the rest
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
… classifier (scikit-learn#9063)

* FIX/TST revert scikit-learn#5802 and raise error for faulty classifier

* FIX check_estimator take care of the rest
NelleV pushed a commit to NelleV/scikit-learn that referenced this pull request Aug 11, 2017
… classifier (scikit-learn#9063)

* FIX/TST revert scikit-learn#5802 and raise error for faulty classifier

* FIX check_estimator take care of the rest
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
… classifier (scikit-learn#9063)

* FIX/TST revert scikit-learn#5802 and raise error for faulty classifier

* FIX check_estimator take care of the rest
AishwaryaRK pushed a commit to AishwaryaRK/scikit-learn that referenced this pull request Aug 29, 2017
… classifier (scikit-learn#9063)

* FIX/TST revert scikit-learn#5802 and raise error for faulty classifier

* FIX check_estimator take care of the rest
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
… classifier (scikit-learn#9063)

* FIX/TST revert scikit-learn#5802 and raise error for faulty classifier

* FIX check_estimator take care of the rest
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
… classifier (scikit-learn#9063)

* FIX/TST revert scikit-learn#5802 and raise error for faulty classifier

* FIX check_estimator take care of the rest
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.

6 participants