Talip7/scikit-learn-issues-multilabel huggingface dataset:
_SetOutputMixin changes default order of inheritance

### Describe the bug

Inheriting from `TransformerMixin` now implicitly adds the wrapped `transform` method of superclass to subclasses and as a consequence can change the order in which multiple inheritance is resolved. 
This is caused by the `_SetOutputMixin.__init_subclass__`. 
I don't know if this is documented somewhere but it seems to me like a very tricky behavior that can cause a lot of headache to debug. 

### Steps/Code to Reproduce

```python
from sklearn.base import TransformerMixin

class Base(TransformerMixin):
    def transform(self, X):
        print('Base')

class A(Base):
    pass

class B(Base):
    def transform(self, X):
        print('B')

class C(A, B):
    pass


C().transform(None)
```

### Expected Results

code will print `B`

### Actual Results

code prints `Base`

### Versions

```shell
System:
    python: 3.8.15 | packaged by conda-forge | (default, Nov 22 2022, 08:42:03) [MSC v.1929 64 bit (AMD64)]
executable: C:\Users\Josef.ondrej\Anaconda3\envs\example\python.exe
   machine: Windows-10-10.0.19045-SP0

Python dependencies:
      sklearn: 1.2.0
          pip: 22.3.1
   setuptools: 65.6.3
        numpy: 1.24.1
        scipy: 1.10.0
       Cython: None
       pandas: 1.5.2
   matplotlib: None
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: mkl
         prefix: libblas
       filepath: C:\Users\Josef.ondrej\Anaconda3\envs\example\Library\bin\libblas.dll
        version: 2022.1-Product
threading_layer: intel
    num_threads: 6

       user_api: openmp
   internal_api: openmp
         prefix: vcomp
       filepath: C:\Users\Josef.ondrej\Anaconda3\envs\example\vcomp140.dll
        version: None
    num_threads: 12
```

COMMENT:
Uhm actually, the problematic one could be the `setattr(cls, method, wrapped_method)` that does not do what we expect.

Labels: Bug
get_feature_names_out not working on periodic SplineTransformers

### Describe the bug

When using a SplineTransformer with argument `extrapolation="periodic"` there seems to be a disagreement with the number of columns of the transformed features and the names returned by `get_feature_names_out`

### Steps/Code to Reproduce

```
import pandas as pd
import numpy as np
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import SplineTransformer

period = 30
n_knots = 5
degree = 3
X = pd.DataFrame({"month_day": np.arange(0, period + 1, 1)})

preprocessor = ColumnTransformer(
    transformers=[
        (
            "cyclic",
            SplineTransformer(
                knots=np.linspace(0, period, n_knots)[:, None],
                extrapolation="periodic",
                degree=degree,
                include_bias=True,
            ),
            ["month_day"],
        )
    ]
)

x_transformed = preprocessor.fit_transform(X)
print(x_transformed.shape[1])  # gives 4
print(preprocessor.named_transformers_["cyclic"].n_features_out_)  # gives 4
print(len(preprocessor.get_feature_names_out()))  # gives 7

result = x_transformed.shape[1] == len(preprocessor.get_feature_names_out())

```

### Expected Results

Expected that `x_transformed.shape[1] == len(preprocessor.get_feature_names_out())`

### Actual Results

`x_transformed.shape[1]` is 4
`len(preprocessor.get_feature_names_out())`is 7

### Versions

```shell
System:
    python: 3.10.6 (main, Sep 27 2022, 10:03:10) [Clang 14.0.0 (clang-1400.0.29.102)]
   machine: macOS-13.0.1-arm64-arm-64bit

Python dependencies:
      sklearn: 1.2.0
          pip: 22.2.2
   setuptools: 59.8.0
        numpy: 1.23.5
        scipy: 1.9.3
       Cython: None
       pandas: 1.5.2
   matplotlib: 3.6.2
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True
```

COMMENT:
Thank you for reporting this bug. I agree this is a bug and opened https://github.com/scikit-learn/scikit-learn/pull/25296 to fix it.

Labels: Bug, module:preprocessing
get_feature_names_out not working on periodic SplineTransformers

### Describe the bug

When using a SplineTransformer with argument `extrapolation="periodic"` there seems to be a disagreement with the number of columns of the transformed features and the names returned by `get_feature_names_out`

### Steps/Code to Reproduce

```
import pandas as pd
import numpy as np
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import SplineTransformer

period = 30
n_knots = 5
degree = 3
X = pd.DataFrame({"month_day": np.arange(0, period + 1, 1)})

preprocessor = ColumnTransformer(
    transformers=[
        (
            "cyclic",
            SplineTransformer(
                knots=np.linspace(0, period, n_knots)[:, None],
                extrapolation="periodic",
                degree=degree,
                include_bias=True,
            ),
            ["month_day"],
        )
    ]
)

x_transformed = preprocessor.fit_transform(X)
print(x_transformed.shape[1])  # gives 4
print(preprocessor.named_transformers_["cyclic"].n_features_out_)  # gives 4
print(len(preprocessor.get_feature_names_out()))  # gives 7

result = x_transformed.shape[1] == len(preprocessor.get_feature_names_out())

```

### Expected Results

Expected that `x_transformed.shape[1] == len(preprocessor.get_feature_names_out())`

### Actual Results

`x_transformed.shape[1]` is 4
`len(preprocessor.get_feature_names_out())`is 7

### Versions

```shell
System:
    python: 3.10.6 (main, Sep 27 2022, 10:03:10) [Clang 14.0.0 (clang-1400.0.29.102)]
   machine: macOS-13.0.1-arm64-arm-64bit

Python dependencies:
      sklearn: 1.2.0
          pip: 22.2.2
   setuptools: 59.8.0
        numpy: 1.23.5
        scipy: 1.9.3
       Cython: None
       pandas: 1.5.2
   matplotlib: 3.6.2
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True
```

COMMENT:
Hello,  
I think the ```n_splines = self.bsplines_[0].c.shape[0]``` in ```get_feature_names_out```  
should be replaced by  
```n_splines = self.bsplines_[0].c.shape[1]```

Labels: Bug, module:preprocessing
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
Not sure how much it matters, but there is also this effect:

```python
>>> loaded.__sklearn_pickle_version__
'1.3.dev0'
>>> clone(loaded).__sklearn_pickle_version__
AttributeError: 'LogisticRegression' object has no attribute '__sklearn_pickle_version__'
```

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
Indeed, both aspects are an issue (cloning and equality check).

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
I am wondering if we should first revert #22094 since the design would be different and would probably require some additional discussion.

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
I open https://github.com/scikit-learn/scikit-learn/pull/25279 in case that we want to start by this step.

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
Revert and a PR with a new design would make sense to me.

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
I was looking a bit at the issue. Since `__init__` is not defined in `BaseEstimator`, `super().__init__` is not forced to be called by the estimator inheriting from it.

I am wondering if `__new__` would do the trick. I drafted https://github.com/scikit-learn/scikit-learn/pull/25280 in this regard.

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
> I was looking a bit at the issue. Since __init__ is not defined in BaseEstimator, super().__init__ is not forced to be called by the estimator inheriting from it.

Since this is a scikit-learn only thing, we can check it in our common tests without asking third party libraries to to do the same. So if they do not call the super constructor, this should not break there code.

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
> I am worried about the unexpected complexity that might stem from the use of metaclasses in our code base.

I think using `__new__` doesn't mean we are using metaclasses. Or put differently, we can use `__new__` without having a metaclass. But, I think `__new__` isn't something that is used a lot (as in there isn't a lot of code that defines a `__new__`) so I also wonder what kind of complexity this adds. However, I can't think of any.

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
Yes I deleted my comment, because I realised that `__new__` alone would not introduce as much complexity as using real metaclasses.

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
> But, I think __new__ isn't something that is used a lot (as in there isn't a lot of code that defines a __new__) so I also wonder what kind of complexity this adds. However, I can't think of any.

It is discouraged because usually there is a simpler and more explicit way instead (e.g. factory function). Here, this is to bypass the limitation of not calling `super().__init__(self)`. But if there is a simpler way that I did not think about, I am taking it :)

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
Sorry to post on this old issue, but it seems the initial error reported by @adrinjalali started occurring again. I just installed sklearn nightly and can reproduce the issue. The regression has to be rather recent, since the skops tests (which indirectly test this) used to pass just a few days ago.

**Edit**: What's strange is that the code related to `__sklearn_pickle_version__` is not found on the `main` branch of sklearn. Is it somehow possible that the nightly build is outdated? This is how sklearn nightly was installed:

`python -m pip install --pre --extra-index https://pypi.anaconda.org/scipy-wheels-nightly/simple scikit-learn`

**Edit2**: I tried again today (with updated sklearn nightly) and now the error is gone.

**Edit3**: Strangely enough, error still occurs on skops [CI](https://github.com/skops-dev/skops/actions/runs/5387718929/jobs/9779408304) (it's not obvious from the error message but it is indeed the same error cause). It only happens with `TfidfTransformer` and `TfidfVectorizer`.

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
FYI, the nightly builds have moved from the `scipy-wheels-nightly` to a new location:

```
pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple scikit-learn
```

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
> Strangely enough, error still occurs on skops [CI](https://github.com/skops-dev/skops/actions/runs/5387718929/jobs/9779408304) (it's not obvious from the error message but it is indeed the same error cause). It only happens with TfidfTransformer and TfidfVectorizer.

It might mean that we have made some changes in the `TfidfTransformer` that changes the state.

Labels: Regression
__sklearn_pickle_version__ makes estimator.__dict__.keys() == loaded.__dict__.keys() to fail

Since https://github.com/scikit-learn/scikit-learn/pull/22094, this fails:

```py
est = <AnySklearnEstimator>
dict_before = est.__dict__.keys()
loaded = pickle.loads(pickle.dumps(est))
dict_after = loaded.__dict__.keys()
assert dict_before == dict_after
```

We're in effect changing the state of the estimator through pickling, and I don't think that's a good idea.

If we think we need to know the version where a model was constructed, then `BaseEstimator.__init__` should do that, not `__getstate__`/`__setstate__`.

I suggest renaming the attribute to `__sklearn_version__` and having it set in `BaseEstimator.__init__`.

cc @BenjaminBossan @glemaitre @thomasjpfan @ogrisel

COMMENT:
Thanks for the update, I'll change the URL for skops to the new one.

Labels: Regression
<!DOCTYPE HTML PUBLIC - 503 Server unavailable error - ALOPS Release Deployment failed

One of our customer's PROD environment release pipeline failed its first release. 

Error: 
##[error]Exception in BCConnector.GetAPIData: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""[http://www.w3.org/TR/html4/strict.dtd](https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2FTR%2Fhtml4%2Fstrict.dtd&data=05%7C01%7Cjkarri%40mprise.nl%7Caa0c2eecb7ac4a46a06808dad9ba11ca%7Cbebc3a1cdc604cd89669a36303f40ff4%7C0%7C0%7C638061690438858501%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=bl0fP4H5O9gJHqgcR%2Bma%2B1U4G%2BsjvjeTvDJd1UanoE4%3D&reserved=0)">
##[error]Cannot find an overload for "GetExtensions" and the argument count: "1".
<img width="518" alt="Release fail error" src="https://user-images.githubusercontent.com/61264260/210202840-fb70045c-bc29-4700-85e4-429d5ec1585c.png">

Question: I'm first time facing this DOCTYPE HTML error. May I know what causes the "<!DOCTYPE HTML Public" error come? 
Or is this just server down or something?

What I checked from my end: 
1.	The servicetier for deployment/pipeline is running
2.	The DeployUser user does exist in the BC installation
3.	The DeployUser user does have the right License Type (in BC) - External User type
4.	The Microsoft API app _Exclude_APIV1_ is installed 
5.	The API endpoint port has been added in the firewall of the environment where the BC installation resides 
6.	The ALOps External Deployer has been installed
7.	The user account (DeployUser) credentials on the pipeline are right
8.	The NST SSL certificate is installed 
9.	On the NST the API services have been enabled
10. Recreated by cloning the TEST release pipeline and the result is same. 

More Information: 
We got our TEST environment release pipeline deploying successfully. 
We use O365 logins for web client.

COMMENT:
This doesn't seem to have anything to do with sklearn.

Labels: Needs Triage