简体   繁体   English

在scikit-learn中获取lda的投影矩阵

[英]Get projection matrix of lda in scikit-learn

I need to get the projection matrix from lda, which has been supplied the train data, so that I can use that to project the train data in the lda space. 我需要从提供了火车数据的lda中获得投影矩阵,以便可以使用它在lda空间中投影火车数据。

I have done the following : 我已经完成以下工作:

def get_projection(features,label):

    transformer = LDA(store_covariance=True)
    transformer.fit_transform(features,label)   
    cov_mat = transformer.covariance_

    return cov_mat

I have then extracted the eigen vectors of the covariance matrix. 然后,我提取了协方差矩阵的特征向量。 But that doesn't seem to give correct solution. 但这似乎并未提供正确的解决方案。 Even the .scalings_ attribute doesn't seem to be helpful. 甚至.scalings_属性似乎也无济于事。 Kindly help me find the projection matrix from this method, so that I can apply it on test data, which don't have labels. 请帮助我从此方法中找到投影矩阵,以便将其应用于没有标签的测试数据。

You can apply the transformer directly on test data by transformer.transform(test_data) . 您可以通过transformer.transform(test_data)将变压器直接应用于测试数据。 See documentation of LDA here. 请参阅此处的LDA 文档

Note: LDA has been deprecated and now its recommended to use LinearDiscriminantAnalysis . 注意:LDA已被弃用,现在建议使用LinearDiscriminantAnalysis

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM