栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

ANOVA in python with 2018 FIFA data

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ANOVA in python with 2018 FIFA data

Data Science Day 21:

Last time we showed an example of using the independent T-test to compare the Age mean value between players in Real Madrid and Barcelona. What statistical method should we use if we want to compare the age mean among the players in Barcelona, Real Madrid, and Juventus?

kappilrinesh / Pixabay

RonnyK / Pixabay

RonnyK / Pixabay[/caption]

Answer:

We will use ANOVA( analysis of variance) Test, a case of GLM(Generalized Linear Model), for comparing the means between more than 2 groups.

Null Hypothesis: Mean(A) = Mean(B) = Mean©

ANOVA Assumptions:
  • Normality of the dependent variable
  • Homogeneity of Variance
  • Independent of observations

Example: Kaggle FIFA 2018 dataset

Null Hypothesis: There is NO significance in the mean of players’ age among Real Madrid, Barcelona, and Juventus.

H0:  Age.mean(Real Madrid) = Age.mean(Barcelona) = Age.mean(Juventus)

  1. Dataset

    We choose the variable Age and Club (Real Madrid, Barcelona, and Juventus).

data2=data1.loc[data1["club"].isin(["Real Madrid CF", "FC Barcelona","Juventus"])]

2.Histogram Plot

plt.hist(data3.age, bins="auto", color="c" ,edgecolor="k",alpha=0.5)
plt.hist(data4.age, bins="auto", color="r",edgecolor="k", alpha=0.5)
plt.hist(data5.age, bins="auto", color="y",edgecolor="k", alpha=0.5)
plt.xlabel('Age')
plt.ylabel('Frequency')
plt.title('Age Dist in Barcelona vs MFC vs Juventus')

plt.show()

3. KDE Density Plot

#kde
df=pd.Dataframe({"mfc": data3.age, "barcelona":data4.age,
  "juventus": data5.age ,})
ax=df.plot.kde()
plt.title("Density Plot for Players' Age in Barcelona vs MFC vs Juventus")
plt.show()

4. ANOVA Test
stats.f_oneway(data3.age, data4.age, data5.age)
F_onewayResult(statistic=4.8827728579356524, pvalue=0.010152460067260918)

Outcome:

F-statistics 4.88 and P-value= 0.01 which is indicating there is an overall significance of the players’ mean age among MFC, Barcelona, and Juventus. Both Histogram and Density plots supported the outcome.  However, we don’t know where the difference lies between the groups, we can use the Bonferroni Method for further investigation.

Bonus:

I remember Song asked me, it is good to know what ANOVA is used for, but do you know which test generates the P-value of ANOVA?

I thought since ANOVA has similar application as T-test, so the t.test generates P-value.
However, the truth is F-test generates the ANOVA’s P-value.

Later, little rain mentioned T-test and F-test is convertible with the relation T^{2}= F.
We will go over the relationship between T-test and F-test next time!

Happy Studying and Soccer game watching! ⚽

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/221783.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号