Talip7/scikit-learn-issues-multilabel huggingface dataset:
tree.plot_tree() method takes too long then crashes 1.2.2

### Describe the bug

Hello Everyone,

So i'm training a decision tree model on a trainng set of about 200k rows and 8 cols, the training itself doesn't take long but when i try to visualize the tree using tree.plot_tree(), it doesn't work and i wait too long for it, untill it crashes.

Here is my code:

```python
plt.figure(figsize=(20,10))
plot_tree(model, feature_names=X_train.columns, class_names=['True', 'False'], filled=True)
plt.show()
```

It is a binary classification, so i put the ['True', 'False'], is there something wrong with my code, or is the data just too large ?

Thanks a lot and have a nice day 


### Steps/Code to Reproduce

```python
# Import necessary libraries

from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier, plot_tree
import matplotlib.pyplot as plt

# Step 1: Load the Iris dataset
iris = load_iris()
X, y = iris.data, iris.target

# Step 2: Train a decision tree classifier
clf = DecisionTreeClassifier()
clf.fit(X, y)

# Step 3: Visualize the decision tree
plt.figure(figsize=(20, 10))  # Set the figure size for better visibility
plot_tree(clf, filled=True, feature_names=iris.feature_names, class_names=iris.target_names)
```
### Expected Results

A tree visualization 

### Actual Results

Takes too long, and then kernel crash

### Versions

```shell
Version 1.2.2
```

COMMENT:
> 200k rows and 8 cols

OK so this is really a different setting from iris (only 150 samples).

Plotting a tree with 200,000 samples will lead to a large number of nodes and leaves (potentially `2 ** n+1` I think). So I don't think that matplotlib can handle this type of rendering.

This is something that we will not fix.

Labels: Bug, Needs Info
classification_report with output_dict=True leads to brittle output

### Describe the workflow you want to enable

When `output_dict` is `True`, the returned `dict` structure is brittle and breaks if one of the class name is the same as one of the average metrics.  
Here for example one of the class is named "accuracy" so that it doesn't appear in the returned `dict` .

``` python
from sklearn.metrics import classification_report
from pprint import pprint

classification_report(
    ["chat", "accuracy"],
    ["chat", "accuracy"],
    output_dict=True,
)
```

``` python
{'accuracy': 1.0,
 'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
 'macro avg': {'f1-score': 1.0,
               'precision': 1.0,
               'recall': 1.0,
               'support': 2.0},
 'weighted avg': {'f1-score': 1.0,
                  'precision': 1.0,
                  'recall': 1.0,
                  'support': 2.0}}
```

### Describe your proposed solution

Any unambiguous output structure, such as separating between class-wise and average metrics:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'average': {
        'accuracy': 1.0,
        'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
}
```

Or:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'accuracy': 1.0,
    'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
}
```

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

_No response_

### Additional context

_No response_

COMMENT:
Indeed, this is unfortunate. Changing the dictionary will break the API for everyone. Maybe we could come with something less invasive where we could remap the name of the class or something similar.

Labels: Bug
classification_report with output_dict=True leads to brittle output

### Describe the workflow you want to enable

When `output_dict` is `True`, the returned `dict` structure is brittle and breaks if one of the class name is the same as one of the average metrics.  
Here for example one of the class is named "accuracy" so that it doesn't appear in the returned `dict` .

``` python
from sklearn.metrics import classification_report
from pprint import pprint

classification_report(
    ["chat", "accuracy"],
    ["chat", "accuracy"],
    output_dict=True,
)
```

``` python
{'accuracy': 1.0,
 'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
 'macro avg': {'f1-score': 1.0,
               'precision': 1.0,
               'recall': 1.0,
               'support': 2.0},
 'weighted avg': {'f1-score': 1.0,
                  'precision': 1.0,
                  'recall': 1.0,
                  'support': 2.0}}
```

### Describe your proposed solution

Any unambiguous output structure, such as separating between class-wise and average metrics:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'average': {
        'accuracy': 1.0,
        'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
}
```

Or:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'accuracy': 1.0,
    'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
}
```

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

_No response_

### Additional context

_No response_

COMMENT:
We can add something like a `strict_output_dict_format` in {`True`, `False`} or `output_dict_format` in {`legacy`, `unambiguous`} parameter.  
Not very pleasing to the eye but the most conceptually clean solution (besides making a breaking change to the API).

Labels: Bug
classification_report with output_dict=True leads to brittle output

### Describe the workflow you want to enable

When `output_dict` is `True`, the returned `dict` structure is brittle and breaks if one of the class name is the same as one of the average metrics.  
Here for example one of the class is named "accuracy" so that it doesn't appear in the returned `dict` .

``` python
from sklearn.metrics import classification_report
from pprint import pprint

classification_report(
    ["chat", "accuracy"],
    ["chat", "accuracy"],
    output_dict=True,
)
```

``` python
{'accuracy': 1.0,
 'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
 'macro avg': {'f1-score': 1.0,
               'precision': 1.0,
               'recall': 1.0,
               'support': 2.0},
 'weighted avg': {'f1-score': 1.0,
                  'precision': 1.0,
                  'recall': 1.0,
                  'support': 2.0}}
```

### Describe your proposed solution

Any unambiguous output structure, such as separating between class-wise and average metrics:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'average': {
        'accuracy': 1.0,
        'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
}
```

Or:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'accuracy': 1.0,
    'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
}
```

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

_No response_

### Additional context

_No response_

COMMENT:
@OmarManzoor do you have some bandwidth to review #29240 and #29668 maybe?

Labels: Bug
classification_report with output_dict=True leads to brittle output

### Describe the workflow you want to enable

When `output_dict` is `True`, the returned `dict` structure is brittle and breaks if one of the class name is the same as one of the average metrics.  
Here for example one of the class is named "accuracy" so that it doesn't appear in the returned `dict` .

``` python
from sklearn.metrics import classification_report
from pprint import pprint

classification_report(
    ["chat", "accuracy"],
    ["chat", "accuracy"],
    output_dict=True,
)
```

``` python
{'accuracy': 1.0,
 'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
 'macro avg': {'f1-score': 1.0,
               'precision': 1.0,
               'recall': 1.0,
               'support': 2.0},
 'weighted avg': {'f1-score': 1.0,
                  'precision': 1.0,
                  'recall': 1.0,
                  'support': 2.0}}
```

### Describe your proposed solution

Any unambiguous output structure, such as separating between class-wise and average metrics:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'average': {
        'accuracy': 1.0,
        'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
}
```

Or:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'accuracy': 1.0,
    'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
}
```

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

_No response_

### Additional context

_No response_

COMMENT:
@adrinjalali One of the PRs is prepending "class " to the metrics that are associated with different class labels. While the other is keeping the class labels as they are currently and instead combining all the overall metrics into a key called "averages". Which approach would we prefer? Depending on the preference, we can move forward with reviewing that PR and closing the other one.

Labels: Bug
classification_report with output_dict=True leads to brittle output

### Describe the workflow you want to enable

When `output_dict` is `True`, the returned `dict` structure is brittle and breaks if one of the class name is the same as one of the average metrics.  
Here for example one of the class is named "accuracy" so that it doesn't appear in the returned `dict` .

``` python
from sklearn.metrics import classification_report
from pprint import pprint

classification_report(
    ["chat", "accuracy"],
    ["chat", "accuracy"],
    output_dict=True,
)
```

``` python
{'accuracy': 1.0,
 'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
 'macro avg': {'f1-score': 1.0,
               'precision': 1.0,
               'recall': 1.0,
               'support': 2.0},
 'weighted avg': {'f1-score': 1.0,
                  'precision': 1.0,
                  'recall': 1.0,
                  'support': 2.0}}
```

### Describe your proposed solution

Any unambiguous output structure, such as separating between class-wise and average metrics:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'average': {
        'accuracy': 1.0,
        'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
}
```

Or:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'accuracy': 1.0,
    'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
}
```

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

_No response_

### Additional context

_No response_

COMMENT:
I think I prefer better structuring the output instead of renaming labels, maybe even more structuring than what's proposed in the PR. Not sure what @glemaitre prefers.

Labels: Bug
classification_report with output_dict=True leads to brittle output

### Describe the workflow you want to enable

When `output_dict` is `True`, the returned `dict` structure is brittle and breaks if one of the class name is the same as one of the average metrics.  
Here for example one of the class is named "accuracy" so that it doesn't appear in the returned `dict` .

``` python
from sklearn.metrics import classification_report
from pprint import pprint

classification_report(
    ["chat", "accuracy"],
    ["chat", "accuracy"],
    output_dict=True,
)
```

``` python
{'accuracy': 1.0,
 'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
 'macro avg': {'f1-score': 1.0,
               'precision': 1.0,
               'recall': 1.0,
               'support': 2.0},
 'weighted avg': {'f1-score': 1.0,
                  'precision': 1.0,
                  'recall': 1.0,
                  'support': 2.0}}
```

### Describe your proposed solution

Any unambiguous output structure, such as separating between class-wise and average metrics:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'average': {
        'accuracy': 1.0,
        'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
}
```

Or:
``` python
{
    'class': {
        'accuracy': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
        'chat': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    },
    'accuracy': 1.0,
    'macro avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
    'weighted avg': {'f1-score': 1.0, 'precision': 1.0, 'recall': 1.0, 'support': 1.0},
}
```

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

_No response_

### Additional context

_No response_

COMMENT:
Since we have the a way to display the information, I would also prefer structuring the information when it comes to get the results.

Labels: Bug
scikit-learn algorithm cheat sheet (Diagram)

### Describe the bug

It seems there is some wrong path, described for choosing the estimator in the main diagram as compared to the previous versions.
https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html
So, the moment you hit the above link you will get a diagram to choose the right estimator, but it is not taking me in the right direction. I think so (issue mentioned in the screenshot)
Wrong diagram screenshot
![image](https://github.com/scikit-learn/scikit-learn/assets/40638304/bb37002d-5549-4b71-92ce-42b7c0ea1c3b)

correct diagram screenshot
![image](https://github.com/scikit-learn/scikit-learn/assets/40638304/ec26f3ee-9f4b-482c-b2f5-916ace942ae7)


### Steps/Code to Reproduce

Getting wrong direction for estimator

### Expected Results

correct diagram screenshot
![image](https://github.com/scikit-learn/scikit-learn/assets/40638304/ec26f3ee-9f4b-482c-b2f5-916ace942ae7)

### Actual Results

Wrong diagram screenshot
![image](https://github.com/scikit-learn/scikit-learn/assets/40638304/bb37002d-5549-4b71-92ce-42b7c0ea1c3b)

### Versions

```shell
v1.5.0
```

COMMENT:
This is fixed upstream (we probably want to quickly cherry pick the commit for the stable branch @glemaitre @jeremiedbb , we've had a few of these issues now)

Labels: Bug, Needs Triage
Inconsistency regarding Poisson regression in decision tree user guide doc

### Inconsistency about criterion in Decision Tree Regressor

Hi! I was revising scitkit-learn  User guide about Decision Tree regressors and I found an inconsistency. In 1.10.7.2. Regression criteria it is mentioned **Poisson Deviance**. However, the formula showed is the one of **Half Poisson Deviance**. Furthermore, when I checked API section about decision tree regressor and **poisson deviance** is mentioned not **half poisson deviance**. So, I'm confused, what is the criterion used Poisson Deviance or Half Poisson Deviance? I need an answer as soon as posible as I'm using this function in my bachelor thesis.
<img width="488" alt="Captura de pantalla 2024-06-06 024245" src="https://github.com/scikit-learn/scikit-learn/assets/171883799/0e6f5f63-b550-4a91-9ee5-b01f3b01d0c2">
<img width="499" alt="image" src="https://github.com/scikit-learn/scikit-learn/assets/171883799/eb430dd4-8ec1-494c-a47c-ec06f85d88e2">




### Edit documentation

Please can you fix this inconsistency? If poisson deviance is used change the formula in the guide but if half poisson deviance is used can you specify it?
Thanks!

COMMENT:
> I need an answer as soon as posible as I'm using this function in my bachelor thesis.

Just to clarify, this is an issue tracker and these type of claim does not have its place here.

The criterion minimized is the half Poisson deviance since that `x2` factor does not change the split found and would require an extra multiplication at each split evaluation.

I'm thinking that we should probably write the user guide in terms of Poisson deviance and then have a note stating the implementation details regarding the half losses.

Labels: Documentation
Inconsistency regarding Poisson regression in decision tree user guide doc

### Inconsistency about criterion in Decision Tree Regressor

Hi! I was revising scitkit-learn  User guide about Decision Tree regressors and I found an inconsistency. In 1.10.7.2. Regression criteria it is mentioned **Poisson Deviance**. However, the formula showed is the one of **Half Poisson Deviance**. Furthermore, when I checked API section about decision tree regressor and **poisson deviance** is mentioned not **half poisson deviance**. So, I'm confused, what is the criterion used Poisson Deviance or Half Poisson Deviance? I need an answer as soon as posible as I'm using this function in my bachelor thesis.
<img width="488" alt="Captura de pantalla 2024-06-06 024245" src="https://github.com/scikit-learn/scikit-learn/assets/171883799/0e6f5f63-b550-4a91-9ee5-b01f3b01d0c2">
<img width="499" alt="image" src="https://github.com/scikit-learn/scikit-learn/assets/171883799/eb430dd4-8ec1-494c-a47c-ec06f85d88e2">




### Edit documentation

Please can you fix this inconsistency? If poisson deviance is used change the formula in the guide but if half poisson deviance is used can you specify it?
Thanks!

COMMENT:
@carlaxc Do you wish to contribute by making a pull-request.

Labels: Documentation
Inconsistency regarding Poisson regression in decision tree user guide doc

### Inconsistency about criterion in Decision Tree Regressor

Hi! I was revising scitkit-learn  User guide about Decision Tree regressors and I found an inconsistency. In 1.10.7.2. Regression criteria it is mentioned **Poisson Deviance**. However, the formula showed is the one of **Half Poisson Deviance**. Furthermore, when I checked API section about decision tree regressor and **poisson deviance** is mentioned not **half poisson deviance**. So, I'm confused, what is the criterion used Poisson Deviance or Half Poisson Deviance? I need an answer as soon as posible as I'm using this function in my bachelor thesis.
<img width="488" alt="Captura de pantalla 2024-06-06 024245" src="https://github.com/scikit-learn/scikit-learn/assets/171883799/0e6f5f63-b550-4a91-9ee5-b01f3b01d0c2">
<img width="499" alt="image" src="https://github.com/scikit-learn/scikit-learn/assets/171883799/eb430dd4-8ec1-494c-a47c-ec06f85d88e2">




### Edit documentation

Please can you fix this inconsistency? If poisson deviance is used change the formula in the guide but if half poisson deviance is used can you specify it?
Thanks!

COMMENT:
@glemaitre If I may I would like to submit a PR for this. That would be my first scikit-learn contribution.
I would then update this part of the documentation

https://github.com/scikit-learn/scikit-learn/blob/ea1e8c4b216d4b1e21b02bafe75ee1713ad21079/doc/modules/tree.rst?plain=1#L536-L577

and also the docstring here
https://github.com/scikit-learn/scikit-learn/blob/ea1e8c4b216d4b1e21b02bafe75ee1713ad21079/sklearn/tree/_classes.py#L1100-L1109

Labels: Documentation
Mistake on "Choosing the right estimator" in latest documentation

### Describe the issue linked to the documentation

On the latest stable version (1.5.0) of the documentation, on the [Choosing the right estimator](https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html#choosing-the-right-estimator) section of the sklearn tutorials, there is an error in the fluxogram:
![image](https://github.com/scikit-learn/scikit-learn/assets/16235786/445b06da-b916-4e0a-9f70-dde228ed93f1)
This arrow should start on the "predicting a quantity", like the following image from the fluxogram  present on version 1.4.2 of the documentation
![image](https://github.com/scikit-learn/scikit-learn/assets/16235786/fde430ee-46bc-4220-a4b2-92cb380eb79b)


### Suggest a potential alternative/fix

_No response_

COMMENT:
already fixed on `main`: https://scikit-learn.org/dev/machine_learning_map.html#choosing-the-right-estimator

Labels: Documentation, Needs Triage
⚠️ CI failed on Linux_nogil.pylatest_pip_nogil (last failure: Jun 10, 2024) ⚠️

**CI is still failing on [Linux_nogil.pylatest_pip_nogil](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=67402&view=logs&j=67fbb25f-e417-50be-be55-3b1e9637fce5)** (Jun 10, 2024)
Unable to find junit file. Please see link for details.

COMMENT:
Now that we check build dependencies https://github.com/scikit-learn/scikit-learn/pull/29132, the numpy in nogil is too old, i.e. 1.24 and we want >=1.25.

I think this may be worth removing this historic nogil build given that a CPython 3.13 free-threaded will happen soonish, maybe a few weeks:
- there is already a free-threaded Numpy wheel in https://anaconda.org/scientific-python-nightly-wheels/numpy/files. Look for `313t` (`t` is the marker for free-threaded)
- there will be soon a free-threaded Scipy wheel: https://github.com/scipy/scipy/pull/20882
- once there is a Scipy wheel, it is up to us to add a CI build for CPython 3.13 free-threaded :wink:. Locally it seems like the full test suite passes (at least for me) https://github.com/scikit-learn/scikit-learn/issues/28978#issuecomment-2129447374

Labels: Needs Triage
⚠️ CI failed on Linux_nogil.pylatest_pip_nogil (last failure: Jun 10, 2024) ⚠️

**CI is still failing on [Linux_nogil.pylatest_pip_nogil](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=67402&view=logs&j=67fbb25f-e417-50be-be55-3b1e9637fce5)** (Jun 10, 2024)
Unable to find junit file. Please see link for details.

COMMENT:
I opened https://github.com/scikit-learn/scikit-learn/pull/29191 to remove the nogil CPython 3.9 build.

Labels: Needs Triage