Talip7/scikit-learn-issues-multilabel huggingface dataset:
Weighted MAPE behaviour on 0

### Describe the workflow you want to enable

Hello,

I create this ticket because I realized unexpected behaviour for Weighted MAPE when you weight for the real values and those values are 0.

By the formula:

<img width="217" height="73" alt="Image" src="https://github.com/user-attachments/assets/2e874378-3674-4861-9e4f-91866c7d23bd" />

In the case the weights are the same as the a_i, the values should cancel out (even at 0 because the limit is well defined and can be extended to 0) and coincide with this:

<img width="202" height="62" alt="Image" src="https://github.com/user-attachments/assets/0c6ac99d-d69f-4326-90c3-b97dd709e966" /> (1)

Looking at the current implementation:

https://github.com/scikit-learn/scikit-learn/blob/c60dae2060/sklearn/metrics/_regression.py#L408

what happens with zeros is that they are removed from the computation.


I understand this needs to be like this to allow for generic weights, that are not the real values, but this is creating an unexpected behaviour.
Maybe there should be another class that implements directly (1), to avoid problems with it.

Best,

Arnau

### Describe your proposed solution

I wold suggest create another classe wape that directly calculates:
sum(|y_pred- y|)/sum(|y|)
To avoid this unexpected behaviour.

### Describe alternatives you've considered, if relevant

I don't think changing the current class would be a good option since it is implemented in the only way that can allow for generic weights.

### Additional context

_No response_

COMMENT:
Thank you, @virchan,

So just to confirm — your suggestion is that anyone needing to compute WAPE as defined above should implement their own version, rather than relying on mean_absolute_percentage_error?

I still believe that many users will expect to obtain WAPE that way and may encounter the same confusion I described (I’ve already seen this happen several times in my team). But if the extra maintenance cost outweighs the benefit, I completely understand.

Thanks again for the clear explanation and for taking the time to discuss this.

Best,
Arnau

Labels: module:metrics
DOC all random seeds commit message

### Describe the issue linked to the documentation

I wanted to reference the [all random seeds] commit message in the developer guide, which is very useful when contributing a test depending on `global_random_seed`, but it isn't documented in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers ?

### Suggest a potential alternative/fix

Add the [all random seeds] commit message to the table in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers and an example test using `global_random_seed` (python snippet) in https://scikit-learn.org/dev/computing/parallelism.html#sklearn-tests-global-random-seed

COMMENT:
Hi! I'd like to work on this issue. 
 
   Could you confirm this is still available and provide any guidance 
   on how [all random seeds] works in your CI? Also i would like to be assigned to it if nobody is

Labels: Documentation
DOC all random seeds commit message

### Describe the issue linked to the documentation

I wanted to reference the [all random seeds] commit message in the developer guide, which is very useful when contributing a test depending on `global_random_seed`, but it isn't documented in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers ?

### Suggest a potential alternative/fix

Add the [all random seeds] commit message to the table in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers and an example test using `global_random_seed` (python snippet) in https://scikit-learn.org/dev/computing/parallelism.html#sklearn-tests-global-random-seed

COMMENT:
Sure ! If you have a parametrized `test_foo(param, global_random_seed)`, to trigger the CI with all random seeds, one uses the commit message marker [all random seeds] followed by the test in question:
```shell
my commit message [all random seeds]
test_foo
```
To [test locally with all random seeds](https://scikit-learn.org/dev/computing/parallelism.html#sklearn-tests-global-random-seed), one would do:
```shell
SKLEARN_TESTS_GLOBAL_RANDOM_SEED="all" pytest -v -k test_foo
```

Labels: Documentation
DOC all random seeds commit message

### Describe the issue linked to the documentation

I wanted to reference the [all random seeds] commit message in the developer guide, which is very useful when contributing a test depending on `global_random_seed`, but it isn't documented in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers ?

### Suggest a potential alternative/fix

Add the [all random seeds] commit message to the table in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers and an example test using `global_random_seed` (python snippet) in https://scikit-learn.org/dev/computing/parallelism.html#sklearn-tests-global-random-seed

COMMENT:
Ill proceed with the issue

Labels: Documentation
DOC all random seeds commit message

### Describe the issue linked to the documentation

I wanted to reference the [all random seeds] commit message in the developer guide, which is very useful when contributing a test depending on `global_random_seed`, but it isn't documented in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers ?

### Suggest a potential alternative/fix

Add the [all random seeds] commit message to the table in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers and an example test using `global_random_seed` (python snippet) in https://scikit-learn.org/dev/computing/parallelism.html#sklearn-tests-global-random-seed

COMMENT:
If I had to point someone to the `[all random seeds]` commit message, I would link to https://github.com/scikit-learn/scikit-learn/issues/28959.

This is completely debatable, but it's the kind of things where I am fine having the info findable in the github issue tracker rather than having it in the doc.

Maybe a reasonable compromise would be to say that the commit marker exists in the doc and point to the github issue for the commit message format?

Labels: Documentation
DOC all random seeds commit message

### Describe the issue linked to the documentation

I wanted to reference the [all random seeds] commit message in the developer guide, which is very useful when contributing a test depending on `global_random_seed`, but it isn't documented in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers ?

### Suggest a potential alternative/fix

Add the [all random seeds] commit message to the table in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers and an example test using `global_random_seed` (python snippet) in https://scikit-learn.org/dev/computing/parallelism.html#sklearn-tests-global-random-seed

COMMENT:
I was just wondering what the message was to check all random seeds and wondering if it was documented some where. I did not know about https://github.com/scikit-learn/scikit-learn/issues/28959.

I would be happy with something in the contributing docs, even if it just pointed to https://github.com/scikit-learn/scikit-learn/issues/28959

So I'm +1 for adding something to the docs

Labels: Documentation
DOC all random seeds commit message

### Describe the issue linked to the documentation

I wanted to reference the [all random seeds] commit message in the developer guide, which is very useful when contributing a test depending on `global_random_seed`, but it isn't documented in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers ?

### Suggest a potential alternative/fix

Add the [all random seeds] commit message to the table in https://scikit-learn.org/dev/developers/contributing.html#commit-message-markers and an example test using `global_random_seed` (python snippet) in https://scikit-learn.org/dev/computing/parallelism.html#sklearn-tests-global-random-seed

COMMENT:
closed by #32595

Labels: Documentation
Add a changelog entry about free-theaded support in scikit-learn 1.8

To say that free-threaded is officially supported and Python 3.14 is probably better if you want to experiment with it.

I guess something similar to https://scikit-learn.org/stable/whats_new/v1.6.html#free-threaded-cpython-3-13-support

COMMENT:
We could make it explicit that scikit-learn 1.8 has now marked all its native extensions as [free-threading compatible](https://cython.readthedocs.io/en/latest/src/userguide/freethreading.html#status): importing them will therefore no longer cause the CPython interpreter to re-enable the GIL on a free-threading build.

Furthermore, we have set up dedicated continuous integration configuration to stress-test scikit-learn components with multiple concurrent threads using [`pytest-run-parallel`](https://github.com/Quansight-Labs/pytest-run-parallel). This testing campaign discovered a few thread-safety problems that are now either fixed or tracked with dedicated open issues in the issue tracker.

Labels: Documentation
Add a changelog entry about free-theaded support in scikit-learn 1.8

To say that free-threaded is officially supported and Python 3.14 is probably better if you want to experiment with it.

I guess something similar to https://scikit-learn.org/stable/whats_new/v1.6.html#free-threaded-cpython-3-13-support

COMMENT:
Hi, I would like to work on this issue.

Labels: Documentation
Add a changelog entry about free-theaded support in scikit-learn 1.8

To say that free-threaded is officially supported and Python 3.14 is probably better if you want to experiment with it.

I guess something similar to https://scikit-learn.org/stable/whats_new/v1.6.html#free-threaded-cpython-3-13-support

COMMENT:
@ogrisel  below I have created the PR for the same can you pls review it.
https://github.com/scikit-learn/scikit-learn/pull/32534

Labels: Documentation
Add a changelog entry about free-theaded support in scikit-learn 1.8

To say that free-threaded is officially supported and Python 3.14 is probably better if you want to experiment with it.

I guess something similar to https://scikit-learn.org/stable/whats_new/v1.6.html#free-threaded-cpython-3-13-support

COMMENT:
@ritikverma2000 I had already opened #32528 so I closed your PR with a comment pointing to our contributing guide.

Labels: Documentation
DOC Add documentation on how to disable the DevContainer popups in VSCode

One for @DeaMariaLeon [^1] when you manage to figure out how to remove these annoying popups

[^1]: oops pinged the wrong Dea originally 😅 ...

There seems to be two related popups:
- install Dev Containers extension (I probably had it installed already which is why I was not exactly seeing the same thing as @DeaMariaLeon)
- once you have the DevContainers installed: do you want to run inside the devcontainer. This was the popup from my comment https://github.com/scikit-learn/scikit-learn/pull/31096#issuecomment-3350817895. 

Discussed in https://github.com/scikit-learn/scikit-learn/issues/32342#issuecomment-3397290793
            
`containers.showRemoteWorkspaceWarning` settings is supposed to fix it but maybe not completely according to https://github.com/scikit-learn/scikit-learn/pull/32342#issuecomment-3397763595? Anyway this needs more investigation ...

COMMENT:
~~Two things:~~

**1.** Regarding

> Anyway this needs more investigation ...

 When `devcontainers` is not installed the popup message is: "_Do you want to install the recommended Dev Containers  extension from Microsoft for this repository?"_  Inside the popup window, there is a settings icon where one can select _"Don't Show Again for this Repository"._ 
I think that this setting icon wasn't shown before. Maybe it's available only after I set the `containers.showRemoteWorkspaceWarning` setting. I'm not sure. 
My take is that I can't be too specific on the instructions. People can comment once I write something. It's just FYI of what I see now. 

~~**2.** Did you mean that a note should be added to the section in #32474? (once is merged?)~~

Edit: Crossed-out second question as the PR mentioned may need more time.

Labels: Documentation
DOC Add documentation on how to disable the DevContainer popups in VSCode

One for @DeaMariaLeon [^1] when you manage to figure out how to remove these annoying popups

[^1]: oops pinged the wrong Dea originally 😅 ...

There seems to be two related popups:
- install Dev Containers extension (I probably had it installed already which is why I was not exactly seeing the same thing as @DeaMariaLeon)
- once you have the DevContainers installed: do you want to run inside the devcontainer. This was the popup from my comment https://github.com/scikit-learn/scikit-learn/pull/31096#issuecomment-3350817895. 

Discussed in https://github.com/scikit-learn/scikit-learn/issues/32342#issuecomment-3397290793
            
`containers.showRemoteWorkspaceWarning` settings is supposed to fix it but maybe not completely according to https://github.com/scikit-learn/scikit-learn/pull/32342#issuecomment-3397763595? Anyway this needs more investigation ...

COMMENT:
So using the "Don't Show Again for this Repository" I mentioned above seems to stop the pop-up message for good.

Labels: Documentation
DOC Add documentation on how to disable the DevContainer popups in VSCode

One for @DeaMariaLeon [^1] when you manage to figure out how to remove these annoying popups

[^1]: oops pinged the wrong Dea originally 😅 ...

There seems to be two related popups:
- install Dev Containers extension (I probably had it installed already which is why I was not exactly seeing the same thing as @DeaMariaLeon)
- once you have the DevContainers installed: do you want to run inside the devcontainer. This was the popup from my comment https://github.com/scikit-learn/scikit-learn/pull/31096#issuecomment-3350817895. 

Discussed in https://github.com/scikit-learn/scikit-learn/issues/32342#issuecomment-3397290793
            
`containers.showRemoteWorkspaceWarning` settings is supposed to fix it but maybe not completely according to https://github.com/scikit-learn/scikit-learn/pull/32342#issuecomment-3397763595? Anyway this needs more investigation ...

COMMENT:
Thanks a lot, below is the result of a quick investigation on VSCode, which matches yours

I uninstalled every extension that seemed related to Docker, DevContainers, container before I started to make sure I was starting from a clean state ...

### First popup about installing "Dev Containers" extension

<img width="555" height="130" alt="Image" src="https://github.com/user-attachments/assets/7399d760-f2e5-4a0f-b789-70f32b9688cd" />

Closing the popup with the cross icon => the popup shows again on the next VSCode restart

Clicking the wheel in the popup you can do "Do not show again for this repository" which seems to work after a VSCode. This matches @DeaMariaLeon's report.

Side-comment: show recommendations is not very helpful (just goes to the doc of the extension, does not really show recommendations ...)

### Second popup if you have Dev Containers extension installed

<img width="550" height="145" alt="Image" src="https://github.com/user-attachments/assets/6e6d9b28-e606-4f0a-aaeb-952ff47b8278" />

I clicked "Don't show again" which showed another popup

<img width="560" height="128" alt="Image" src="https://github.com/user-attachments/assets/590df3af-ef0a-4971-ba8a-a06110f1f2a8" />

and then "Any folder". For now, I don't have any Dev Container use cases ...

Labels: Documentation
DOC Add documentation on how to disable the DevContainer popups in VSCode

One for @DeaMariaLeon [^1] when you manage to figure out how to remove these annoying popups

[^1]: oops pinged the wrong Dea originally 😅 ...

There seems to be two related popups:
- install Dev Containers extension (I probably had it installed already which is why I was not exactly seeing the same thing as @DeaMariaLeon)
- once you have the DevContainers installed: do you want to run inside the devcontainer. This was the popup from my comment https://github.com/scikit-learn/scikit-learn/pull/31096#issuecomment-3350817895. 

Discussed in https://github.com/scikit-learn/scikit-learn/issues/32342#issuecomment-3397290793
            
`containers.showRemoteWorkspaceWarning` settings is supposed to fix it but maybe not completely according to https://github.com/scikit-learn/scikit-learn/pull/32342#issuecomment-3397763595? Anyway this needs more investigation ...

COMMENT:
I guess it's enough for now to have this issue that we can find and/or point people to it. 

Adding this in the documentation, maybe one day, but at the same time, it's the kind of VSCode detail that can change and the documentation can become outdated.

Labels: Documentation
is_classifier() returns False for Custom Classifier

### Describe the bug

`is_classifier()` should return True for an instance of a custom classifier.

### Steps/Code to Reproduce

```python
from sklearn.base import BaseEstimator, ClassifierMixin, is_classifier
from sklearn import __version__ as sklearn_version

# A minimal estimator class inheriting from both.

class MyClassifier(BaseEstimator, ClassifierMixin):
    def fit(self, X, y):
        return self

    def predict(self, X):
        return [1] * len(X)

# 1. Instantiate the estimator
my_clf = MyClassifier()

# 2. Check its type using the function
is_it_a_classifier = is_classifier(my_clf)

print(f"Is `my_clf` a classifier? -> {is_it_a_classifier}")
print(f"Version of sklearn: {sklearn_version}")
```

### Expected Results

Should return True.

### Actual Results

Returns False.

### Versions

```shell
System:
    python: 3.11.14 | packaged by conda-forge | (main, Oct 13 2025, 14:00:26) [MSC v.1944 64 bit (AMD64)]
executable: c:\Users\william.chiu\.conda\envs\env_sklearnex_202510\python.exe
   machine: Windows-10-10.0.17763-SP0

Python dependencies:
      sklearn: 1.7.2
          pip: 25.2
   setuptools: 80.9.0
        numpy: 2.1.3
        scipy: 1.15.3
       Cython: 3.1.4
       pandas: 2.3.3
   matplotlib: 3.10.0
       joblib: 1.5.2
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
    num_threads: 72
         prefix: vcomp
       filepath: C:\Users\william.chiu\.conda\envs\env_sklearnex_202510\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 24
         prefix: libscipy_openblas
       filepath: C:\Users\william.chiu\.conda\envs\env_sklearnex_202510\Lib\site-packages\numpy.libs\libscipy_openblas64_-c16e4918366c6bc1f1cd71e28ca36fc0.dll
        version: 0.3.27
threading_layer: pthreads
   architecture: SkylakeX

       user_api: blas
   internal_api: openblas
    num_threads: 24
         prefix: libscipy_openblas
       filepath: C:\Users\william.chiu\.conda\envs\env_sklearnex_202510\Lib\site-packages\scipy.libs\libscipy_openblas-f07f5a5d207a3a47104dca54d6d0c86a.dll
        version: 0.3.28
threading_layer: pthreads
   architecture: SkylakeX
```

COMMENT:
Yep, and if you run `check_estimator` on it, it does raise due to wrong order of inheritance.

Labels: Bug, Needs Triage
MNT Check the variable initialization in Cython pxd files

So it turns out variable initialization in pxd files doesn't do anything see https://github.com/scikit-learn/scikit-learn/pull/32259#issuecomment-3337478228.

It would be good to check that we are not doing it in other places than the ones we have already fixed (see https://github.com/scikit-learn/scikit-learn/pull/32291 for an example of a PR fixing one of these)

```
git grep -C10 -P '\w+\s*=\s*\d' **/*.pxd
```

Some of them are inside `enum` and my guess is that it works fine (to be double-checked ...) but at least one of them is not:
```
sklearn/utils/_random.pxd:cdef inline uint32_t DEFAULT_SEED = 1
```

The value is set in the `.pyx` so I guess in this case it's fine to remove the initialization from the `pxd` (and I guess also the type declaration in the `pyx`).

_Originally posted by @lesteve in https://github.com/scikit-learn/scikit-learn/issues/32259#issuecomment-3338224571_
            
Another way to check is to use Cython development version which has added a warning since https://github.com/cython/cython/pull/7176.

COMMENT:
hey @lesteve, I am really interested in this issue. Could you please assign it to me?

Labels: cython
MNT Check the variable initialization in Cython pxd files

So it turns out variable initialization in pxd files doesn't do anything see https://github.com/scikit-learn/scikit-learn/pull/32259#issuecomment-3337478228.

It would be good to check that we are not doing it in other places than the ones we have already fixed (see https://github.com/scikit-learn/scikit-learn/pull/32291 for an example of a PR fixing one of these)

```
git grep -C10 -P '\w+\s*=\s*\d' **/*.pxd
```

Some of them are inside `enum` and my guess is that it works fine (to be double-checked ...) but at least one of them is not:
```
sklearn/utils/_random.pxd:cdef inline uint32_t DEFAULT_SEED = 1
```

The value is set in the `.pyx` so I guess in this case it's fine to remove the initialization from the `pxd` (and I guess also the type declaration in the `pyx`).

_Originally posted by @lesteve in https://github.com/scikit-learn/scikit-learn/issues/32259#issuecomment-3338224571_
            
Another way to check is to use Cython development version which has added a warning since https://github.com/cython/cython/pull/7176.

COMMENT:
@hsachdeva9 this is not a good issue for a new contributor. Also we don't assign issues to people in our project.

Great if you are looking to contribute to scikit-learn! Please have a look at our [contributing doc](https://scikit-learn.org/dev/developers/contributing.html) and in particular the section [Issues for new contributors](https://scikit-learn.org/dev/developers/contributing.html#new-contributors).

Labels: cython
MNT Check the variable initialization in Cython pxd files

So it turns out variable initialization in pxd files doesn't do anything see https://github.com/scikit-learn/scikit-learn/pull/32259#issuecomment-3337478228.

It would be good to check that we are not doing it in other places than the ones we have already fixed (see https://github.com/scikit-learn/scikit-learn/pull/32291 for an example of a PR fixing one of these)

```
git grep -C10 -P '\w+\s*=\s*\d' **/*.pxd
```

Some of them are inside `enum` and my guess is that it works fine (to be double-checked ...) but at least one of them is not:
```
sklearn/utils/_random.pxd:cdef inline uint32_t DEFAULT_SEED = 1
```

The value is set in the `.pyx` so I guess in this case it's fine to remove the initialization from the `pxd` (and I guess also the type declaration in the `pyx`).

_Originally posted by @lesteve in https://github.com/scikit-learn/scikit-learn/issues/32259#issuecomment-3338224571_
            
Another way to check is to use Cython development version which has added a warning since https://github.com/cython/cython/pull/7176.

COMMENT:
I'd like to work on this issue. I'll use the provided git grep command to find all variable initializations in .pxd files and verify which ones need fixing.

Labels: cython