为什么在LDA中,N组件不正常?
我尝试使用LDA并找到3通道输出。但是它的输出只有2个通道。
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
x = []
y = []
for i in range(len(img)):
for j in range(len(img[0])):
x.append([i,i,j,j])
y.append(img[i][j])
y = np.array(y)
x = np.array(x)
y.shape,x.shape
lad = out = _ = ''
lda = LDA(n_components=3)
out = lda.fit(x, y).transform(x)
print(out.shape,y.shape,x.shape)
我使用[I,I,J,J],因为LDA要求我拥有具有更多功能的X。
印刷输出是:
(((392960,2),(392960,),(392960,4))
但是,我要寻找的形状(392960,3)
有人可以帮我吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
始终低于类的数量,因为它将数据投射到尺寸的仿射子空间中,最多是class 1负1。看起来您的
y
有3堂课。The number of components in
LinearDiscriminantAnalysis
is always lower than the number of classes as it projects the data into an affine subspace of dimension at most the number of classes minus 1. It looks like youry
has 3 classes.