ageron / ageron/handson-ml3

Multilabel Classification FutureWarning with KNeighborsClassifier.predict()

Open
#45 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
14.1k
Forks
5.3k
PR merge metrics
No merged PRs in 30d

Description

In the Multilabel Classification section, the following code generates a warning:

```python
knn_clf.predict([some_digit])
```

The warning is:

```
[c:\tools\Anaconda3\lib\site-packages\sklearn\neighbors\_classification.py:228](file:///C:/tools/Anaconda3/lib/site-packages/sklearn/neighbors/_classification.py:228): FutureWarning: Unlike other reduction functions (e.g. `skew`, `kurtosis`), the default behavior of `mode` typically preserves the axis it acts along. In SciPy 1.11.0, this behavior will change: the default value of `keepdims` will become False, the `axis` over which the statistic is taken will be eliminated, and the value None will no longer be accepted. Set `keepdims` to True or False to avoid this warning.
mode, _ = stats.mode(_y[neigh_ind, k], axis=1)
```

I verified I have the latest repo code.

**Versions:**
- OS: Windoows 11
- Python: 3.9.13
- Scikit-Learn: 1.0.2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.