Talip7/scikit-learn-issues-multilabel huggingface dataset:
ModuleNotFoundError: No module named 'sklearn.ensemble._bagging'

### Describe the bug

ModuleNotFoundError: No module named 'sklearn.ensemble._bagging'
 Above error i am gettting  while using python3.7 . Please provide me with the right version of scikit-learn .Here i am using scikit-learn =0.21.3

### Steps/Code to Reproduce

 File "app.py", line 23, in <module>
    from speakerDiarization import dia,label
  File "/home/jrspy/Voice-Sentiment-Analysis-20220617T123339Z-001/Voice-Sentiment-Analysis/speakerDiarization.py", line 4, in <module>
    from filter import main_file,main
  File "/home/jrspy/Voice-Sentiment-Analysis-20220617T123339Z-001/Voice-Sentiment-Analysis/filter.py", line 35, in <module>
    model_emotion = pickle.load(modelObj)
ModuleNotFoundError: No module named 'sklearn.ensemble._bagging'


### Expected Results

No error is thrown

### Actual Results

no error needs to be there

### Versions

```shell
i am currently using 0.21.3 version of scikit-learn
```

COMMENT:
Python 3.7 is no longer supported, and 0.21.3 is a very old version. We no longer support it.

Labels: Bug, Needs Triage
⚠️ CI failed on macOS.pylatest_conda_forge_mkl ⚠️

**CI is still failing on [macOS.pylatest_conda_forge_mkl](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=55585&view=logs&j=97641769-79fb-5590-9088-a30ce9b850b9)** (Jun 05, 2023)
- test_fastica_simple[9-float32-True]
- test_fastica_simple[9-float32-False]

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=55657&view=logs&j=97641769-79fb-5590-9088-a30ce9b850b9) on Jun 08, 2023

Labels: Needs Triage
⚠️ CI failed on Linux_Runs.pylatest_conda_forge_mkl ⚠️

**CI is still failing on [Linux_Runs.pylatest_conda_forge_mkl](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=55657&view=logs&j=dde5042c-7464-5d47-9507-31bdd2ee0a3a)** (Jun 08, 2023)
- test_fastica_simple[41-float32-False]

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=55614&view=logs&j=dde5042c-7464-5d47-9507-31bdd2ee0a3a) on Jun 07, 2023

Labels: Needs Triage
⚠️ CI failed on linux_arm64_wheel ⚠️

**CI failed on [linux_arm64_wheel](https://cirrus-ci.com/build/4727305860284416)** (Jun 03, 2023)

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://cirrus-ci.com/build/5851815137247232) on Jun 04, 2023

Labels: Needs Triage
⚠️ CI failed on linux_arm64_wheel ⚠️

**CI failed on [linux_arm64_wheel](https://cirrus-ci.com/build/4727305860284416)** (Jun 03, 2023)

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://cirrus-ci.com/build/4727305860284416) on Jun 03, 2023

Labels: Needs Triage
Return training loss from LogisticRegression

### Describe the workflow you want to enable

Currently there seems to be no way to retrieve the loss (or change in loss) when training a logistic regression model (`sklearn.linear_model.LogisticRegression`). If one changes the verbosity then this can be seen from the terminal, but also cannot be retrieved from stdout. This makes it unfeasible to actually plot training curves from logistic regression models. 

### Describe your proposed solution

Add `train_loss` as an attribute, same as e.g. `classes_` or `n_features_in_`.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

_No response_

COMMENT:
Hi @rachrapp could you check out this link [here](https://stackoverflow.com/questions/44443479/python-sklearn-show-loss-values-during-training). Seems like you need to define a custom wrapper around it.

Labels: New Feature, module:linear_model
Return training loss from LogisticRegression

### Describe the workflow you want to enable

Currently there seems to be no way to retrieve the loss (or change in loss) when training a logistic regression model (`sklearn.linear_model.LogisticRegression`). If one changes the verbosity then this can be seen from the terminal, but also cannot be retrieved from stdout. This makes it unfeasible to actually plot training curves from logistic regression models. 

### Describe your proposed solution

Add `train_loss` as an attribute, same as e.g. `classes_` or `n_features_in_`.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

_No response_

COMMENT:
Thanks @Abhinavfreecodecamp. While this workaround does work for the `SGDClassifier` class, it unfortunately does not work for `LogisticRegression`.

Labels: New Feature, module:linear_model
Return training loss from LogisticRegression

### Describe the workflow you want to enable

Currently there seems to be no way to retrieve the loss (or change in loss) when training a logistic regression model (`sklearn.linear_model.LogisticRegression`). If one changes the verbosity then this can be seen from the terminal, but also cannot be retrieved from stdout. This makes it unfeasible to actually plot training curves from logistic regression models. 

### Describe your proposed solution

Add `train_loss` as an attribute, same as e.g. `classes_` or `n_features_in_`.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

_No response_

COMMENT:
This is the kind of feature that will be possible when we have a callback API (https://github.com/scikit-learn/scikit-learn/pull/22000), which is still work in progress.

Labels: New Feature, module:linear_model
Rename percentiles to quantile_levels in partial_dependence

`partial_dependence` and `PartialDependenceDisplay` have a parameter `percentiles` with range (0, 1). It should be either have range (0, 100) or be named `quantiles`.

This issue proposes to rename `percentiles` to ~~`quantiles`~~ `quantile_levels`.

This is a similar proposal as in #26090.

COMMENT:
Is this worth the disruption of a deprecation?

Labels: API, Needs Decision, module:inspection
Rename percentiles to quantile_levels in partial_dependence

`partial_dependence` and `PartialDependenceDisplay` have a parameter `percentiles` with range (0, 1). It should be either have range (0, 100) or be named `quantiles`.

This issue proposes to rename `percentiles` to ~~`quantiles`~~ `quantile_levels`.

This is a similar proposal as in #26090.

COMMENT:
> Is this worth the disruption of a deprecation?

+1. For me, it is.
Even better, it should be named `quantile_levels`.

Labels: API, Needs Decision, module:inspection
Rename percentiles to quantile_levels in partial_dependence

`partial_dependence` and `PartialDependenceDisplay` have a parameter `percentiles` with range (0, 1). It should be either have range (0, 100) or be named `quantiles`.

This issue proposes to rename `percentiles` to ~~`quantiles`~~ `quantile_levels`.

This is a similar proposal as in #26090.

COMMENT:
If unresolved, I'll make these changes

Labels: API, Needs Decision, module:inspection
Rename percentiles to quantile_levels in partial_dependence

`partial_dependence` and `PartialDependenceDisplay` have a parameter `percentiles` with range (0, 1). It should be either have range (0, 100) or be named `quantiles`.

This issue proposes to rename `percentiles` to ~~`quantiles`~~ `quantile_levels`.

This is a similar proposal as in #26090.

COMMENT:
@aidangold It is not decided yet whether we want to make this change or not => see label "Needs Decision".

Labels: API, Needs Decision, module:inspection
Run common test for SparseCoder and FeatureUnion

Currently, the `SparseCoder` estimator is not tested by our common test because it requires a `dictionary` parameter.

We should make sure to construct the instance in `_construct_instance` and check that the estimator runs the test. I am almost sure that it is missing the `"stateless"` tag and the parameter validation.

COMMENT:
/take

Labels: Enhancement, Moderate, help wanted, module:decomposition, module:test-suite
Run common test for SparseCoder and FeatureUnion

Currently, the `SparseCoder` estimator is not tested by our common test because it requires a `dictionary` parameter.

We should make sure to construct the instance in `_construct_instance` and check that the estimator runs the test. I am almost sure that it is missing the `"stateless"` tag and the parameter validation.

COMMENT:
We have the same issue with `FeatureUnion` because it requires a ``transformer_list``

Labels: Enhancement, Moderate, help wanted, module:decomposition, module:test-suite
Run common test for SparseCoder and FeatureUnion

Currently, the `SparseCoder` estimator is not tested by our common test because it requires a `dictionary` parameter.

We should make sure to construct the instance in `_construct_instance` and check that the estimator runs the test. I am almost sure that it is missing the `"stateless"` tag and the parameter validation.

COMMENT:
Will work on `Feature Union`

Labels: Enhancement, Moderate, help wanted, module:decomposition, module:test-suite
Run common test for SparseCoder and FeatureUnion

Currently, the `SparseCoder` estimator is not tested by our common test because it requires a `dictionary` parameter.

We should make sure to construct the instance in `_construct_instance` and check that the estimator runs the test. I am almost sure that it is missing the `"stateless"` tag and the parameter validation.

COMMENT:
FeatureUnion is tested in the common tests since https://github.com/scikit-learn/scikit-learn/pull/29707.
SparseCoder is tested in the common tests since #32077.
Let's close this issue

Labels: Enhancement, Moderate, help wanted, module:decomposition, module:test-suite
Conflict assigning unique session to joblib processes in GridSearchCV

### Describe the bug

Kernel is freezing when `n_jobs` is not `None` and a wrong parameter is passed to an estimator inside a grid/random search.
VSCode raises an error, but jupyter notebooks just appear to be running thought they are not.

### Steps/Code to Reproduce

```python
from sklearn.datasets import load_iris
from sklearn.model_selection import GridSearchCV
from sklearn.linear_model import LogisticRegression

X, y = load_iris(return_X_y=True)
parameters = {"n_estimators": [1, 10]}
clf = LogisticRegression()
grid_search = GridSearchCV(clf, parameters, n_jobs=2)
grid_search.fit(X, y)
```

### Expected Results

```python-traceback
ValueError: Invalid parameter 'n_estimators' for estimator LogisticRegression(). Valid parameters are: ['C', 'class_weight', 'dual', 'fit_intercept', 'intercept_scaling', 'l1_ratio', 'max_iter', 'multi_class', 'n_jobs', 'penalty', 'random_state', 'solver', 'tol', 'verbose', 'warm_start'].
```

### Actual Results

```python-traceback
ERROR! Session/line number was not unique in database. History logging moved to new session <XXXX>
```

### Versions

```shell
System:
    python: 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:41:03)  [GCC 9.4.0]
executable: /home/arturoamor/miniforge3/envs/dev-scikit-learn/bin/python
   machine: Linux-5.14.0-1059-oem-x86_64-with-glibc2.31

Python dependencies:
      sklearn: 1.3.dev0
          pip: 22.3.1
   setuptools: 65.5.1
        numpy: 1.22.1
        scipy: 1.7.3
       Cython: 0.29.33
       pandas: 2.0.1
   matplotlib: 3.7.1
       joblib: 1.2.0
threadpoolctl: 3.0.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /home/arturoamor/miniforge3/envs/dev-scikit-learn/lib/python3.9/site-packages/numpy.libs/libopenblas64_p-r0-2f7c42d4.3.18.so
        version: 0.3.18
threading_layer: pthreads
   architecture: SkylakeX
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /home/arturoamor/miniforge3/envs/dev-scikit-learn/lib/python3.9/site-packages/scipy.libs/libopenblasp-r0-8b9e111f.3.17.so
        version: 0.3.17
threading_layer: pthreads
   architecture: SkylakeX
    num_threads: 8

       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /home/arturoamor/miniforge3/envs/dev-scikit-learn/lib/libgomp.so.1.0.0
        version: None
    num_threads: 8
```

COMMENT:
Pinging @jeremiedbb on this one :)

Labels: Bug
Conflict assigning unique session to joblib processes in GridSearchCV

### Describe the bug

Kernel is freezing when `n_jobs` is not `None` and a wrong parameter is passed to an estimator inside a grid/random search.
VSCode raises an error, but jupyter notebooks just appear to be running thought they are not.

### Steps/Code to Reproduce

```python
from sklearn.datasets import load_iris
from sklearn.model_selection import GridSearchCV
from sklearn.linear_model import LogisticRegression

X, y = load_iris(return_X_y=True)
parameters = {"n_estimators": [1, 10]}
clf = LogisticRegression()
grid_search = GridSearchCV(clf, parameters, n_jobs=2)
grid_search.fit(X, y)
```

### Expected Results

```python-traceback
ValueError: Invalid parameter 'n_estimators' for estimator LogisticRegression(). Valid parameters are: ['C', 'class_weight', 'dual', 'fit_intercept', 'intercept_scaling', 'l1_ratio', 'max_iter', 'multi_class', 'n_jobs', 'penalty', 'random_state', 'solver', 'tol', 'verbose', 'warm_start'].
```

### Actual Results

```python-traceback
ERROR! Session/line number was not unique in database. History logging moved to new session <XXXX>
```

### Versions

```shell
System:
    python: 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:41:03)  [GCC 9.4.0]
executable: /home/arturoamor/miniforge3/envs/dev-scikit-learn/bin/python
   machine: Linux-5.14.0-1059-oem-x86_64-with-glibc2.31

Python dependencies:
      sklearn: 1.3.dev0
          pip: 22.3.1
   setuptools: 65.5.1
        numpy: 1.22.1
        scipy: 1.7.3
       Cython: 0.29.33
       pandas: 2.0.1
   matplotlib: 3.7.1
       joblib: 1.2.0
threadpoolctl: 3.0.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /home/arturoamor/miniforge3/envs/dev-scikit-learn/lib/python3.9/site-packages/numpy.libs/libopenblas64_p-r0-2f7c42d4.3.18.so
        version: 0.3.18
threading_layer: pthreads
   architecture: SkylakeX
    num_threads: 8

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /home/arturoamor/miniforge3/envs/dev-scikit-learn/lib/python3.9/site-packages/scipy.libs/libopenblasp-r0-8b9e111f.3.17.so
        version: 0.3.17
threading_layer: pthreads
   architecture: SkylakeX
    num_threads: 8

       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /home/arturoamor/miniforge3/envs/dev-scikit-learn/lib/libgomp.so.1.0.0
        version: None
    num_threads: 8
```

COMMENT:
We checked with @ArturoAmorQ and more recent versions of jupyter behave as expected. There's nothing we can do on our side. If someone faces the same issue, the solution seems to just upgrade jupyter.

Labels: Bug
Pandas set_output Development and Customer Transformers Best Practice

### Describe the issue linked to the documentation

The set_output feature is amazing. However, many of my pipelines have sklearn style custom transformers. It would be really useful to have some best practices on how to write custom transformer objects so that they maintain the functionality of the set_output API.

The closest I have found is this: https://stackoverflow.com/questions/75026592/how-to-create-pandas-output-for-custom-transformers, but while an excellent answer on stackoverflow, it would be great to see some offical best practices on it. I think it would be a really useful for more advanced pipelines.

Many thanks. Awesome work 🚀 

### Suggest a potential alternative/fix

_No response_

COMMENT:
Is this documentation page not enough?

https://scikit-learn.org/dev/developers/develop.html#developer-api-for-set-output

Labels: Documentation, Pandas compatibility
Pandas set_output Development and Customer Transformers Best Practice

### Describe the issue linked to the documentation

The set_output feature is amazing. However, many of my pipelines have sklearn style custom transformers. It would be really useful to have some best practices on how to write custom transformer objects so that they maintain the functionality of the set_output API.

The closest I have found is this: https://stackoverflow.com/questions/75026592/how-to-create-pandas-output-for-custom-transformers, but while an excellent answer on stackoverflow, it would be great to see some offical best practices on it. I think it would be a really useful for more advanced pipelines.

Many thanks. Awesome work 🚀 

### Suggest a potential alternative/fix

_No response_

COMMENT:
I agree with Josh, set_output has been a game changer. However, as far as I can tell, the docs have little detail as to what the output column names will be, even for canonical transformers such as [ColumnTransformer](https://scikit-learn.org/stable/modules/generated/sklearn.compose.ColumnTransformer.html#sklearn.compose.ColumnTransformer.set_output).

Labels: Documentation, Pandas compatibility
Pandas set_output Development and Customer Transformers Best Practice

### Describe the issue linked to the documentation

The set_output feature is amazing. However, many of my pipelines have sklearn style custom transformers. It would be really useful to have some best practices on how to write custom transformer objects so that they maintain the functionality of the set_output API.

The closest I have found is this: https://stackoverflow.com/questions/75026592/how-to-create-pandas-output-for-custom-transformers, but while an excellent answer on stackoverflow, it would be great to see some offical best practices on it. I think it would be a really useful for more advanced pipelines.

Many thanks. Awesome work 🚀 

### Suggest a potential alternative/fix

_No response_

COMMENT:
@glemaitre - I hadn't seen this. This is helpful but could be improved.

1) It gives and example of what to do if you don't want the behaviour. However, I think it would be really useful having a minimal working custom transformer example showing column names with outputs.

2) I think this has a typo:

> The set_output API is automatically defined if the transformer defines [get_feature_names_out](https://scikit-learn.org/dev/glossary.html#term-get_feature_names_out) and subclasses [base.TransformerMixin](https://scikit-learn.org/dev/modules/generated/sklearn.base.TransformerMixin.html#sklearn.base.TransformerMixin). [get_feature_names_out](https://scikit-learn.org/dev/glossary.html#term-get_feature_names_out) is used to get the column names of pandas output.

I'm still not super clear on what it it is trying to say but I think it could be:
> The set_output API is automatically defined if the transformer defines [get_feature_names_out](https://scikit-learn.org/dev/glossary.html#term-get_feature_names_out). The **subclass'** [base.TransformerMixin](https://scikit-learn.org/dev/modules/generated/sklearn.base.TransformerMixin.html#sklearn.base.TransformerMixin).[get_feature_names_out](https://scikit-learn.org/dev/glossary.html#term-get_feature_names_out) is used to get the column names of pandas output.

Better still,

> The set_output API is automatically defined if the transformer defines [get_feature_names_out](https://scikit-learn.org/dev/glossary.html#term-get_feature_names_out). The [base.TransformerMixin](https://scikit-learn.org/dev/modules/generated/sklearn.base.TransformerMixin.html#sklearn.base.TransformerMixin) subclass uses its [get_feature_names_out](https://scikit-learn.org/dev/glossary.html#term-get_feature_names_out) method to get the column names of pandas output.

NB: Above the AND sounds like you need to do two things to set this up. Further, if I understand this correctly, the subclass owns/possesses the get_feature_names_out method. Above it suggests there are multiple subclasses.

Labels: Documentation, Pandas compatibility
Pandas set_output Development and Customer Transformers Best Practice

### Describe the issue linked to the documentation

The set_output feature is amazing. However, many of my pipelines have sklearn style custom transformers. It would be really useful to have some best practices on how to write custom transformer objects so that they maintain the functionality of the set_output API.

The closest I have found is this: https://stackoverflow.com/questions/75026592/how-to-create-pandas-output-for-custom-transformers, but while an excellent answer on stackoverflow, it would be great to see some offical best practices on it. I think it would be a really useful for more advanced pipelines.

Many thanks. Awesome work 🚀 

### Suggest a potential alternative/fix

_No response_

COMMENT:
After having reread the discussion it looks like the main improvement would be to add an example of a custom transformer that is able to use `set_output`.

Something like this (maybe too much of a toy too simple) seems to work:
```py
class MyTranformer(TransformerMixin):
     def get_feature_names_out(self, input_features=None):
         return ['a', 'b']
     def fit(self, X):
         return self
     def transform(self, X):
         return np.array([[1, 2]])

transformer = MyTranformer().set_output(transform="pandas")

transformer.fit_transform([[1, 2, 3]])
```

About the wording comments, I think the current wording is accurate (but always improvable), you need to do two things:
- inherit from `TransformerMixin`
- implement `get_feature_names_out`

Labels: Documentation, Pandas compatibility
Haversine distance documentation

### Describe the issue linked to the documentation

I would like to propose to update misleading formula for haversine distance:
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.haversine_distances.html

It is not clear from the page if (x1, y1) is the first vector or (x1, x2). Thus it might be misleading how to read x1, y1, x2, y2. 

```
    .. math::
       D(x, y) = 2\\arcsin[\\sqrt{\\sin^2((x1 - y1) / 2)
                                + \\cos(x1)\\cos(y1)\\sin^2((x2 - y2) / 2)}]
```

### Suggest a potential alternative/fix

```
    .. math::
       D(x, y) = 2\\arcsin[\\sqrt{\\sin^2((x_lat - y_lat) / 2)
                                + \\cos(x_lat)\\cos(y_lat)\\sin^2((x_lon - y_lon) / 2)}]
```

COMMENT:
Thank you for the issue! I'll be happy with a PR that clarifies the docstring.

Labels: Documentation, help wanted, module:metrics
Haversine distance documentation

### Describe the issue linked to the documentation

I would like to propose to update misleading formula for haversine distance:
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.haversine_distances.html

It is not clear from the page if (x1, y1) is the first vector or (x1, x2). Thus it might be misleading how to read x1, y1, x2, y2. 

```
    .. math::
       D(x, y) = 2\\arcsin[\\sqrt{\\sin^2((x1 - y1) / 2)
                                + \\cos(x1)\\cos(y1)\\sin^2((x2 - y2) / 2)}]
```

### Suggest a potential alternative/fix

```
    .. math::
       D(x, y) = 2\\arcsin[\\sqrt{\\sin^2((x_lat - y_lat) / 2)
                                + \\cos(x_lat)\\cos(y_lat)\\sin^2((x_lon - y_lon) / 2)}]
```

COMMENT:
Working on this.

Labels: Documentation, help wanted, module:metrics
Reference of partial_fit of MLP

### Describe the issue linked to the documentation

In MLPClassifier model, I can not find reference about partial_fit() function. Could you add the reference into the document that where this function comes from or just a progress by yourself?

### Suggest a potential alternative/fix

You could add the reference in your official document about how the partial_fit() function works.

COMMENT:
`partial_fit` is documented in the API docs. I don't think we need to add more docs. If you have a concrete idea, happy to review a PR about it.

Labels: Documentation, Needs Triage