What is the relationship between correlation ratio and one-way Anova?

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:

1. how the correlation ratio is computed using one-way anova?
2. 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?

The code:

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.

• Hi! about the second question I don't know unfortunately but as the response to the first question, have you seen here? – Media Jul 8 '18 at 13:11
• Eta squared = SSbetween-groups / SStotal. (where SSbetween-groups = SStotal - SSwithin-groups). – ttnphns Jul 8 '18 at 15:17
• @ttnphns Thanks a lot. Could you please let me know if the above one-way anova code are more informative to show the dependence between categorical and numerical variables or the following correlation ratio code:? towardsdatascience.com/… – ebrahimi Jul 8 '18 at 17:46
• The kernel claims that: we took the log of the inverse of the p-value (np.log(1./anova['p']): the inverse so that when we take the log we get positive numbers, and log so that we don't just see a single bar. In other words, the p-value is a magnitude of about 300 times smaller than the next feature! – ebrahimi Jul 8 '18 at 17:55
• @Media based on the above quotation, it seems that the kaggler just did it to be able to plot the p-value. – ebrahimi Jul 8 '18 at 18:01