[MRG+2] FIX DummyEstimator and a single output 2d input list/array#13545
Merged
NicolasHug merged 15 commits intoscikit-learn:masterfrom Apr 5, 2019
Merged
[MRG+2] FIX DummyEstimator and a single output 2d input list/array#13545NicolasHug merged 15 commits intoscikit-learn:masterfrom
NicolasHug merged 15 commits intoscikit-learn:masterfrom
Conversation
jnothman
reviewed
Mar 31, 2019
Member
jnothman
left a comment
There was a problem hiding this comment.
Is this the behaviour of other multioutput estimatiors?
Needs a what's new.
Member
Author
|
@jnothman borrowing your gist: import warnings
import sklearn
warnings.simplefilter('ignore')
from sklearn import *
X = [[0], [0], [0], [0], [0]]
y_1d = [1, 2, 1, 1, 1]
y = [[1], [2], [1], [1], [1]]
for clf in [tree.DecisionTreeClassifier(),
neighbors.KNeighborsClassifier(),
neural_network.MLPClassifier(),
multioutput.MultiOutputClassifier(linear_model.LogisticRegression()),
multiclass.OneVsRestClassifier(linear_model.LogisticRegression()),
dummy.DummyClassifier(),
]:
try:
clf.fit(X, y)
for method in ['predict', 'decision_function', 'predict_proba']:
if not hasattr(clf, method):
continue
s = getattr(clf, method)(X[-3:])
if hasattr(s, 'shape'):
print(type(clf).__name__, method, s.shape)
else:
print(type(clf).__name__, method, [x.shape for x in s])
except Exception as e:
print(type(clf).__name__, e)The output: |
jnothman
reviewed
Apr 2, 2019
doc/whats_new/v0.21.rst
Outdated
| float64 for the ``stratified`` strategy. :issue:`13266` by | ||
| :user:`Christos Aridas<chkoar>`. | ||
|
|
||
| - |Fix| Fixed a bug in :class:`dummy.DummyClassifier` where 1d dimensional y |
Member
There was a problem hiding this comment.
"1d dimensional y with ndim=2" makes no sense to me. Do you mean "column vector"?
Member
Author
There was a problem hiding this comment.
Yep, it was a copy paste from the old issue, sorry. Fixed.
jnothman
approved these changes
Apr 2, 2019
NicolasHug
reviewed
Apr 5, 2019
Co-Authored-By: adrinjalali <adrin.jalali@gmail.com>
Member
|
Thanks @adrinjalali ! |
jeremiedbb
pushed a commit
to jeremiedbb/scikit-learn
that referenced
this pull request
Apr 25, 2019
* Add column_or_1d to account for dataframe y * Add test * make the diff cleaner * switched pandas import for 2d array * change test to a simple comparison between 1d and 2d y * flake8 errors in tests * Add warning to acieve consistent behaviour as in other classifiers * Update whats new file * remove redundant code, fix regression * remove unnecessary import * add comment on test * address comments * fix what's new entry * Update doc/whats_new/v0.21.rst Co-Authored-By: adrinjalali <adrin.jalali@gmail.com>
xhluca
pushed a commit
to xhluca/scikit-learn
that referenced
this pull request
Apr 28, 2019
* Add column_or_1d to account for dataframe y * Add test * make the diff cleaner * switched pandas import for 2d array * change test to a simple comparison between 1d and 2d y * flake8 errors in tests * Add warning to acieve consistent behaviour as in other classifiers * Update whats new file * remove redundant code, fix regression * remove unnecessary import * add comment on test * address comments * fix what's new entry * Update doc/whats_new/v0.21.rst Co-Authored-By: adrinjalali <adrin.jalali@gmail.com>
koenvandevelde
pushed a commit
to koenvandevelde/scikit-learn
that referenced
this pull request
Jul 12, 2019
* Add column_or_1d to account for dataframe y * Add test * make the diff cleaner * switched pandas import for 2d array * change test to a simple comparison between 1d and 2d y * flake8 errors in tests * Add warning to acieve consistent behaviour as in other classifiers * Update whats new file * remove redundant code, fix regression * remove unnecessary import * add comment on test * address comments * fix what's new entry * Update doc/whats_new/v0.21.rst Co-Authored-By: adrinjalali <adrin.jalali@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10786, closes #10926
Assumes the
yis 1d if there's only one column to it.