Python ValueError:找到包含1个样本(形状=(1,2))的数组,而聚合群集至少需要2个样本

Python ValueError:找到包含1个样本(形状=(1,2))的数组,而聚合群集至少需要2个样本,python,machine-learning,Python,Machine Learning,我试图预测看不见的数据 enter code here` from sklearn.cluster import AgglomerativeClustering hc = AgglomerativeClustering(n_clusters = 5, affinity = 'euclidean', linkage = 'ward') y = hc.fit(X) X.shape (200,2) a = int(input('Enter Income (K$)

我试图预测看不见的数据

enter code here`
   from sklearn.cluster import AgglomerativeClustering
   hc = AgglomerativeClustering(n_clusters = 5, affinity = 'euclidean', linkage = 'ward')
   y = hc.fit(X)

   X.shape
   (200,2)
   a = int(input('Enter Income (K$)'))
   b = int(input('Enter spending score (1-100)'))
   c = np.zeros((1,2))
   c[0,0] = a
   c[0,1] = b
   print(c.shape)
   print(c)
   print(type(c))
   o = y.fit_predict(c)
   if o == 4:
       Category = 'Sensible Clients'
   elif o == 3:
       Category = 'Careless Client'
   elif o == 2:
       Category = 'Target Client'
   elif o == 1:
       Category = 'Standard Client'
   else:
       Category = 'Careful Client'
   print('The client belongs to {} Category'.format(Category))
enter code here`
   from sklearn.cluster import AgglomerativeClustering
   hc = AgglomerativeClustering(n_clusters = 5, affinity = 'euclidean', linkage = 'ward')
   y = hc.fit(X)

   X.shape
   (200,2)
   a = int(input('Enter Income (K$)'))
   b = int(input('Enter spending score (1-100)'))
   c = np.zeros((1,2))
   c[0,0] = a
   c[0,1] = b
   print(c.shape)
   print(c)
   print(type(c))
   o = y.fit_predict(c)
   if o == 4:
       Category = 'Sensible Clients'
   elif o == 3:
       Category = 'Careless Client'
   elif o == 2:
       Category = 'Target Client'
   elif o == 1:
       Category = 'Standard Client'
   else:
       Category = 'Careful Client'
   print('The client belongs to {} Category'.format(Category))
当我试图预测看不见的数据时

enter code here`
   from sklearn.cluster import AgglomerativeClustering
   hc = AgglomerativeClustering(n_clusters = 5, affinity = 'euclidean', linkage = 'ward')
   y = hc.fit(X)

   X.shape
   (200,2)
   a = int(input('Enter Income (K$)'))
   b = int(input('Enter spending score (1-100)'))
   c = np.zeros((1,2))
   c[0,0] = a
   c[0,1] = b
   print(c.shape)
   print(c)
   print(type(c))
   o = y.fit_predict(c)
   if o == 4:
       Category = 'Sensible Clients'
   elif o == 3:
       Category = 'Careless Client'
   elif o == 2:
       Category = 'Target Client'
   elif o == 1:
       Category = 'Standard Client'
   else:
       Category = 'Careful Client'
   print('The client belongs to {} Category'.format(Category))
enter code here`
   from sklearn.cluster import AgglomerativeClustering
   hc = AgglomerativeClustering(n_clusters = 5, affinity = 'euclidean', linkage = 'ward')
   y = hc.fit(X)

   X.shape
   (200,2)
   a = int(input('Enter Income (K$)'))
   b = int(input('Enter spending score (1-100)'))
   c = np.zeros((1,2))
   c[0,0] = a
   c[0,1] = b
   print(c.shape)
   print(c)
   print(type(c))
   o = y.fit_predict(c)
   if o == 4:
       Category = 'Sensible Clients'
   elif o == 3:
       Category = 'Careless Client'
   elif o == 2:
       Category = 'Target Client'
   elif o == 1:
       Category = 'Standard Client'
   else:
       Category = 'Careful Client'
   print('The client belongs to {} Category'.format(Category))
输入收入(K$)90 输入支出分数(1-100)90 (1, 2) [[90. 90.]]' 'ValueError回溯(最近一次调用上次) 我试图预测看不见的数据

enter code here`
   from sklearn.cluster import AgglomerativeClustering
   hc = AgglomerativeClustering(n_clusters = 5, affinity = 'euclidean', linkage = 'ward')
   y = hc.fit(X)

   X.shape
   (200,2)
   a = int(input('Enter Income (K$)'))
   b = int(input('Enter spending score (1-100)'))
   c = np.zeros((1,2))
   c[0,0] = a
   c[0,1] = b
   print(c.shape)
   print(c)
   print(type(c))
   o = y.fit_predict(c)
   if o == 4:
       Category = 'Sensible Clients'
   elif o == 3:
       Category = 'Careless Client'
   elif o == 2:
       Category = 'Target Client'
   elif o == 1:
       Category = 'Standard Client'
   else:
       Category = 'Careful Client'
   print('The client belongs to {} Category'.format(Category))
enter code here`
   from sklearn.cluster import AgglomerativeClustering
   hc = AgglomerativeClustering(n_clusters = 5, affinity = 'euclidean', linkage = 'ward')
   y = hc.fit(X)

   X.shape
   (200,2)
   a = int(input('Enter Income (K$)'))
   b = int(input('Enter spending score (1-100)'))
   c = np.zeros((1,2))
   c[0,0] = a
   c[0,1] = b
   print(c.shape)
   print(c)
   print(type(c))
   o = y.fit_predict(c)
   if o == 4:
       Category = 'Sensible Clients'
   elif o == 3:
       Category = 'Careless Client'
   elif o == 2:
       Category = 'Target Client'
   elif o == 1:
       Category = 'Standard Client'
   else:
       Category = 'Careful Client'
   print('The client belongs to {} Category'.format(Category))
当我试图预测看不见的数据时

enter code here`
   from sklearn.cluster import AgglomerativeClustering
   hc = AgglomerativeClustering(n_clusters = 5, affinity = 'euclidean', linkage = 'ward')
   y = hc.fit(X)

   X.shape
   (200,2)
   a = int(input('Enter Income (K$)'))
   b = int(input('Enter spending score (1-100)'))
   c = np.zeros((1,2))
   c[0,0] = a
   c[0,1] = b
   print(c.shape)
   print(c)
   print(type(c))
   o = y.fit_predict(c)
   if o == 4:
       Category = 'Sensible Clients'
   elif o == 3:
       Category = 'Careless Client'
   elif o == 2:
       Category = 'Target Client'
   elif o == 1:
       Category = 'Standard Client'
   else:
       Category = 'Careful Client'
   print('The client belongs to {} Category'.format(Category))
enter code here`
   from sklearn.cluster import AgglomerativeClustering
   hc = AgglomerativeClustering(n_clusters = 5, affinity = 'euclidean', linkage = 'ward')
   y = hc.fit(X)

   X.shape
   (200,2)
   a = int(input('Enter Income (K$)'))
   b = int(input('Enter spending score (1-100)'))
   c = np.zeros((1,2))
   c[0,0] = a
   c[0,1] = b
   print(c.shape)
   print(c)
   print(type(c))
   o = y.fit_predict(c)
   if o == 4:
       Category = 'Sensible Clients'
   elif o == 3:
       Category = 'Careless Client'
   elif o == 2:
       Category = 'Target Client'
   elif o == 1:
       Category = 'Standard Client'
   else:
       Category = 'Careful Client'
   print('The client belongs to {} Category'.format(Category))
输入收入(K$)90 输入支出分数(1-100)90 (1, 2) [[90. 90.]]' 'ValueError回溯(最近一次调用上次) 在里面 7印刷品(c) 8印刷品(c类) ---->9 o=hc.拟合度(c)

c:\users\user\appdata\local\programs\python37\lib\site packages\sklearn\base.py in fit\u predict(self,X,y) 445#非优化默认实现;当一个更好的 446#方法适用于给定的聚类算法 -->447自适配(X) 448返回自助标签_ 449

c:\users\user\appdata\local\programs\python37\lib\site packages\sklearn\cluster\hierarchy.py(self,X,y) 803“它在0.20版中已被弃用,将被删除” 804'已在0.22'中删除,弃用警告) -->805 X=检查数组(X,确保最小样本数=2,估计器=self) 806内存=检查内存(自内存) 807

检查数组中的c:\users\user\appdata\local\programs\python37\lib\site packages\sklearn\utils\validation.py(数组,接受稀疏,接受大稀疏,数据类型,顺序,复制,强制所有有限,确保二维,允许,确保最小样本,确保最小特征,警告数据类型,估算器) 548“至少需要%d个%s。” 549%(n个样本,数组。形状,确保最小样本, -->(上下文) 551 552如果确保_min_features>0且array.ndim==2:

ValueError:找到包含1个样本(形状=(1,2))的数组,而AggregativeClustering's至少需要2个样本