-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+2] DOC adding separate fit()
methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressor
#7824
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
sample_weight=sample_weight, | ||
check_input=check_input, | ||
X_idx_sorted=X_idx_sorted) | ||
|
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.
The tests are failing because self
is not returned here and also for DecisionTreeRegressor
. I suppose you missed to return self
in here. Also since the tests are failing, I think it might be good to run flake8 / pep8
checker so that code is pep compliant.
@maniteja123 Thank you for pointing that out. My bad. Also, I ran the pep8 test, but it was showing a few errors mostly on lines that I had not changed, like 'E501 line too long (83 > 79 characters)'. So, for the time being I felt it's better left untouched. However, let me know if you intend to have a discussion on that. |
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.
The point of having a separate fit method is to avoid generic docstrings and have specific ones for regression / classification. Both the docstrings seem identical. Kindly make it more specific...
@@ -731,6 +731,53 @@ def __init__(self, | |||
min_impurity_split=min_impurity_split, | |||
presort=presort) | |||
|
|||
def fit(self, X, y, sample_weight=None, check_input=True, | |||
X_idx_sorted=None): | |||
"""Build a decision tree classifier from the training set (X, y). |
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.
Incorrect indentation?
They should be aligned like
def fit(self, X, y, ...
X_idx_sorted):
"""Build ...
Parameters...
"""
""" | ||
|
||
super(DecisionTreeRegressor,self).fit( | ||
X=X, |
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.
X, y, ...
fit()
methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressor
fit()
methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressorfit()
methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressor
@raghavrv I modified the generic docstrings for 'y' and 'sample_weight' to a more specific one. Please let me know if I there is any more issue. |
@maniteja123 Actually, in my code editor, I used tabs and that messed up everything. |
""" | ||
|
||
super(DecisionTreeClassifier,self).fit( | ||
X, y, sample_weight, check_input, X_idx_sorted) |
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.
Sorry if you misconstrued... I meant X and y alone without the keywords and the rest with keywords
X, y,
sampl...=sampl...
@raghavrv No problem! |
@raghavrv Please let me know if there is any more issues. |
fit()
methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressorfit()
methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressor
@amueller 2nd look? |
@jnothman Would you have time for a quick review of this + Merge |
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.
Should we be removing the docstring from BaseDecisionTree.fit
? Otherwise LGTM.
to a sparse ``csc_matrix``. | ||
|
||
y : array-like, shape = [n_samples] or [n_samples, n_outputs] | ||
The target values (class labels). |
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.
might as well specify "as integers or strings"
I feel we shouldn't remove the docstring from BaseDecisionTree.fit. As a user using it for the 1st time, it would be helpful to understand how it generalizes to both regressor and classifier. Please let me know what you think. |
Indeed, but |
Yes that's true. I'll make the change then. |
I'd like someone else to give their opinion on removing docs from the base class. |
fit()
methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressorfit()
methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressor
LGTM |
…sionTreeClassifier and DecisionTreeRegressor (scikit-learn#7824) * DOC adding separate fit() functions * DOC adding keywords to arguments of super() * DOC removing trailing whitespaces * DOC specifying the type of class labels * DOC removing docstring from BaseDecisionTree.fit
…sionTreeClassifier and DecisionTreeRegressor (scikit-learn#7824) * DOC adding separate fit() functions * DOC adding keywords to arguments of super() * DOC removing trailing whitespaces * DOC specifying the type of class labels * DOC removing docstring from BaseDecisionTree.fit
…sionTreeClassifier and DecisionTreeRegressor (scikit-learn#7824) * DOC adding separate fit() functions * DOC adding keywords to arguments of super() * DOC removing trailing whitespaces * DOC specifying the type of class labels * DOC removing docstring from BaseDecisionTree.fit
* tag '0.18.1': (144 commits) skip tree-test on 32bit do the warning test as we do it in other places. Replase assert_equal by assert_almost_equal in cosine test version bump 0.18.1 fix merge conflict mess in whatsnew add the python2.6 warning to 0.18.1 fix learning_curve test that I messed up in cherry-picking the "reentrant cv" PR. sync whatsnew with master [MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (scikit-learn#7553) FIX scikit-learn#6420: Cloning decision tree estimators breaks criterion objects (scikit-learn#7680) Add whats new entry for scikit-learn#6282 (scikit-learn#7629) [MGR + 2] fix selectFdr bug (scikit-learn#7490) fixed whatsnew cherry-pick mess (somewhat) [MRG + 2] FIX LogisticRegressionCV to correctly handle string labels (scikit-learn#5874) [MRG + 2] Fixed parameter setting in SelectFromModel (scikit-learn#7764) [MRG+2] DOC adding separate `fit()` methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressor (scikit-learn#7824) Fix docstring typo (scikit-learn#7844) n_features --> n_components [MRG + 1] DOC adding :user: role to whats_new (scikit-learn#7818) [MRG+1] label binarizer not used consistently in CalibratedClassifierCV (scikit-learn#7799) DOC : fix docstring of AIC/BIC in GMM ...
* releases: (144 commits) skip tree-test on 32bit do the warning test as we do it in other places. Replase assert_equal by assert_almost_equal in cosine test version bump 0.18.1 fix merge conflict mess in whatsnew add the python2.6 warning to 0.18.1 fix learning_curve test that I messed up in cherry-picking the "reentrant cv" PR. sync whatsnew with master [MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (scikit-learn#7553) FIX scikit-learn#6420: Cloning decision tree estimators breaks criterion objects (scikit-learn#7680) Add whats new entry for scikit-learn#6282 (scikit-learn#7629) [MGR + 2] fix selectFdr bug (scikit-learn#7490) fixed whatsnew cherry-pick mess (somewhat) [MRG + 2] FIX LogisticRegressionCV to correctly handle string labels (scikit-learn#5874) [MRG + 2] Fixed parameter setting in SelectFromModel (scikit-learn#7764) [MRG+2] DOC adding separate `fit()` methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressor (scikit-learn#7824) Fix docstring typo (scikit-learn#7844) n_features --> n_components [MRG + 1] DOC adding :user: role to whats_new (scikit-learn#7818) [MRG+1] label binarizer not used consistently in CalibratedClassifierCV (scikit-learn#7799) DOC : fix docstring of AIC/BIC in GMM ... Conflicts: removed sklearn/externals/joblib/__init__.py sklearn/externals/joblib/_parallel_backends.py sklearn/externals/joblib/testing.py
* dfsg: (144 commits) skip tree-test on 32bit do the warning test as we do it in other places. Replase assert_equal by assert_almost_equal in cosine test version bump 0.18.1 fix merge conflict mess in whatsnew add the python2.6 warning to 0.18.1 fix learning_curve test that I messed up in cherry-picking the "reentrant cv" PR. sync whatsnew with master [MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (scikit-learn#7553) FIX scikit-learn#6420: Cloning decision tree estimators breaks criterion objects (scikit-learn#7680) Add whats new entry for scikit-learn#6282 (scikit-learn#7629) [MGR + 2] fix selectFdr bug (scikit-learn#7490) fixed whatsnew cherry-pick mess (somewhat) [MRG + 2] FIX LogisticRegressionCV to correctly handle string labels (scikit-learn#5874) [MRG + 2] Fixed parameter setting in SelectFromModel (scikit-learn#7764) [MRG+2] DOC adding separate `fit()` methods (and docstrings) for DecisionTreeClassifier and DecisionTreeRegressor (scikit-learn#7824) Fix docstring typo (scikit-learn#7844) n_features --> n_components [MRG + 1] DOC adding :user: role to whats_new (scikit-learn#7818) [MRG+1] label binarizer not used consistently in CalibratedClassifierCV (scikit-learn#7799) DOC : fix docstring of AIC/BIC in GMM ...
…sionTreeClassifier and DecisionTreeRegressor (scikit-learn#7824) * DOC adding separate fit() functions * DOC adding keywords to arguments of super() * DOC removing trailing whitespaces * DOC specifying the type of class labels * DOC removing docstring from BaseDecisionTree.fit
…sionTreeClassifier and DecisionTreeRegressor (scikit-learn#7824) * DOC adding separate fit() functions * DOC adding keywords to arguments of super() * DOC removing trailing whitespaces * DOC specifying the type of class labels * DOC removing docstring from BaseDecisionTree.fit
…sionTreeClassifier and DecisionTreeRegressor (scikit-learn#7824) * DOC adding separate fit() functions * DOC adding keywords to arguments of super() * DOC removing trailing whitespaces * DOC specifying the type of class labels * DOC removing docstring from BaseDecisionTree.fit
Reference Issue
Fixes #7809
What does this implement/fix? Explain your changes.
Added a separate fit function for DecisionTreeRegressor and DecisionTreeClassifier that calls super to have separate docstrings for both.