简体   繁体   中英

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.

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. 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) . See documentation of LDA here.

Note: LDA has been deprecated and now its recommended to use LinearDiscriminantAnalysis .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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