我正在尝试在sklearn 17.1中使用 explain_variance_ratio _ 。
在sklearn docs中,它被描述为 LinearDiscriminantAnalysis 类的属性。
但如何应用呢?
我的代码是
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as lda
clf = lda(solver='eigen', shrinkage = 'auto')
clf.fit((tr_train, targ_train)
基本上,我在尝试
lda.explained_variance_ratio_(tr_train)
但我有
AttributeError: 'LinearDiscriminantAnalysis' object has no attribute 'explained_variance_ratio_'
答案 0 :(得分:1)
我认为您正在寻找的是:
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as lda
clf = lda(solver='eigen', shrinkage = 'auto')
clf.fit(tr_train, targ_train)
print clf.explained_variance_ratio_