ValueError:找到样本数不一致的输入变量:[250,22]

2024-05-11 02:33:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图拟合一个大小为250x22的数据帧,其中基本上每列都是一个像素强度值,因此我有22个像素值,每行都是一张人脸图像。我想做的是在LDA中拟合我的数据。但当我这样做时,我会得到以下错误:

ValueError: Found input variables with inconsistent numbers of samples: [250, 22]

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
pixel_index = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]
df = pd.DataFrame(reshaped_array)
X = df 
Y = pixel_index 
clf = LinearDiscriminantAnalysis()
clf.fit(X, y)
LinearDiscriminantAnalysis()

Link for the dataframe

我想做的只是塑造我的数据框架,这样我可以将一半的行分类为A类,另一半分类为B类


Tags: 数据图像dfindex错误分类像素人脸