When looking for correlation between features (for feature selection), I found that sklearn implementation of Chi2 test of independence produce significantly different results from scipy.stats implementation.
My data contains 300 records, with 6 anonymized categorical features and the label. My focus is on the feature A. This data is available here in github. In the folder, see the file sample300.csv, alongside the notebook with my testing code.
For the feature A, sklearn's SelectKBest() returned the lowest ranking, suggesting there is no correlation between A and label. But scipy.stats.chi2_contingency() returned very different result, suggesting the correlation is very high.
Because of mismatch between the two, I went a long way performing a number of different tests described in detail in this article The results suggest that the scipy implementation is correct, while sklearn implementation is incorrect.
This conclusion surprising, given the popularity of sklearn.feature_selection_SelectKBest. Why are the two implementations of chi2 producing contradicting results? Did I make a methodical error somewhere or is this really a bug? I am looking forward for some critical peer review.