Skip to content
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

fix two warnings from sklearn #327

Merged
merged 2 commits into from
Sep 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python-package/rgf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ def fit(self, X, y, sample_weight=None):
raise ValueError("Classifier can't predict when only one class is present.")

self._fitted = True
self.n_features_in_ = self._n_features
Copy link
Member Author

Choose a reason for hiding this comment

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

Why not property: because now scikit-learn is checking only attributes with trailing underscore, not properties microsoft/LightGBM#3014 (comment)


return self

Expand Down Expand Up @@ -663,6 +664,7 @@ def fit(self, X, y, sample_weight=None):
self._fit_regression_task(X, y, sample_weight, params)

self._fitted = True
self.n_features_in_ = self._n_features

return self

Expand Down
6 changes: 3 additions & 3 deletions python-package/tests/test_rgf_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class EstimatorBaseTest(object):
def test_sklearn_integration(self):
check_estimator(self.estimator_class)
check_estimator(self.estimator_class())

def test_input_arrays_shape(self):
est = self.estimator_class(**self.kwargs)
Expand Down Expand Up @@ -489,7 +489,7 @@ def test_attributes(self):
def test_sklearn_integration(self):
# TODO(fukatani): FastRGF bug?
# FastRGF doesn't work if the number of sample is too small.
# check_estimator(self.estimator_class)
# check_estimator(self.estimator_class())
pass


Expand Down Expand Up @@ -541,5 +541,5 @@ def test_parallel_gridsearch(self):
def test_sklearn_integration(self):
# TODO(fukatani): FastRGF bug?
# FastRGF doesn't work if the number of sample is too small.
# check_estimator(self.estimator_class)
# check_estimator(self.estimator_class())
pass