Talip7/scikit-learn-issues-multilabel huggingface dataset:
Putting it all together Pipelining is not working ( missing dependencies and plot )

### Describe the issue linked to the documentation

From https://scikit-learn.org/stable/tutorial/statistical_inference/putting_together.html#pipelining it is missing
```
from sklearn import datasets
import numpy as np
import matplotlib.pyplot as plt
```
The last chart is missing the data

![image](https://github.com/scikit-learn/scikit-learn/assets/687311/99953518-cc6e-4a63-a1a8-b15eda3363f4)


### Suggest a potential alternative/fix

_No response_

COMMENT:
The code inside https://scikit-learn.org/stable/tutorial/statistical_inference/putting_together.html#pipelining is incomplete
```
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler

# Define a pipeline to search for the best combination of PCA truncation
# and classifier regularization.
pca = PCA()
# Define a Standard Scaler to normalize inputs
scaler = StandardScaler()

# set the tolerance to a large value to make the example faster
logistic = LogisticRegression(max_iter=10000, tol=0.1)
pipe = Pipeline(steps=[("scaler", scaler), ("pca", pca), ("logistic", logistic)])

X_digits, y_digits = datasets.load_digits(return_X_y=True)
# Parameters of pipelines can be set using '__' separated parameter names:
param_grid = {
    "pca__n_components": [5, 15, 30, 45, 60],
    "logistic__C": np.logspace(-4, 4, 4),
}
search = GridSearchCV(pipe, param_grid, n_jobs=2)
search.fit(X_digits, y_digits)
print("Best parameter (CV score=%0.3f):" % search.best_score_)
print(search.best_params_)

# Plot the PCA spectrum
pca.fit(X_digits)

fig, (ax0, ax1) = plt.subplots(nrows=2, sharex=True, figsize=(6, 6))
ax0.plot(
    np.arange(1, pca.n_components_ + 1), pca.explained_variance_ratio_, "+", linewidth=2
)
ax0.set_ylabel("PCA explained variance ratio")

ax0.axvline(
    search.best_estimator_.named_steps["pca"].n_components,
    linestyle=":",
    label="n_components chosen",
)
ax0.legend(prop=dict(size=12))
```

Labels: Documentation
Putting it all together Pipelining is not working ( missing dependencies and plot )

### Describe the issue linked to the documentation

From https://scikit-learn.org/stable/tutorial/statistical_inference/putting_together.html#pipelining it is missing
```
from sklearn import datasets
import numpy as np
import matplotlib.pyplot as plt
```
The last chart is missing the data

![image](https://github.com/scikit-learn/scikit-learn/assets/687311/99953518-cc6e-4a63-a1a8-b15eda3363f4)


### Suggest a potential alternative/fix

_No response_

COMMENT:
Ah, I had missed before that you were talking about the tutorial, not about [this example](https://scikit-learn.org/stable/auto_examples/compose/plot_digits_pipe.html#sphx-glr-auto-examples-compose-plot-digits-pipe-py). 

Thanks for reporting, @diegolovison. We will take care of that.

Labels: Documentation
Putting it all together Pipelining is not working ( missing dependencies and plot )

### Describe the issue linked to the documentation

From https://scikit-learn.org/stable/tutorial/statistical_inference/putting_together.html#pipelining it is missing
```
from sklearn import datasets
import numpy as np
import matplotlib.pyplot as plt
```
The last chart is missing the data

![image](https://github.com/scikit-learn/scikit-learn/assets/687311/99953518-cc6e-4a63-a1a8-b15eda3363f4)


### Suggest a potential alternative/fix

_No response_

COMMENT:
Nice. We are on the same page now.

Where is the source code for the documentation?
I believe we can have a single code shared in both tutorials.

Labels: Documentation
Putting it all together Pipelining is not working ( missing dependencies and plot )

### Describe the issue linked to the documentation

From https://scikit-learn.org/stable/tutorial/statistical_inference/putting_together.html#pipelining it is missing
```
from sklearn import datasets
import numpy as np
import matplotlib.pyplot as plt
```
The last chart is missing the data

![image](https://github.com/scikit-learn/scikit-learn/assets/687311/99953518-cc6e-4a63-a1a8-b15eda3363f4)


### Suggest a potential alternative/fix

_No response_

COMMENT:
It is here: `doc/tutorial/statistical_inference/putting_together.rst`.
Do you want to go ahead and create a PR?

Labels: Documentation
Putting it all together Pipelining is not working ( missing dependencies and plot )

### Describe the issue linked to the documentation

From https://scikit-learn.org/stable/tutorial/statistical_inference/putting_together.html#pipelining it is missing
```
from sklearn import datasets
import numpy as np
import matplotlib.pyplot as plt
```
The last chart is missing the data

![image](https://github.com/scikit-learn/scikit-learn/assets/687311/99953518-cc6e-4a63-a1a8-b15eda3363f4)


### Suggest a potential alternative/fix

_No response_

COMMENT:
Sounds good. Going to create it.

Labels: Documentation
Putting it all together Pipelining is not working ( missing dependencies and plot )

### Describe the issue linked to the documentation

From https://scikit-learn.org/stable/tutorial/statistical_inference/putting_together.html#pipelining it is missing
```
from sklearn import datasets
import numpy as np
import matplotlib.pyplot as plt
```
The last chart is missing the data

![image](https://github.com/scikit-learn/scikit-learn/assets/687311/99953518-cc6e-4a63-a1a8-b15eda3363f4)


### Suggest a potential alternative/fix

_No response_

COMMENT:
Tutorials are now removed from the repo.

Labels: Documentation
infinity in split nodes

### Describe the bug

![image](https://github.com/scikit-learn/scikit-learn/assets/72708109/05146230-843e-4347-92cb-aed5e642328a)

I've created a simple model with decision trees. However, when I used the "export_text" function, I noticed that there are "infinity" values in the split nodes. Is this an error, or is it an expected behavior? It doesn't seem logical to me at all.

note: train data contains null.

### Steps/Code to Reproduce

DT = sklearn.tree.DecisionTreeClassifier()
DT.fit(X_train, y_train)
export_text(DT)

### Expected Results

There shouldn't infinity.

### Actual Results

in image.

### Versions

```shell
System:
    python: 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]
executable: C:\Users\sametc\AppData\Local\Programs\Python\Python311\python.exe
   machine: Windows-10-10.0.19044-SP0

Python dependencies:
      sklearn: 1.3.0
          pip: 23.1.2
   setuptools: 68.0.0
        numpy: 1.25.1
        scipy: 1.10.1
       Cython: 3.0.0b3
       pandas: 2.0.2
   matplotlib: 3.7.1
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: vcomp
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\numpy\.libs\libopenblas64__v0.3.23-gcc_10_3_0.dll
        version: 0.3.23
threading_layer: pthreads
   architecture: Haswell
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy.libs\libopenblas-802f9ed1179cb9c9b03d67ff79f48187.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: Haswell
    num_threads: 8
```

COMMENT:
To better help, we'll need a [minimal reproducer](https://scikit-learn.org/stable/developers/minimal_reproducer.html).

Without extra information, the threshold can be infinity if it is "splitting on missing values". This means all the missing values go to one child and the non-missing values goes to the other child. Are there missing values in your dataset?

Labels: Bug, module:tree, Needs Reproducible Code, Needs Investigation
infinity in split nodes

### Describe the bug

![image](https://github.com/scikit-learn/scikit-learn/assets/72708109/05146230-843e-4347-92cb-aed5e642328a)

I've created a simple model with decision trees. However, when I used the "export_text" function, I noticed that there are "infinity" values in the split nodes. Is this an error, or is it an expected behavior? It doesn't seem logical to me at all.

note: train data contains null.

### Steps/Code to Reproduce

DT = sklearn.tree.DecisionTreeClassifier()
DT.fit(X_train, y_train)
export_text(DT)

### Expected Results

There shouldn't infinity.

### Actual Results

in image.

### Versions

```shell
System:
    python: 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]
executable: C:\Users\sametc\AppData\Local\Programs\Python\Python311\python.exe
   machine: Windows-10-10.0.19044-SP0

Python dependencies:
      sklearn: 1.3.0
          pip: 23.1.2
   setuptools: 68.0.0
        numpy: 1.25.1
        scipy: 1.10.1
       Cython: 3.0.0b3
       pandas: 2.0.2
   matplotlib: 3.7.1
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: vcomp
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\numpy\.libs\libopenblas64__v0.3.23-gcc_10_3_0.dll
        version: 0.3.23
threading_layer: pthreads
   architecture: Haswell
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy.libs\libopenblas-802f9ed1179cb9c9b03d67ff79f48187.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: Haswell
    num_threads: 8
```

COMMENT:
@thomasjpfan Assuming there're some NaNs in feature_18 in the OP, while the splitting threshold is 0.01, how could I get to know quickly **which node all NaNs go to**? Thx!

Labels: Bug, module:tree, Needs Reproducible Code, Needs Investigation
infinity in split nodes

### Describe the bug

![image](https://github.com/scikit-learn/scikit-learn/assets/72708109/05146230-843e-4347-92cb-aed5e642328a)

I've created a simple model with decision trees. However, when I used the "export_text" function, I noticed that there are "infinity" values in the split nodes. Is this an error, or is it an expected behavior? It doesn't seem logical to me at all.

note: train data contains null.

### Steps/Code to Reproduce

DT = sklearn.tree.DecisionTreeClassifier()
DT.fit(X_train, y_train)
export_text(DT)

### Expected Results

There shouldn't infinity.

### Actual Results

in image.

### Versions

```shell
System:
    python: 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]
executable: C:\Users\sametc\AppData\Local\Programs\Python\Python311\python.exe
   machine: Windows-10-10.0.19044-SP0

Python dependencies:
      sklearn: 1.3.0
          pip: 23.1.2
   setuptools: 68.0.0
        numpy: 1.25.1
        scipy: 1.10.1
       Cython: 3.0.0b3
       pandas: 2.0.2
   matplotlib: 3.7.1
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: vcomp
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\numpy\.libs\libopenblas64__v0.3.23-gcc_10_3_0.dll
        version: 0.3.23
threading_layer: pthreads
   architecture: Haswell
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy.libs\libopenblas-802f9ed1179cb9c9b03d67ff79f48187.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: Haswell
    num_threads: 8
```

COMMENT:
`missing_go_to_left` gives the information about nans going left: (1 means "go left")

```python
import numpy as np
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier

X, y = load_iris(return_X_y=True)
X[[0, 3], 2] = np.nan

clf = DecisionTreeClassifier(max_leaf_nodes=3, random_state=0)
clf.fit(X, y)

# clf.tree_.missing_go_to_left
array([0, 0, 1, 1, 1], dtype=uint8)
```

The position of the elements in `missing_go_to_left` match the semantics described in [this example](https://scikit-learn.org/stable/auto_examples/tree/plot_unveil_tree_structure.html#tree-structure) .

Labels: Bug, module:tree, Needs Reproducible Code, Needs Investigation
infinity in split nodes

### Describe the bug

![image](https://github.com/scikit-learn/scikit-learn/assets/72708109/05146230-843e-4347-92cb-aed5e642328a)

I've created a simple model with decision trees. However, when I used the "export_text" function, I noticed that there are "infinity" values in the split nodes. Is this an error, or is it an expected behavior? It doesn't seem logical to me at all.

note: train data contains null.

### Steps/Code to Reproduce

DT = sklearn.tree.DecisionTreeClassifier()
DT.fit(X_train, y_train)
export_text(DT)

### Expected Results

There shouldn't infinity.

### Actual Results

in image.

### Versions

```shell
System:
    python: 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]
executable: C:\Users\sametc\AppData\Local\Programs\Python\Python311\python.exe
   machine: Windows-10-10.0.19044-SP0

Python dependencies:
      sklearn: 1.3.0
          pip: 23.1.2
   setuptools: 68.0.0
        numpy: 1.25.1
        scipy: 1.10.1
       Cython: 3.0.0b3
       pandas: 2.0.2
   matplotlib: 3.7.1
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: vcomp
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\numpy\.libs\libopenblas64__v0.3.23-gcc_10_3_0.dll
        version: 0.3.23
threading_layer: pthreads
   architecture: Haswell
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: C:\Users\sametc\AppData\Local\Programs\Python\Python311\Lib\site-packages\scipy.libs\libopenblas-802f9ed1179cb9c9b03d67ff79f48187.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: Haswell
    num_threads: 8
```

COMMENT:
Closing this since there is no issue. Also we solve some additional issues linked to missing values handling since.

Labels: Bug, module:tree, Needs Reproducible Code, Needs Investigation
Add sample weighting to V Measure Score

### Describe the workflow you want to enable

Many evaluation metrics in sklearn have the ability to weight samples by some measure of importance (usually included as a `sample_weight`). This is also important to do when evaluating clustering. In particular, the `v_measure_score` (and the metrics and functions it relies on), should have this ability.

### Describe your proposed solution

The proposed solution is to amend the `v_measure_score` function, as well as the `entropy`, the `contingency_matrix` and the `mutual_info_score` functions, to include a `sample_weight` input parameter. 

This has been implemented and tested already in [this](https://github.com/wpmccormack/ePIC_Clustering_2023/blob/pip_installable/epic_clustering/scoring/scoring_functions.py) repository, for [this](https://www.kaggle.com/competitions/hgs-hire-power-week-an-epic-competition/overview) Kaggle challenge scoring metric. 

Making the changes requires very little substantive changes to each function, and handling the edge cases is straightforward. This would make the `v_measure_score` much more useful for cases such as those in the Kaggle challenge (clustering of energy deposits of different intensities).

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

A possible alternative is to keep the current functions, and handle weighting by repeating entries according to their weight. However, this is expensive and clunky, and doesn't work for fractional weights.

### Additional context

_No response_

COMMENT:
I'm also very happy to work on this contribution myself. A draft has already been sketched in the linked repository, so I would just need some guidance on getting test coverage on the amended functions.

Labels: New Feature
Add sample weighting to V Measure Score

### Describe the workflow you want to enable

Many evaluation metrics in sklearn have the ability to weight samples by some measure of importance (usually included as a `sample_weight`). This is also important to do when evaluating clustering. In particular, the `v_measure_score` (and the metrics and functions it relies on), should have this ability.

### Describe your proposed solution

The proposed solution is to amend the `v_measure_score` function, as well as the `entropy`, the `contingency_matrix` and the `mutual_info_score` functions, to include a `sample_weight` input parameter. 

This has been implemented and tested already in [this](https://github.com/wpmccormack/ePIC_Clustering_2023/blob/pip_installable/epic_clustering/scoring/scoring_functions.py) repository, for [this](https://www.kaggle.com/competitions/hgs-hire-power-week-an-epic-competition/overview) Kaggle challenge scoring metric. 

Making the changes requires very little substantive changes to each function, and handling the edge cases is straightforward. This would make the `v_measure_score` much more useful for cases such as those in the Kaggle challenge (clustering of energy deposits of different intensities).

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

A possible alternative is to keep the current functions, and handle weighting by repeating entries according to their weight. However, this is expensive and clunky, and doesn't work for fractional weights.

### Additional context

_No response_

COMMENT:
It'd be nice if you could open a PR so that we could see the diff as well. I think this sounds like a good idea.

Labels: New Feature
Add sample weighting to V Measure Score

### Describe the workflow you want to enable

Many evaluation metrics in sklearn have the ability to weight samples by some measure of importance (usually included as a `sample_weight`). This is also important to do when evaluating clustering. In particular, the `v_measure_score` (and the metrics and functions it relies on), should have this ability.

### Describe your proposed solution

The proposed solution is to amend the `v_measure_score` function, as well as the `entropy`, the `contingency_matrix` and the `mutual_info_score` functions, to include a `sample_weight` input parameter. 

This has been implemented and tested already in [this](https://github.com/wpmccormack/ePIC_Clustering_2023/blob/pip_installable/epic_clustering/scoring/scoring_functions.py) repository, for [this](https://www.kaggle.com/competitions/hgs-hire-power-week-an-epic-competition/overview) Kaggle challenge scoring metric. 

Making the changes requires very little substantive changes to each function, and handling the edge cases is straightforward. This would make the `v_measure_score` much more useful for cases such as those in the Kaggle challenge (clustering of energy deposits of different intensities).

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

A possible alternative is to keep the current functions, and handle weighting by repeating entries according to their weight. However, this is expensive and clunky, and doesn't work for fractional weights.

### Additional context

_No response_

COMMENT:
Hi @adrinjalali, thanks for encouraging this feature. I've made a PR, as linked to this issue. If yourself, or someone else, gets a chance to look it over, I hope it should be a straightforward addition.

Labels: New Feature
Cirrus CI usage limits in the future

In a recent [CirrusCI annoucment](https://cirrus-ci.org/blog/2023/07/17/limiting-free-usage-of-cirrus-ci/) they are limited free usage to 40 compute credits. For reference, we used:

- 214 credits in 05/2023
- 355 credits in 06/2023 (Release month, so there was more wheel building)
- 178 credits in 07/2023

Note that Apple Silicon CPU time is 8 times more expensive than Linux for the same CPU time: [reference](https://cirrus-ci.org/pricing/#compute-credits).

I think we'll likely need to stop running ARM CI on PRs and upload ARM wheels once a week.

COMMENT:
> Note that Apple Silicon GPU time is 8 times more expensive than Linux for the same CPU time

I assume that you mean Aooke Silicon CPU

Labels: Build / CI
Cirrus CI usage limits in the future

In a recent [CirrusCI annoucment](https://cirrus-ci.org/blog/2023/07/17/limiting-free-usage-of-cirrus-ci/) they are limited free usage to 40 compute credits. For reference, we used:

- 214 credits in 05/2023
- 355 credits in 06/2023 (Release month, so there was more wheel building)
- 178 credits in 07/2023

Note that Apple Silicon CPU time is 8 times more expensive than Linux for the same CPU time: [reference](https://cirrus-ci.org/pricing/#compute-credits).

I think we'll likely need to stop running ARM CI on PRs and upload ARM wheels once a week.

COMMENT:
> I assume that you mean Aooke Silicon CPU

Yes, I mean the Apple Silicon CPU. 😅

Labels: Build / CI