Total Articles 284
https://github.com/PacktPublishing/Statistics-for-Machine-Learning
2021.02.16 13:10:44 (*.247.149.239)
# Chi-square independence test
import pandas as pd
from scipy import stats
pd.read_csv()
survey = pd.read_csv("survey.csv")
# Tabulating 2 variables with row & column variables respectively
survey_tab = pd.crosstab(survey.Smoke, survey.Exer, margins = True)
# Creating observed table for analysis
observed = survey_tab.iloc[0:4,0:3]
contg = stats.chi2_contingency(observed= observed)
p_value = round(contg[1],3)
print ("P-value is: ",p_value)