요인 설계: 원리와 활용

Python으로 배우는 실험 설계

James Chapman

Curriculum Manager, DataCamp

요인 설계 이해하기

 

  • 한 실험에서 여러 독립변수/요인 연구
  • 요인 수준의 모든 조합을 시험
  • 직접 효과와 요인 간 상호작용 발견

빛 조건과 비료 종류가 식물 성장에 미치는 실험.

1 Image Generated with DALL·E 3
Python으로 배우는 실험 설계

요인 설계 데이터 예시

  • 요인 1(Light_Condition) - 두 수준: Full Sunlight, Partial Shade
  • 요인 2(Fertilizer_Type) - 두 수준: Synthetic, Organic
  • 수치 반응/종속/결과 변수: Growth_cm
plant_growth_data.head()
   Plant_ID  Light_Condition  Fertilizer_Type  Growth_cm
0         1    Full Sunlight        Synthetic  16.489735
1         2    Partial Shade          Organic  18.361689
2         3    Full Sunlight        Synthetic  18.039459
3         4    Full Sunlight          Organic  12.682425
4         5    Full Sunlight          Organic  21.480601
Python으로 배우는 실험 설계

상호작용 시각화를 위한 데이터 정리

plant_growth = pd.pivot_table(plant_growth_data, 
                              values='Growth_cm',
                              index='Light_Condition',
                              columns='Fertilizer_Type', 
                              aggfunc='mean')

plant_growth
Light_Condition     Organic   Synthetic
Full Sunlight       20.602       19.869
Partial Shade       20.246       20.326
Python으로 배우는 실험 설계

히트맵으로 상호작용 시각화

import seaborn as sns
import matplotlib.pyplot as plt
sns.heatmap(plant_growth, 
            annot=True, 
            cmap='coolwarm',
            fmt='g')
plt.show()

식물 성장 히트맵

Python으로 배우는 실험 설계

상호작용 해석

Light_Condition     Organic   Synthetic
Full Sunlight       20.602       19.869
Partial Shade       20.246       20.326
  • 상호작용: 한 요인의 효과가 다른 요인의 수준에 따라 달라짐
  • 상호작용이 유의함 → 요인들이 독립적으로 작동하지 않음
Python으로 배우는 실험 설계

요인 설계 vs. 무작위 블록 설계

  • 다수 처치와 상호작용
  • 복잡한 다변량 효과와 상호작용 분해
  • 더 많은 피험자 필요할 수 있음

빛 조건과 비료 종류가 식물 성장에 미치는 실험.

  • 무작위화 설계에서 유사한 피험자 블록화
  • 블록 내 분산 통제
  • 각 처치를 모든 블록에서 검증

무작위로 색이 지정된 큐브가 담긴 두 블록.

1 Images Generated with DALL·E 3
Python으로 배우는 실험 설계

연습해 봅시다!

Python으로 배우는 실험 설계

Preparing Video For Download...