我正在研究ML问题,为了特征选择的目的,我试图计算fisher评分。
A B Y
1 1 1
2 5 1
1 5 1
7 9 0
7 9 0
8 9 0
t = pd.read_clipboard()
我试图计算每个特征的fisher评分。我只是在学习教程,就像这里和这里一样
下面给出了代码
!pip install skfeature-chappers
from skfeature.function.similarity_based import fisher_score
score = fisher_score.fisher_score(t[['A','B']], t['Y'])) # error here
score = fisher_score.fisher_score(t[['A','B']], t['Y']), mode='rank') # tried this but also error
score = pd.Series(fisher_score.fisher_score(t[['A','B']], t['Y']))) # error here
我得到了
ValueError: Length of values (1) does not match length of index (2)
如果我只传递一个功能作为输入,如下所示,
score = pd.Series(fisher_score.fisher_score(t[['A']], t['Y']))
我希望输出的每个功能都有一个分数列表,但是我得到了另一个错误:
ValueError: Data must be 1-dimensional
如何解决这个问题?
发布于 2022-03-03 13:46:50
对fisher_score方法的输入应该是一个numpy数组,而不是熊猫数据/序列。
试试这个:
score = fisher_score.fisher_score(t[['A','B']].to_numpy(),
t['Y'].to_numpy())
https://stackoverflow.com/questions/71337738
复制相似问题