File ~\anaconda3\lib\site-packages\sklearn\base.py:566, in BaseEstimator._validate_data(self, X, y, reset, validate_separately, check_params)
564 raise ValueError("Validation should be done on X, y or both.")
565 elif not no_val_X and no_val_y:
--> 566 X = check_array(X, check_params)
567 out = X
568 elif no_val_X and not no_val_y:
File ~\anaconda3\lib\site-packages\sklearn\utils\validation.py:769, in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator)
767 # If input is 1D raise error
768 if array.ndim == 1:
--> 769 raise ValueError(
770 "Expected 2D array, got 1D array instead:\narray={}.\n"
771 "Reshape your data either using array.reshape(-1, 1) if "
772 "your data has a single feature or array.reshape(1, -1) "
773 "if it contains a single sample.".format(array)
774 )
776 # make sure we actually converted to numeric:
777 if dtype_numeric and array.dtype.kind in "OUSV":
ValueError: Expected 2D array, got 1D array instead:
array=[].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
Clustering
KMeans = KMeans(number_clusters, random_state=0).fit(featurelist)
ValueError Traceback (most recent call last) Input In [84], in <cell line: 2>() 1 # Clustering ----> 2 KMeans = KMeans(number_clusters, random_state=0).fit(featurelist)
File ~\anaconda3\lib\site-packages\sklearn\cluster_kmeans.py:1137, in KMeans.fit(self, X, y, sample_weight) 1111 def fit(self, X, y=None, sample_weight=None): 1112 """Compute k-means clustering. 1113
1114 Parameters (...) 1135 Fitted estimator. 1136 """ -> 1137 X = self._validate_data( 1138 X, 1139 accept_sparse="csr", 1140 dtype=[np.float64, np.float32], 1141 order="C", 1142 copy=self.copy_x, 1143 accept_large_sparse=False, 1144 ) 1146 self._check_params(X) 1147 random_state = check_random_state(self.random_state)
File ~\anaconda3\lib\site-packages\sklearn\base.py:566, in BaseEstimator._validate_data(self, X, y, reset, validate_separately, check_params) 564 raise ValueError("Validation should be done on X, y or both.") 565 elif not no_val_X and no_val_y: --> 566 X = check_array(X, check_params) 567 out = X 568 elif no_val_X and not no_val_y: File ~\anaconda3\lib\site-packages\sklearn\utils\validation.py:769, in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator) 767 # If input is 1D raise error 768 if array.ndim == 1: --> 769 raise ValueError( 770 "Expected 2D array, got 1D array instead:\narray={}.\n" 771 "Reshape your data either using array.reshape(-1, 1) if " 772 "your data has a single feature or array.reshape(1, -1) " 773 "if it contains a single sample.".format(array) 774 ) 776 # make sure we actually converted to numeric: 777 if dtype_numeric and array.dtype.kind in "OUSV": ValueError: Expected 2D array, got 1D array instead: array=[]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.