Talip7/scikit-learn-issues-multilabel huggingface dataset:
Unsupervised K-Means Clustering Algorithm

### Describe the workflow you want to enable

"the k-means algorithm and its extensions are always influenced by initializations with a necessary number of clusters a priori. That is, the k-means algorithm is not exactly an unsupervised clustering method. In this paper, we construct an unsupervised learning schema for the k-means algorithm so that it is free of initializations without parameter selection and can also simultaneously find an optimal number of clusters." from the abstract. 

### Describe your proposed solution

"To construct the k-means clustering algorithm with free of initializations and automatically find the number of clusters, we use the entropy concept. We borrow the idea from the EM algorithm by Yang et al." from section 3 (THE UNSUPERVISED K-MEANS CLUSTERING ALGORITHM).

### Describe alternatives you've considered, if relevant

R-EM, C-FS, X-Means, and RL-FCM

### Additional context

https://ieeexplore.ieee.org/document/9072123

309 citations (according to Google Scholar, not sure why IEEE shows a different number), released in 20 April 2020. I think there are up to 5 parameters "γ, β, c, a K, a K,"  might be wrong.

The total computational complexity for the U-k-means algorithm is O(ncd), where n is the number of data points, c is the number of clusters, and d is the dimension of data points.

Name of the authors: Kristina P. Sinaga, Miin-Shen Yang

COMMENT:
> @MrinalTyagi Do you think this would require a seperate estimator? Or could it be implemented in an existing one by specifying ```n_clusters='auto'```?

Just adding auto as param in n_clusters would be a better option i feel considering the api structure of scikit learn

Labels: New Feature, module:cluster, Needs Decision - Include Feature
Unsupervised K-Means Clustering Algorithm

### Describe the workflow you want to enable

"the k-means algorithm and its extensions are always influenced by initializations with a necessary number of clusters a priori. That is, the k-means algorithm is not exactly an unsupervised clustering method. In this paper, we construct an unsupervised learning schema for the k-means algorithm so that it is free of initializations without parameter selection and can also simultaneously find an optimal number of clusters." from the abstract. 

### Describe your proposed solution

"To construct the k-means clustering algorithm with free of initializations and automatically find the number of clusters, we use the entropy concept. We borrow the idea from the EM algorithm by Yang et al." from section 3 (THE UNSUPERVISED K-MEANS CLUSTERING ALGORITHM).

### Describe alternatives you've considered, if relevant

R-EM, C-FS, X-Means, and RL-FCM

### Additional context

https://ieeexplore.ieee.org/document/9072123

309 citations (according to Google Scholar, not sure why IEEE shows a different number), released in 20 April 2020. I think there are up to 5 parameters "γ, β, c, a K, a K,"  might be wrong.

The total computational complexity for the U-k-means algorithm is O(ncd), where n is the number of data points, c is the number of clusters, and d is the dimension of data points.

Name of the authors: Kristina P. Sinaga, Miin-Shen Yang

COMMENT:
I'm not sure if we need to:
1. make a new MixIn or Base class
2. create an option for n_neighbors== 'auto'
3. create a new estimator like https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.NearestNeighbors.html#sklearn.neighbors.NearestNeighbors

Labels: New Feature, module:cluster, Needs Decision - Include Feature
Unsupervised K-Means Clustering Algorithm

### Describe the workflow you want to enable

"the k-means algorithm and its extensions are always influenced by initializations with a necessary number of clusters a priori. That is, the k-means algorithm is not exactly an unsupervised clustering method. In this paper, we construct an unsupervised learning schema for the k-means algorithm so that it is free of initializations without parameter selection and can also simultaneously find an optimal number of clusters." from the abstract. 

### Describe your proposed solution

"To construct the k-means clustering algorithm with free of initializations and automatically find the number of clusters, we use the entropy concept. We borrow the idea from the EM algorithm by Yang et al." from section 3 (THE UNSUPERVISED K-MEANS CLUSTERING ALGORITHM).

### Describe alternatives you've considered, if relevant

R-EM, C-FS, X-Means, and RL-FCM

### Additional context

https://ieeexplore.ieee.org/document/9072123

309 citations (according to Google Scholar, not sure why IEEE shows a different number), released in 20 April 2020. I think there are up to 5 parameters "γ, β, c, a K, a K,"  might be wrong.

The total computational complexity for the U-k-means algorithm is O(ncd), where n is the number of data points, c is the number of clusters, and d is the dimension of data points.

Name of the authors: Kristina P. Sinaga, Miin-Shen Yang

COMMENT:
in class KNeighborsMixin:
```
    def kneighbors(self, X=None, n_neighbors=None, return_distance=True):
        if n_neighbors == 'unsupervised':
            n_neighbors = self.n_neighbors
            clust, c_history = Unsupervised_K_Means_Clustering(thres=0.0001, beta=2, gamma=0.0001, rate=0, t_max=1000).fit(X, y=None)
            n_neighbors = int(np.median(clust))
        return super().kneighbors(X, n_neighbors, return_distance)
```
I doubt this fits the sklearn standard tho

Labels: New Feature, module:cluster, Needs Decision - Include Feature
Unsupervised K-Means Clustering Algorithm

### Describe the workflow you want to enable

"the k-means algorithm and its extensions are always influenced by initializations with a necessary number of clusters a priori. That is, the k-means algorithm is not exactly an unsupervised clustering method. In this paper, we construct an unsupervised learning schema for the k-means algorithm so that it is free of initializations without parameter selection and can also simultaneously find an optimal number of clusters." from the abstract. 

### Describe your proposed solution

"To construct the k-means clustering algorithm with free of initializations and automatically find the number of clusters, we use the entropy concept. We borrow the idea from the EM algorithm by Yang et al." from section 3 (THE UNSUPERVISED K-MEANS CLUSTERING ALGORITHM).

### Describe alternatives you've considered, if relevant

R-EM, C-FS, X-Means, and RL-FCM

### Additional context

https://ieeexplore.ieee.org/document/9072123

309 citations (according to Google Scholar, not sure why IEEE shows a different number), released in 20 April 2020. I think there are up to 5 parameters "γ, β, c, a K, a K,"  might be wrong.

The total computational complexity for the U-k-means algorithm is O(ncd), where n is the number of data points, c is the number of clusters, and d is the dimension of data points.

Name of the authors: Kristina P. Sinaga, Miin-Shen Yang

COMMENT:
> I'm not sure if we need to:
> 
> 1. make a new MixIn or Base class
> 2. create an option for n_neighbors== 'auto'
> 3. create a new estimator

Considering that this is an unsupervised model instead of a supervised model, I think this should be its own estimator. If we could get someone to weigh in on this, that would be great. @cmarmo @Micky774 if either of you could give an opinion or recommend someone to

Labels: New Feature, module:cluster, Needs Decision - Include Feature
Unsupervised K-Means Clustering Algorithm

### Describe the workflow you want to enable

"the k-means algorithm and its extensions are always influenced by initializations with a necessary number of clusters a priori. That is, the k-means algorithm is not exactly an unsupervised clustering method. In this paper, we construct an unsupervised learning schema for the k-means algorithm so that it is free of initializations without parameter selection and can also simultaneously find an optimal number of clusters." from the abstract. 

### Describe your proposed solution

"To construct the k-means clustering algorithm with free of initializations and automatically find the number of clusters, we use the entropy concept. We borrow the idea from the EM algorithm by Yang et al." from section 3 (THE UNSUPERVISED K-MEANS CLUSTERING ALGORITHM).

### Describe alternatives you've considered, if relevant

R-EM, C-FS, X-Means, and RL-FCM

### Additional context

https://ieeexplore.ieee.org/document/9072123

309 citations (according to Google Scholar, not sure why IEEE shows a different number), released in 20 April 2020. I think there are up to 5 parameters "γ, β, c, a K, a K,"  might be wrong.

The total computational complexity for the U-k-means algorithm is O(ncd), where n is the number of data points, c is the number of clusters, and d is the dimension of data points.

Name of the authors: Kristina P. Sinaga, Miin-Shen Yang

COMMENT:
Hey there @replacementAI, sorry for the delay. I still need to actually read the underlying paper proposing the algorithm.

I also wonder if @GaelVaroquaux @adrinjalali @jeremiedbb have any familiarity with this, or opinions on inclusion.

Labels: New Feature, module:cluster, Needs Decision - Include Feature
Unsupervised K-Means Clustering Algorithm

### Describe the workflow you want to enable

"the k-means algorithm and its extensions are always influenced by initializations with a necessary number of clusters a priori. That is, the k-means algorithm is not exactly an unsupervised clustering method. In this paper, we construct an unsupervised learning schema for the k-means algorithm so that it is free of initializations without parameter selection and can also simultaneously find an optimal number of clusters." from the abstract. 

### Describe your proposed solution

"To construct the k-means clustering algorithm with free of initializations and automatically find the number of clusters, we use the entropy concept. We borrow the idea from the EM algorithm by Yang et al." from section 3 (THE UNSUPERVISED K-MEANS CLUSTERING ALGORITHM).

### Describe alternatives you've considered, if relevant

R-EM, C-FS, X-Means, and RL-FCM

### Additional context

https://ieeexplore.ieee.org/document/9072123

309 citations (according to Google Scholar, not sure why IEEE shows a different number), released in 20 April 2020. I think there are up to 5 parameters "γ, β, c, a K, a K,"  might be wrong.

The total computational complexity for the U-k-means algorithm is O(ncd), where n is the number of data points, c is the number of clusters, and d is the dimension of data points.

Name of the authors: Kristina P. Sinaga, Miin-Shen Yang

COMMENT:
I do not think that it has the popularity required for inclusion.

These days, we are really trying to focus on the main conceptual tools and push up the quality of the features rather than the number of methods implemented.

A wider range of methods can typically be added via scikit-learn-contrib.

Thanks!

Labels: New Feature, module:cluster, Needs Decision - Include Feature
Unsupervised K-Means Clustering Algorithm

### Describe the workflow you want to enable

"the k-means algorithm and its extensions are always influenced by initializations with a necessary number of clusters a priori. That is, the k-means algorithm is not exactly an unsupervised clustering method. In this paper, we construct an unsupervised learning schema for the k-means algorithm so that it is free of initializations without parameter selection and can also simultaneously find an optimal number of clusters." from the abstract. 

### Describe your proposed solution

"To construct the k-means clustering algorithm with free of initializations and automatically find the number of clusters, we use the entropy concept. We borrow the idea from the EM algorithm by Yang et al." from section 3 (THE UNSUPERVISED K-MEANS CLUSTERING ALGORITHM).

### Describe alternatives you've considered, if relevant

R-EM, C-FS, X-Means, and RL-FCM

### Additional context

https://ieeexplore.ieee.org/document/9072123

309 citations (according to Google Scholar, not sure why IEEE shows a different number), released in 20 April 2020. I think there are up to 5 parameters "γ, β, c, a K, a K,"  might be wrong.

The total computational complexity for the U-k-means algorithm is O(ncd), where n is the number of data points, c is the number of clusters, and d is the dimension of data points.

Name of the authors: Kristina P. Sinaga, Miin-Shen Yang

COMMENT:
> I do not think that it has the popularity required for inclusion.
> 
> These days, we are really trying to focus on the main conceptual tools and push up the quality of the features rather than the number of methods implemented.
> 
> A wider range of methods can typically be added via scikit-learn-contrib.
> 
> Thanks!

Thanks, I will go ahead and close it for now then.

Labels: New Feature, module:cluster, Needs Decision - Include Feature
MinMaxScaler on Loaded DataFrame fails with TypeError : NoneType

### Describe the bug

Hey, I've been re-running my code on a different machine and I realized my old version was 0.24.1 but in the latest version of 1.02 , in the [_handle_zeros_in_scale](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/preprocessing/_data.py#L90) method - 

Even though scale.dtype shows `float64` , the `np.finfo()` throws an error in Line 114 at constant_mask

`TypeError: 'NoneType' object is not callable`

Technically there is no change in my code or data and it should be running as expected but I'm getting this issue from version change. Solution can be to downgrade my version, but this part doesn't make sense to me. Everything in the debug is same till this point, so it should work.

the main change is the addition of the constant mask
this `scale[scale==0.0] = 1.0`
became `scale[constant_mask] = 1.0`

However that is still not the issue. It's the np.finfo() and specifically

```python

        try:
            dtype = numeric.dtype(dtype)
        except TypeError:
            # In case a float instance was given
            dtype = numeric.dtype(type(dtype))

```

Both the try and except clauses give the same error result for float64. This is where it stalls. 

I have written a code to replicate it below, and an interesting thing I noticed is that, if I create a dataframe and sent it to the scaler directly it works but if the dataframe is loaded from a file, then I get this error

### Steps/Code to Reproduce

import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler

arr = np.round(np.random.rand(4, 5) * 10)
pd.DataFrame(arr).to_csv("file.csv",index=False,header=False)
df = pd.read_csv("file.csv")
scaler = MinMaxScaler()
scaler.fit(df)

### Expected Results

Expected is a scaler and code to execute fully but it errors out

### Actual Results

It is supposed to create a scaler object 

### Versions

```shell
'1.0.2'
```

COMMENT:
I am not able to reproduce this issue with your code snippet on 1.0.2 or 1.1.1.

(On OSX using Python 3.9)

Labels: Bug, module:preprocessing, Needs Investigation
MinMaxScaler on Loaded DataFrame fails with TypeError : NoneType

### Describe the bug

Hey, I've been re-running my code on a different machine and I realized my old version was 0.24.1 but in the latest version of 1.02 , in the [_handle_zeros_in_scale](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/preprocessing/_data.py#L90) method - 

Even though scale.dtype shows `float64` , the `np.finfo()` throws an error in Line 114 at constant_mask

`TypeError: 'NoneType' object is not callable`

Technically there is no change in my code or data and it should be running as expected but I'm getting this issue from version change. Solution can be to downgrade my version, but this part doesn't make sense to me. Everything in the debug is same till this point, so it should work.

the main change is the addition of the constant mask
this `scale[scale==0.0] = 1.0`
became `scale[constant_mask] = 1.0`

However that is still not the issue. It's the np.finfo() and specifically

```python

        try:
            dtype = numeric.dtype(dtype)
        except TypeError:
            # In case a float instance was given
            dtype = numeric.dtype(type(dtype))

```

Both the try and except clauses give the same error result for float64. This is where it stalls. 

I have written a code to replicate it below, and an interesting thing I noticed is that, if I create a dataframe and sent it to the scaler directly it works but if the dataframe is loaded from a file, then I get this error

### Steps/Code to Reproduce

import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler

arr = np.round(np.random.rand(4, 5) * 10)
pd.DataFrame(arr).to_csv("file.csv",index=False,header=False)
df = pd.read_csv("file.csv")
scaler = MinMaxScaler()
scaler.fit(df)

### Expected Results

Expected is a scaler and code to execute fully but it errors out

### Actual Results

It is supposed to create a scaler object 

### Versions

```shell
'1.0.2'
```

COMMENT:
I had scikit-learn 1.0.2 on python 3.10.4 , Windows

Labels: Bug, module:preprocessing, Needs Investigation
MinMaxScaler on Loaded DataFrame fails with TypeError : NoneType

### Describe the bug

Hey, I've been re-running my code on a different machine and I realized my old version was 0.24.1 but in the latest version of 1.02 , in the [_handle_zeros_in_scale](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/preprocessing/_data.py#L90) method - 

Even though scale.dtype shows `float64` , the `np.finfo()` throws an error in Line 114 at constant_mask

`TypeError: 'NoneType' object is not callable`

Technically there is no change in my code or data and it should be running as expected but I'm getting this issue from version change. Solution can be to downgrade my version, but this part doesn't make sense to me. Everything in the debug is same till this point, so it should work.

the main change is the addition of the constant mask
this `scale[scale==0.0] = 1.0`
became `scale[constant_mask] = 1.0`

However that is still not the issue. It's the np.finfo() and specifically

```python

        try:
            dtype = numeric.dtype(dtype)
        except TypeError:
            # In case a float instance was given
            dtype = numeric.dtype(type(dtype))

```

Both the try and except clauses give the same error result for float64. This is where it stalls. 

I have written a code to replicate it below, and an interesting thing I noticed is that, if I create a dataframe and sent it to the scaler directly it works but if the dataframe is loaded from a file, then I get this error

### Steps/Code to Reproduce

import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler

arr = np.round(np.random.rand(4, 5) * 10)
pd.DataFrame(arr).to_csv("file.csv",index=False,header=False)
df = pd.read_csv("file.csv")
scaler = MinMaxScaler()
scaler.fit(df)

### Expected Results

Expected is a scaler and code to execute fully but it errors out

### Actual Results

It is supposed to create a scaler object 

### Versions

```shell
'1.0.2'
```

COMMENT:
- Can you see what dtype you get here:

```python
import numpy as np
import pandas as pd

rng = np.random.RandomState(42)
arr = np.round(rng.rand(4, 5) * 10)
pd.DataFrame(arr).to_csv("file.csv",index=False,header=False)
df = pd.read_csv("file.csv")
print(df.dtypes)
```

I get:

```
4.0     float64
10.0    float64
7.0     float64
6.0     float64
2.0     float64
dtype: object
```

- Also it's strange to have `header=False`, this means the `pd.read_csv` will use the first row in "file.csv" as strings for column names. Using `header=True` would recover the original DataFrame. The following works for me:

```python
import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler

rng = np.random.RandomState(42)
arr = np.round(rng.rand(4, 5) * 10)
df_orig = pd.DataFrame(arr)

# header=True here
df_orig.to_csv("file.csv",index=False,header=True)

df = pd.read_csv("file.csv")
scaler = MinMaxScaler()
scaler.fit(df)
```

Labels: Bug, module:preprocessing, Needs Investigation
MinMaxScaler on Loaded DataFrame fails with TypeError : NoneType

### Describe the bug

Hey, I've been re-running my code on a different machine and I realized my old version was 0.24.1 but in the latest version of 1.02 , in the [_handle_zeros_in_scale](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/preprocessing/_data.py#L90) method - 

Even though scale.dtype shows `float64` , the `np.finfo()` throws an error in Line 114 at constant_mask

`TypeError: 'NoneType' object is not callable`

Technically there is no change in my code or data and it should be running as expected but I'm getting this issue from version change. Solution can be to downgrade my version, but this part doesn't make sense to me. Everything in the debug is same till this point, so it should work.

the main change is the addition of the constant mask
this `scale[scale==0.0] = 1.0`
became `scale[constant_mask] = 1.0`

However that is still not the issue. It's the np.finfo() and specifically

```python

        try:
            dtype = numeric.dtype(dtype)
        except TypeError:
            # In case a float instance was given
            dtype = numeric.dtype(type(dtype))

```

Both the try and except clauses give the same error result for float64. This is where it stalls. 

I have written a code to replicate it below, and an interesting thing I noticed is that, if I create a dataframe and sent it to the scaler directly it works but if the dataframe is loaded from a file, then I get this error

### Steps/Code to Reproduce

import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler

arr = np.round(np.random.rand(4, 5) * 10)
pd.DataFrame(arr).to_csv("file.csv",index=False,header=False)
df = pd.read_csv("file.csv")
scaler = MinMaxScaler()
scaler.fit(df)

### Expected Results

Expected is a scaler and code to execute fully but it errors out

### Actual Results

It is supposed to create a scaler object 

### Versions

```shell
'1.0.2'
```

COMMENT:
I'm getting the same dtype output as you, and if header=True, then instead of those random numbers I see 0,1,2,3,4 with dtype float64.

You're right about the header part. but technically that shouldn't change anything other than having one less row. I put that to false to see if that was causing the dtype issues

I had to uninstall and reinstall packages and i'm back at 1.0.2 because that is more compatible with python 3.10 and I couldn't downgrade. However, the problem doesn't seem to happen anymore. Yesterday, I initially had to modify the constant_mask and scale code , to the 0.24.2 version, to make it work without the error. Now it's working without that hack too. I guess the reinstall of scikit AND pandas helped

Labels: Bug, module:preprocessing, Needs Investigation