이변량 범주-범주
크로스탭
pd.crosstab(titanic['Survived'], titanic['Sex'])
# 세로 비율 합이 1 / 비율로 출력
pd.crosstab(titanic['Survived'], titanic['Sex'], normalize = 'columns')
# 가로 비율 합이 1 / 비율로 출력
pd.crosstab(titanic['Survived'], titanic['Sex'], normalize = 'index')
# 전체 비율 합이 1
pd.crosstab(titanic['Survived'], titanic['Sex'], normalize = 'all')
모자이크 플롯
mosoic(data, ['col1', 'target']
plt.axhline(1-data['target'].mean())
plt.show()
카이제곱검정
카이 제곱 통계: 값이 클수록 기대빈도로부터 실제 값에 차이가 크다. 보통, 자유도의 2~3배 보다 크면, 차이가 있다고 본다.
# 1) 교차표 집계
table = pd.crosstab(data['target'], data['col1'])
# 2) 카이제곱검정
spst.chi2_contingency(table)
이변량 숫자-범주
히스토그램
sns.histplot(x='col1', data=data, hue='target')
plt.show()
1. kdeplot( , hue = 'target'): 두 그래프의 아래 면적의 합이 1
2. kdeplot( , hue = 'target', common_norm = False): 각각 그래프 면적의 합이 1인 그래프