*I calculate chi square but I got a different result from orang3 program and python, is there reason?
*this is number I got from python
0 수분섭취량(ml) 18.932143 0.755599
1 알코올 섭취량(g) 22.009615 0.519671
2 나트륨 섭취량(mg) 84.000000 0.448668
3 당 섭취량(g) 49.275000 0.382270
4 식이섬유 섭취량(g) 19.560714 0.848676
5 트랜스지방 섭취량(g) 13.391551 0.643942
*And this is number I got by orange3
orange3 chisquare number
*This is all the info of table I used
FYI
*This is python code I used
import pandas as pd
import scipy.stats as stats
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib import font_manager, rc
font_path = "C:/Windows/Fonts/malgun.ttf" # Windows의 'Malgun Gothic' 폰트 경로
font = font_manager.FontProperties(fname=font_path).get_name()
rc('font', family=font)
data = pd.read_csv('C:/Users/tlotr/OneDrive/바탕 화면/BYDIET/개구리모재후통합사전식단_caloricateglrized.csv', encoding='euc-kr')
data.info()
variables = ['수분섭취량(ml)', '알코올 섭취량(g)', '나트륨 섭취량(mg)', '당 섭취량(g)', '식이섬유 섭취량(g)', '트랜스지방 섭취량(g)']
chi2_results = []
for var in variables:
contingency_table = pd.crosstab(data['칼로리C'], data[var])
chi2, p, _, _ = stats.chi2_contingency(contingency_table)
chi2_results.append((var, chi2, p))
chi2_results_df = pd.DataFrame(chi2_results, columns=['Variable', 'Chi2', 'p-value'])
print(chi2_results_df)
plt.figure(figsize=(12, 8))
sns.barplot(x='Variable', y='Chi2', data=chi2_results_df)
plt.title('카이제곱 검정 결과')
plt.xlabel('변수')
plt.ylabel('Chi2 값')
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
*This is Orange3 I used
Orage3 GuI
R reco is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.