Talip7/scikit-learn-issues-multilabel huggingface dataset:
How to solve the AttributeError: 'LabelPowerset' object has no attribute 'classes_'?

When I try to use LabelPowerset in scikit-multilearn, the code runs with GrieSearchCV with an error
```python
from skmultilearn.problem_transform import LabelPowerset
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import make_scorer, hamming_loss
from sklearn.datasets import make_multilabel_classification
X, Y = make_multilabel_classification()
classifier = LabelPowerset(classifier=RandomForestClassifier())
parameters = {
'classifier__n_estimators': [10, 50, 100],
'classifier__max_depth': [None, 5, 10]
}
scorer = make_scorer(hamming_loss, greater_is_better=False)
grid_search = GridSearchCV(classifier, parameters, scoring=scorer, cv=5)
grid_search.fit(X, Y)
``` 
The above code reports an error
```python
Traceback (most recent call last):
  File "/home/zhangkai/.conda/envs/classifier/lib/python3.9/site-packages/sklearn/model_selection/_validation.py", line 813, in _score
    scores = scorer(estimator, X_test, y_test)
  File "/home/zhangkai/.conda/envs/classifier/lib/python3.9/site-packages/sklearn/metrics/_scorer.py", line 266, in __call__
    return self._score(partial(_cached_call, None), estimator, X, y_true, **_kwargs)
  File "/home/zhangkai/.conda/envs/classifier/lib/python3.9/site-packages/sklearn/metrics/_scorer.py", line 353, in _score
    y_pred = method_caller(estimator, "predict", X)
  File "/home/zhangkai/.conda/envs/classifier/lib/python3.9/site-packages/sklearn/metrics/_scorer.py", line 86, in _cached_call
    result, _ = _get_response_values(
  File "/home/zhangkai/.conda/envs/classifier/lib/python3.9/site-packages/sklearn/utils/_response.py", line 74, in _get_response_values
    classes = estimator.classes_
AttributeError: 'LabelPowerset' object has no attribute 'classes
``` 
I tried the example code given on the official website(http://scikit.ml/api/skmultilearn.problem_transform.lp.html#skmultilearn.problem_transform.LabelPowerset) and still reported the same error.

How to solve this problem?

COMMENT:
The problem has been resolved, I have dropped the version of sklearn from 1.3.1 to 1.2.2, and there are no previous errors!

Labels: Needs Triage
Interactive code examples

### Describe the issue linked to the documentation

I think the `scikit-learn` docs would be even better if the code examples were interactive (while still being lighter and more reader-friendly than full-featured notebooks). Then people could change the code and see it reflected in the output and visualizations.

### Suggest a potential alternative/fix

Here is an example of how this can be done: https://codapi.org/try/scikit-learn

If you're interested, I'll be happy to send you a PR to backport this into the docs.

COMMENT:
The discussions about interactive docs are happening here: https://github.com/scikit-learn/scikit-learn/issues/24878

Please add your suggestion there.

Labels: Documentation, Needs Triage
Implement `SplineTransformer.inverse_transform`

### Describe the workflow you want to enable

I think it should be possible to implement a new method `inverse_transform` such that:

```python
import numpy as np
from sklearn.preprocessing import SplineTransformer

rng = np.random.default_rng(0)
X_train = rng.normal(size=(42, 5))
X_test = rng.normal(size=(43, 5))

st = SplineTransformer().fit(X_train)
np.testing.assert_allclose(X_test, st.inverse_transform(st.transform(X_test)))
```

### Describe your proposed solution


There might be several mathematical ways to define such a transform, in particular if when passing a `X_fake_transformed` that contain real numbers that do not actually result from a spline expansion. For instance when:

- `(X_fake_transformed < 0).any()`
- `(X_fake_transformed > 1).any()`
- `X_fake_transformed.sum(axis=1) != np.ones(n_samples)`.

or when all values of a given row are non-zeros at once...

One possible way would be to decode based on `X_fake_transformed.argmax(axis=1)` and then using the relative strength of neighboring spline activations to resolve ambiguities.

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

The main alternative is to not implement this. The main question is probably why try to implement this in the first place?

Possible use cases:

- fit a GMM model on spline transformed data (to get a more axis-aligned inductive prior), generate samples in the GMM latent space and then recode those samples back into the original space.

- fit PCA with a small rank on spline encoded data and then reconstruct back the projected data,

- fit k-means in spline space and recode the learned centroids back in the original feature space for inspection.

- idem for NMF or dictionary learning components.


### Additional context

If #28043 gets merged, missing values support should also be included when using the 'indicator' strategy.

COMMENT:
While I like the interest in splines, I don’t think an inverse spline method is useful in practice, but difficult to implement!

Labels: New Feature, Needs Decision - Include Feature
Make pipeline cache ignore parameter `verbose` of transformers

### Describe the workflow you want to enable

**Introduction**

sklearn's pipeline caches the output of transformers in the pipeline. The caching is based on a hash of the arguments of function `_fit_transform_one`. Unfortunately, the hash changes when **any** of the transformer's parameters change, including those that don't affect the output, for example the `verbose` parameter (there could be other ones, perhaps `copy`?).

It would be a nice feature if there would be a way to indicate to the pipeline (or if the pipeline can detect it automatically) which parameters within the transformers to ignore for caching.

**Use case**

While developing, I tend to always set a high verbosity to understand what's happening under the hood. Once I am content with the results, I turn the verbosity off. At this point, the results are already calculated and cached, but need to be recalculated because the change of parameter.

**Examples of affected transformers**

* ColumnTransformer
* RFE
* RFECV
* SparsePCA
* IterativeImputer


### Describe your proposed solution

The pipeline's caching is performed here:

https://github.com/scikit-learn/scikit-learn/blob/38b39a403179dd67b325dc2fe3da849feda7f557/sklearn/pipeline.py#L392

It uses joblib's [`Memory.cache`](https://joblib.readthedocs.io/en/latest/generated/joblib.Memory.html#joblib.Memory.cache), which accepts an `ignore` parameter to ignore arguments in the hashing, but you can't ignore parameters within one of the arguments (the first argument to `_fit_transform_one` is the transformer and we would like to ignore `verbose` within arg 1).

I couldn't find any trivial solution without monkey patching joblib's code or programmatically changing the `verbose` parameter in the transformers self (which would lead to unexpected results for the user, for example the lack of output messages). Happy to open a PR if anyone can think of a solution.

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

_No response_

### Additional context

Similar to #23788 but presenting a new use case, which as far as I know, can't be resolved now.

COMMENT:
Indeed, we should address this issue. I don't know yet what is the best option here, maybe creating a list of parameter to ignore? Maybe using the tag mechanism?

Labels: Enhancement
Make pipeline cache ignore parameter `verbose` of transformers

### Describe the workflow you want to enable

**Introduction**

sklearn's pipeline caches the output of transformers in the pipeline. The caching is based on a hash of the arguments of function `_fit_transform_one`. Unfortunately, the hash changes when **any** of the transformer's parameters change, including those that don't affect the output, for example the `verbose` parameter (there could be other ones, perhaps `copy`?).

It would be a nice feature if there would be a way to indicate to the pipeline (or if the pipeline can detect it automatically) which parameters within the transformers to ignore for caching.

**Use case**

While developing, I tend to always set a high verbosity to understand what's happening under the hood. Once I am content with the results, I turn the verbosity off. At this point, the results are already calculated and cached, but need to be recalculated because the change of parameter.

**Examples of affected transformers**

* ColumnTransformer
* RFE
* RFECV
* SparsePCA
* IterativeImputer


### Describe your proposed solution

The pipeline's caching is performed here:

https://github.com/scikit-learn/scikit-learn/blob/38b39a403179dd67b325dc2fe3da849feda7f557/sklearn/pipeline.py#L392

It uses joblib's [`Memory.cache`](https://joblib.readthedocs.io/en/latest/generated/joblib.Memory.html#joblib.Memory.cache), which accepts an `ignore` parameter to ignore arguments in the hashing, but you can't ignore parameters within one of the arguments (the first argument to `_fit_transform_one` is the transformer and we would like to ignore `verbose` within arg 1).

I couldn't find any trivial solution without monkey patching joblib's code or programmatically changing the `verbose` parameter in the transformers self (which would lead to unexpected results for the user, for example the lack of output messages). Happy to open a PR if anyone can think of a solution.

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

_No response_

### Additional context

Similar to #23788 but presenting a new use case, which as far as I know, can't be resolved now.

COMMENT:
> maybe creating a list of parameter to ignore

Probably the easiest solution, but how would you tell `Memory.cache` to ignore those parameters within the transformer? They are part of the transformer's hash.

> Maybe using the tag mechanism

Better solution imo, specially since it would allow the creation of custom transformers with custom parameters ignored. But it still presents the issue of how to pass this information to the hashing mechanism.

Labels: Enhancement
Make pipeline cache ignore parameter `verbose` of transformers

### Describe the workflow you want to enable

**Introduction**

sklearn's pipeline caches the output of transformers in the pipeline. The caching is based on a hash of the arguments of function `_fit_transform_one`. Unfortunately, the hash changes when **any** of the transformer's parameters change, including those that don't affect the output, for example the `verbose` parameter (there could be other ones, perhaps `copy`?).

It would be a nice feature if there would be a way to indicate to the pipeline (or if the pipeline can detect it automatically) which parameters within the transformers to ignore for caching.

**Use case**

While developing, I tend to always set a high verbosity to understand what's happening under the hood. Once I am content with the results, I turn the verbosity off. At this point, the results are already calculated and cached, but need to be recalculated because the change of parameter.

**Examples of affected transformers**

* ColumnTransformer
* RFE
* RFECV
* SparsePCA
* IterativeImputer


### Describe your proposed solution

The pipeline's caching is performed here:

https://github.com/scikit-learn/scikit-learn/blob/38b39a403179dd67b325dc2fe3da849feda7f557/sklearn/pipeline.py#L392

It uses joblib's [`Memory.cache`](https://joblib.readthedocs.io/en/latest/generated/joblib.Memory.html#joblib.Memory.cache), which accepts an `ignore` parameter to ignore arguments in the hashing, but you can't ignore parameters within one of the arguments (the first argument to `_fit_transform_one` is the transformer and we would like to ignore `verbose` within arg 1).

I couldn't find any trivial solution without monkey patching joblib's code or programmatically changing the `verbose` parameter in the transformers self (which would lead to unexpected results for the user, for example the lack of output messages). Happy to open a PR if anyone can think of a solution.

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

_No response_

### Additional context

Similar to #23788 but presenting a new use case, which as far as I know, can't be resolved now.

COMMENT:
Maybe a good way for this to work would be for each estimator to be able to declare which of its constructor arguments should be ignored. I think this goes beyond what the `ignore=` argument of joblib's `Memory` provides, because that only concerns itself with the arguments of the function it is caching, while we want to ignore "arguments to an argument of the function". Maybe `cache_validation_callback=` can help us out, because if not we might be out of luck :-/

Labels: Enhancement
Multiclass support in precision_recall_curve

### Describe the workflow you want to enable

i would like to add multiclass support to precision_recall_curve.

### Describe your proposed solution

- Add check in the beginning to check if multiclass or binary
- Add weighting argument for `micro`, `macro`, `weighted`
- Implement _multiclass_clf_curve

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

_No response_

### Additional context

I can implement the functionality, but I would like to hear any comments before starting

COMMENT:
y_true would be a label array (num_samples, ) or one hot matrix (num_samples, num_classes)
y_pred would be matrix of scores (num_samples, num_classes)

Labels: New Feature
Multiclass support in precision_recall_curve

### Describe the workflow you want to enable

i would like to add multiclass support to precision_recall_curve.

### Describe your proposed solution

- Add check in the beginning to check if multiclass or binary
- Add weighting argument for `micro`, `macro`, `weighted`
- Implement _multiclass_clf_curve

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

_No response_

### Additional context

I can implement the functionality, but I would like to hear any comments before starting

COMMENT:
I think that we should be extending the scope to the ROC curve as well. An example where we do compute the different averages or handle multiclass is this example: https://scikit-learn.org/stable/auto_examples/model_selection/plot_roc.html#sphx-glr-auto-examples-model-selection-plot-roc-py

This would be good to have a simpler API to achieve the same results.

Labels: New Feature
Multiclass support in precision_recall_curve

### Describe the workflow you want to enable

i would like to add multiclass support to precision_recall_curve.

### Describe your proposed solution

- Add check in the beginning to check if multiclass or binary
- Add weighting argument for `micro`, `macro`, `weighted`
- Implement _multiclass_clf_curve

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

_No response_

### Additional context

I can implement the functionality, but I would like to hear any comments before starting

COMMENT:
Without a scientific / statistical justification (e.g. literature), I'm hesitant to add such aggregations because, to me, it is not clear what such aggregations produce and how to interprete them. So my opposite proposal is to remove that part from the examples.

Labels: New Feature
Multiclass support in precision_recall_curve

### Describe the workflow you want to enable

i would like to add multiclass support to precision_recall_curve.

### Describe your proposed solution

- Add check in the beginning to check if multiclass or binary
- Add weighting argument for `micro`, `macro`, `weighted`
- Implement _multiclass_clf_curve

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

_No response_

### Additional context

I can implement the functionality, but I would like to hear any comments before starting

COMMENT:
Hi! I have a PR for this feature now, all tests passing etc! Sounds good to include for ROC curve in the future, although I limited the scope of this particular PR to PR (!) only :)

Labels: New Feature
Localization of scikit-learn website content.

Hi,

I work for Quansight Labs and am helping set things up for translation of main project website content for core projects in the Scientific Python ecosystem. This work is supported by the [Scientific Python Community & Communications Infrastructure grant](https://scientific-python.org/doc/scientific-python-community-and-communications-infrastructure-2022.pdf) from CZI. I created a Github discussion for this here: https://github.com/scikit-learn/scikit-learn/discussions/28105, but @glemaitre pointed out that an issue would be more appropriate.

A deliverable for this grant is to have the brochure websites of at least 8 of the 10 Scientific Python core projects translated into at least 3 commonly used languages. You may have seen the language drop-down selector at https://numpy.org/.  The goal is for a cross functional team of Quansight staff and volunteers to handle the bulk of the work, taking the burden off of project maintainers.

The localization management platform [Crowdin](https://crowdin.com/) is offering a free supported enterprise organization for Scientific Python translations. This is the platform we used for numpy.org. At this moment you would not need to decide what if anything you would do with translated content. *However, to get things started, I'd like to ask permission to fill out the [Crowdin Open Source Project Setup Request ](https://crowdin.com/page/open-source-project-setup-request) form on your behalf, to allow me to add a project to the Scientific Python Crowdin organization for Scikit-Learn.* 

For those interested. Here are the specifics of what I'd do with this.

- Create a GitHub repository which mirrors the content from the Scikit-Learn brochure website.
- Setup a cron github action which polls for updates to the Scikit-Learn website content and helps keep the mirror up to date.
- Sync this repository to the Scikit-Learn Crowdin project. Translate can then translate the content, and Crowdin will automatically push commits to a PR against the repository mirroring the website content.

The end product will be a repository with parallel versions of the website content in a variety of languages which is kept up to date. If you want to host the translations on your webpage like NumPy does, myself and/or a colleague from Quansight would be supported by the grant to help make that happen.

Please let me know if you have any questions.

COMMENT:
This [numpy wiki page](https://github.com/numpy/numpy/wiki/Translations-of-the-NumPy-website) and [NEP 28](https://numpy.org/neps/nep-0028-website-redesign.html#translation-multilingual-i18n) might provide some more context.

Labels: Needs Decision
Localization of scikit-learn website content.

Hi,

I work for Quansight Labs and am helping set things up for translation of main project website content for core projects in the Scientific Python ecosystem. This work is supported by the [Scientific Python Community & Communications Infrastructure grant](https://scientific-python.org/doc/scientific-python-community-and-communications-infrastructure-2022.pdf) from CZI. I created a Github discussion for this here: https://github.com/scikit-learn/scikit-learn/discussions/28105, but @glemaitre pointed out that an issue would be more appropriate.

A deliverable for this grant is to have the brochure websites of at least 8 of the 10 Scientific Python core projects translated into at least 3 commonly used languages. You may have seen the language drop-down selector at https://numpy.org/.  The goal is for a cross functional team of Quansight staff and volunteers to handle the bulk of the work, taking the burden off of project maintainers.

The localization management platform [Crowdin](https://crowdin.com/) is offering a free supported enterprise organization for Scientific Python translations. This is the platform we used for numpy.org. At this moment you would not need to decide what if anything you would do with translated content. *However, to get things started, I'd like to ask permission to fill out the [Crowdin Open Source Project Setup Request ](https://crowdin.com/page/open-source-project-setup-request) form on your behalf, to allow me to add a project to the Scientific Python Crowdin organization for Scikit-Learn.* 

For those interested. Here are the specifics of what I'd do with this.

- Create a GitHub repository which mirrors the content from the Scikit-Learn brochure website.
- Setup a cron github action which polls for updates to the Scikit-Learn website content and helps keep the mirror up to date.
- Sync this repository to the Scikit-Learn Crowdin project. Translate can then translate the content, and Crowdin will automatically push commits to a PR against the repository mirroring the website content.

The end product will be a repository with parallel versions of the website content in a variety of languages which is kept up to date. If you want to host the translations on your webpage like NumPy does, myself and/or a colleague from Quansight would be supported by the grant to help make that happen.

Please let me know if you have any questions.

COMMENT:
@Charlie-XIAO what would be the workload / process like on our side to make this happen?

Note that this is how things have worked in the past:
https://scikit-learn.org/stable/related_projects.html#translations-of-scikit-learn-documentation

We haven't maintained them in any way, and they're completely independent.

Labels: Needs Decision