시작하기무료로 시작하기

밀도 플롯 비교하기

이전에 수행한 다양한 대치(imputation)는 밀도 플롯으로 시각적으로 비교할 수 있습니다. 이러한 플롯을 통해 원본 데이터셋과 분포가 가장 유사한 데이터셋을 쉽게 분석해 찾을 수 있어요. 또한 대치 방법이 어떻게 편향을 유발할 수 있는지도 확인할 수 있습니다.

이번 연습 문제에서는 앞에서 만들어 둔 diabetes의 대치된 DataFrame들의 밀도 플롯을 비교해 보겠습니다.

diabetes_cc, diabetes_mean_imputed, diabetes_knn_imputed, diabetes_mice_imputed DataFrame이 이미 로드되어 있으며, matplotlib.pyplotplt로 임포트되어 있습니다.

이 연습은 강의의 일부입니다

Python에서 결측치 다루기

강의 보기

연습 안내

  • 각 DataFrame의 'Skin_Fold' 열에 대해 밀도 플롯을 그리세요.
  • labels 리스트를 사용해 레이블을 설정하세요.
  • x축 레이블을 'Skin Fold'로 설정하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Plot graphs of imputed DataFrames and the complete case
diabetes_cc['___'].___(___='___', c='red', linewidth=3)
diabetes_mean_imputed['___'].plot(___='___')
diabetes_knn_imputed['___'].plot(___='___')
diabetes_mice_imputed['___'].plot(___='___')

# Create labels for the four DataFrames
labels = ['Baseline (Complete Case)', 'Mean Imputation', 'KNN Imputation', 'MICE Imputation']
plt.legend(___)

# Set the x-label as Skin Fold
plt.xlabel('___')

plt.show()
코드 편집 및 실행