【问题标题】:LDA unexpected number of features selectedLDA 选择了意外数量的功能
【发布时间】:2019-06-17 01:06:22
【问题描述】:

我正在尝试执行 LDA(线性判别分析),以便对我的数据集(features,一个 1360x532 矩阵)执行降维(从 532 个特征)。

lda = LinearDiscriminantAnalysis(n_components=80)
features = lda.fit(features, target).transform(features)
print("[STATUS] LDA performed")
print("[STATUS] feature vector size {}".format(np.array(features).shape))

我写了这段代码,我期待功能变成80,但我得到了这个意外的输出。

[STATUS] target labels shape: (1360,)
/home/robb/.local/lib/python2.7/site-packages/sklearn/discriminant_analysis.py:388: UserWarning: Variables are collinear.
  warnings.warn("Variables are collinear.")
[STATUS] LDA performed
[STATUS] feature vector size (1360, 16)

为什么是16?是否与我收到的警告有关?

【问题讨论】:

    标签: python feature-selection


    【解决方案1】:

    LDA 的行为不符合您的预期。

    组件的数量总是小于唯一类的数量。

    来自docs

    用于降维的组件数 (


    我的猜测是您在 target 变量中有 17 个唯一的类标签,因此,通过指定 80 个组件(大于 17 个)会导致此结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-18
      • 2019-06-11
      • 2023-02-11
      • 2016-07-06
      • 2023-04-01
      • 1970-01-01
      • 2015-12-15
      相关资源
      最近更新 更多