According to the answer to this post, it is recommended to use one-way anova to compute the dependence between a categorical and a numerical variable.
Besides, the second answer to this post says that:
The most classic "correlation" measure between a nominal and an interval ("numeric") variable is Eta, also called correlation ratio, and equal to the root R-square of the one-way ANOVA (with p-value = that of the ANOVA).
I would appreciate if you could let me know:
- how the correlation ratio is computed using one-way anova?
- why this kernel in the following code used
np.log(1./anova['p'])when it intends to plot the correlation between a categorical and a numeric feature using one-way anova?
for cat in cat_features: group_prices =  for group in train[cat].unique(): group_prices.append(train[train[cat] == group]['SalePrice'].values) f, p = scipy.stats.f_oneway(*group_prices) anova['feature'].append(cat) anova['f'].append(f) anova['p'].append(p) anova = pd.DataFrame(anova) anova = anova[['feature','f','p']] anova.sort_values('p', inplace=True) # Plot plt.figure(figsize=(14,6)) sns.barplot(anova.feature, np.log(1./anova['p'])) plt.xticks(rotation=90) plt.show()
Thanks in advance.