I am trying to identify what attributes are not relevant in my dataset to remove them before fitting a classifier.

The target is a categorical variable with three different values.

I also have a lot of numerical attributes.

For ANOVA, I used the following code:

grouped_test2=df[['room_type', 'price']].groupby(['room_type'])
f_val, p_val = stats.f_oneway(grouped_test2.get_group('Entire home/apt')['price'], grouped_test2.get_group('Private room')['price'], grouped_test2.get_group('Shared room')['price'])  

The independent variable is room_type, and the explanatory variable is price.

In this case, the f_val is equal to 1061.64 and p_val is equal to 0.

I read that 0 or values near 0 imply a relationship between the two variables but I am not sure about that?

What mean f_val is near enough to 0 to can say that the two variables are related?


f_val is the F Statistic value. Mathematically it is

$ F = \frac{MS_{Between}}{MS_{Within}}$

The null hypothesis for your ANOVA is

$H_0: \mu_{Entire home/apt} = \mu_{Private room} = \mu_{Shared room} $ which means all means ($\mu_i$ s) are equal and there is no need of grouping using explanatory variable


$H_A:$ At least one $\mu_i$ is different. There is a need for grouping

The p-value for this test was very very low, hence python returned 0. Anything less than 0.05 is considered low enough to reject the null hypothesis.

Independent variables are also called explanatory variables. I believe price is a dependent variable.

  • $\begingroup$ So null hipotesis is H_0, and if a this is rejected there are any relation between the variables right? so really for know if thre are any relation F value is not need right? $\endgroup$ – Tlaloc-ES Nov 9 '19 at 0:50

You have to compare F to your critical value for accepting the null or rejecting the null hypothesis. I can't tell what your critical value is, but you will reject H0 if F > critical value and you can not reject H0 if F < critical value. An F value of 1061.64 seems quite significant! I would say your F value is almost certainly statistically significant at that level. Also a P value < .05 is considered statistically significant. If your P is 0, this is definitely statistically significant!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.