为什么在LDA中,N组件不正常?

发布于 2025-01-23 04:27:57 字数 566 浏览 5 评论 0 原文

我尝试使用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)

有人可以帮我吗?

I tried to use LDA and find a 3-channel output. But its output has just 2 channels.

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 used [i, i, j, j] because LDA asked me to have x with more features.

and printed output is:
((392960, 2), (392960,), (392960, 4))
but for out.shape I seek (392960,3)

Can anyone help me with this, please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

全部不再 2025-01-30 04:27:57

始终低于类的数量,因为它将数据投射到尺寸的仿射子空间中,最多是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 your y has 3 classes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文