dask / dask/dask-ml

Failure in `check_n_features_in_after_fitting` in `tests/test_kmeans.py::test_check_estimator`

Open
#1,010 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
951
Forks
262
PR merge metrics
No merged PRs in 30d

Description

This is currently failing

```
tests/test_kmeans.py::test_check_estimator FAILED

=================================================================================================================== FAILURES ====================================================================================================================
_____________________________________________________________________________________________________________ test_check_estimator ______________________________________________________________________________________________________________

def test_check_estimator():
with warnings.catch_warnings(record=True):
warnings.simplefilter("ignore", RuntimeWarning)
> check_estimator(DKKMeans())

tests/test_kmeans.py:28:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../.venv/lib/python3.12/site-packages/sklearn/utils/_param_validation.py:216: in wrapper
return func(*args, **kwargs)
../.venv/lib/python3.12/site-packages/sklearn/utils/estimator_checks.py:858: in check_estimator
check(estimator)
../.venv/lib/python3.12/site-packages/sklearn/utils/_testing.py:147: in wrapper
return fn(*args, **kwargs)
../.venv/lib/python3.12/site-packages/sklearn/utils/estimator_checks.py:4498: in check_n_features_in_after_fitting
with raises(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = , exc_type = None, exc_value = None, _ = None

def __exit__(self, exc_type, exc_value, _):
# see
# https://docs.python.org/2.5/whatsnew/pep-343.html#SECTION000910000000000000000

if exc_type is None: # No exception was raised in the block
if self.may_pass:
return True # CM is happy
else:
err_msg = self.err_msg or f"Did not raise: {self.expected_exc_types}"
> raise AssertionError(err_msg)
E AssertionError: `KMeans.predict()` does not check for consistency between input number
E of features with KMeans.fit(), via the `n_features_in_` attribute.
E You might want to use `sklearn.utils.validation.validate_data` instead
E of `check_array` in `KMeans.fit()` and KMeans.predict()`. This can be done
E like the following:
E from sklearn.utils.validation import validate_data
E ...
E class MyEstimator(BaseEstimator):
E ...
E def fit(self, X, y):
E X, y = validate_data(self, X, y, ...)
E ...
E return self
E ...
E def predict(self, X):
E X = validate_data(self, X, ..., reset=False)
E ...
E return X

../.venv/lib/python3.12/site-packages/sklearn/utils/_testing.py:1097: AssertionError

```

https://github.com/dask/dask-ml/pull/1008 is adding a skip for that particular check.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.