| Algorithm 1. Pseudocode of Fisher score method. | |
| 1. | Initialization |
| 2. | scores = [], index = {}, shapes = {}; |
| 3. | Input: |
| 4. | Training_Set; |
| 5. | Begin |
| 6. | For c in num_classes: |
| 7. | index[c] = df_fisher[‘class’] == c; |
| 8. | shapes[c] = df_fisher[index[c]].shape [0]; |
| 9. | End for c |
| 10. | For col in df_fisher.columns: |
| 11. | If col == ‘class’: |
| 12. | continue |
| 13. | num = 0; den = 0; |
| 14. | m = df_fisher[col].mean(); |
| 15. | For c in num_classes: |
| 16. | num = num+ (shapes[c]/df_fisher.shape [0]) (m-df_fisher[index[c]][col].mean()).^2; |
| 17. | den = den + (shapes[c]/df_fisher.shape[0]) df_fisher[index[c]][col].var(); |
| 18. | End for c |
| 19. | score = {‘feature’: col, ‘score’: num/den}; |
| 20. | scores.append(score); |
| 21. | End for col |
| 22. | Return Training_Set with selected features; |
| 23. | End |