Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Fisher score error – Length of value does not match length of index?

I am working on ML problem, trying to compute the fisher score for feature selection purpose

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()

I am trying to compute the fisher score for each of the feature. I am just following the tutorials as is here and here

The code is given below

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

!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

I get

ValueError: Length of values (1) does not match length of index (2)

If I pass only one feature as input like shown below,

score = pd.Series(fisher_score.fisher_score(t[['A']], t['Y']))

I expect my output to have a list of scores for each feature, but I get another error:

ValueError: Data must be 1-dimensional

How to fix this issue?

>Solution :

The inputs to the fisher_score method is expected a numpy array not a pandas dataframe/series.

Try this:

score = fisher_score.fisher_score(t[['A','B']].to_numpy(),
                      t['Y'].to_numpy())
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading