TypeError: '<=' not supported between instances of 'str' and 'int' when using fit_predict

I am trying to utilize silhouette analysis on KMeans clustering in order to determine how to choose the optimal number of clusters in a given dataset.
I tried the example code provided on [scikit-learn](https://scikit-learn.org/stable/auto_examples/cluster/plot_kmeans_silhouette_analysis.html#) but it seems to produce an error whenever I try to run it.

Traceback:
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [14], in <cell line: 24>()
     37 # Initialize the clusterer with n_clusters value and a random generator
     38 # seed of 10 for reproducibility.
     39 clusterer = KMeans(n_clusters=n_clusters, n_init="auto", random_state=10)
---> 40 cluster_labels = clusterer.fit_predict(X)
     42 # The silhouette_score gives the average value for all the samples.
     43 # This gives a perspective into the density and separation of the formed
     44 # clusters
     45 silhouette_avg = silhouette_score(X, cluster_labels)

File ~\Anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:1255, in KMeans.fit_predict(self, X, y, sample_weight)
   1232 def fit_predict(self, X, y=None, sample_weight=None):
   1233     """Compute cluster centers and predict cluster index for each sample.
   1234 
   1235     Convenience method; equivalent to calling fit(X) followed by
   (...)
   1253         Index of the cluster each sample belongs to.
   1254     """
-> 1255     return self.fit(X, sample_weight=sample_weight).labels_

File ~\Anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:1146, in KMeans.fit(self, X, y, sample_weight)
   1112 """Compute k-means clustering.
   1113 
   1114 Parameters
   (...)
   1135     Fitted estimator.
   1136 """
   1137 X = self._validate_data(
   1138     X,
   1139     accept_sparse="csr",
   (...)
   1143     accept_large_sparse=False,
   1144 )
-> 1146 self._check_params(X)
   1147 random_state = check_random_state(self.random_state)
   1148 sample_weight = _check_sample_weight(sample_weight, X, dtype=X.dtype)

File ~\Anaconda3\lib\site-packages\sklearn\cluster\_kmeans.py:937, in KMeans._check_params(self, X)
    935 def _check_params(self, X):
    936     # n_init
--> 937     if self.n_init <= 0:
    938         raise ValueError(f"n_init should be > 0, got {self.n_init} instead.")
    939     self._n_init = self.n_init

TypeError: '<=' not supported between instances of 'str' and 'int'
```

Is there something I am missing here? I iterated through the sample data and did not see any strings present in `X`. I copied and ran the exact same code as present on the website.

Thank you!

COMMENT:
We rebuild the examples to make sure they work with the version it was released with. In this case, `n_init="auto"` was added in v1.2, so it only works with v1.2. In original code snippet, I can see that it is v1.1 because that code appears in v1.1 and was updated in v1.2. Here is a link to the code from `1.1.3` tag, which matches the code snippet:

https://github.com/scikit-learn/scikit-learn/blob/ffc0f66676b4835eb1bdd3f3ecab025e9c1be9fe/sklearn/cluster/_kmeans.py#L818-L820

In v1.2, the validation code changed to take into account `n_init="auto"`:

https://github.com/scikit-learn/scikit-learn/blob/e58f36c73bd524ad87b05126a4e5b50dc4b24fcc/sklearn/cluster/_kmeans.py#L866-L881

If one has v1.2, then the above code will run which supports `n_init="auto"`.

One can get the scikit-learn version used by the Python interpreter by running:

```bash
python -c "import sklearn; sklearn.show_versions()"
```

Labels: Question