-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] Resolve the problem with cross_val_predict(method=) when passing X or y as list #9600
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
Conversation
Please make the title more descriptive, and the reference issue should be prefixed by "Fixes" |
@@ -732,7 +732,7 @@ def _fit_and_predict(estimator, X, y, train, test, verbose, fit_params, | |||
predictions = func(X_test) | |||
if method in ['decision_function', 'predict_proba', 'predict_log_proba']: | |||
n_classes = len(set(y)) | |||
predictions_ = np.zeros((X_test.shape[0], n_classes)) | |||
predictions_ = np.zeros((((X_test.shape[0]) if type(X_test) is np.ndarray else (_num_samples(X_test))), n_classes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should be able to use _num_samples in all cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true...
@@ -808,6 +808,10 @@ def test_cross_val_predict_input_types(): | |||
clf = CheckingClassifier(check_y=list_check) | |||
predictions = cross_val_predict(clf, X, y.tolist()) | |||
|
|||
#test with X and y as list and non empty method | |||
predictions = cross_val_predict(LogisticRegression(), X.tolist(), y.tolist(), method='decision_function') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep line length under 80 chars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
@@ -808,6 +808,12 @@ def test_cross_val_predict_input_types(): | |||
clf = CheckingClassifier(check_y=list_check) | |||
predictions = cross_val_predict(clf, X, y.tolist()) | |||
|
|||
#test with X and y as list and non empty method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8: space after #
@@ -808,6 +808,12 @@ def test_cross_val_predict_input_types(): | |||
clf = CheckingClassifier(check_y=list_check) | |||
predictions = cross_val_predict(clf, X, y.tolist()) | |||
|
|||
#test with X and y as list and non empty method | |||
predictions = cross_val_predict(LogisticRegression(), X.tolist(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8 indentation, please; preferably:
predictions = cross_val_predict(LogisticRegression(), X.tolist(),
y.tolist(), method='decision_function')
LGTM, thanks! |
Thanks @CoderINusE ! |
…ing X or y as list (scikit-learn#9600) * issue 9592 * issue resolve * resolve issue * review * Delete sample.py * review
…ing X or y as list (scikit-learn#9600) * issue 9592 * issue resolve * resolve issue * review * Delete sample.py * review
…ing X or y as list (scikit-learn#9600) * issue 9592 * issue resolve * resolve issue * review * Delete sample.py * review
…ing X or y as list (scikit-learn#9600) * issue 9592 * issue resolve * resolve issue * review * Delete sample.py * review
Reference Issue
Fixes: #9592