모델 오류와 무작위성

Python으로 배우는 선형 모델 입문

Jason Vestuto

Data Scientist

오류의 유형

  1. 측정 오류
    • 예: 센서 고장, 잘못 기록된 측정값
  2. 표본 편향
    • 예: 가장 더운 8월의 기온 데이터만 사용
  3. 무작위 우연
Python으로 배우는 선형 모델 입문

귀무 가설

질문: 효과가 관계에 의한 것인가, 무작위 우연에 의한 것인가?

답: 귀무 가설을 확인하십시오.

Python으로 배우는 선형 모델 입문

정렬된 데이터

거리(마일) 대 시간(시간) 축에 표시된 하이킹 데이터 산점도

Python으로 배우는 선형 모델 입문

데이터 그룹화

거리(마일) 대 시간(시간) 축에 표시된 하이킹 데이터 산점도로, 5시간 미만은 빨간색, 초과는 파란색으로 표시됨

Python으로 배우는 선형 모델 입문

데이터 그룹화

종 모양의 두 히스토그램: 단기 여행(빨간색, 평균 약 5마일)과 장기 여행(파란색, 평균 약 15마일)

  • 단기 그룹, 평균 = 5
  • 장기 그룹, 평균 = 15
Python으로 배우는 선형 모델 입문

검정 통계량

# Group into early and late times
group_short = sample_distances[times < 5]
group_long = sample_distances[times > 5]
# Resample distributions
resample_short = np.random.choice(group_short, size=500, replace=True)
resample_long = np.random.choice(group_long, size=500, replace=True)
# Test Statistic
test_statistic = resample_long - resample_short
# Effect size as mean of test statistic distribution
effect_size = np.mean(test_statistic)
Python으로 배우는 선형 모델 입문

셔플 및 재그룹화

거리(마일) 대 시간(시간) 축에 표시된 하이킹 데이터 산점도로, 모든 시간 구간에 걸쳐 빨간색과 파란색이 혼재됨

Python으로 배우는 선형 모델 입문

셔플 및 재그룹화

0~25마일 범위에서 거의 동일한 형태로 겹치는 두 히스토그램

Python으로 배우는 선형 모델 입문

셔플 및 분할

# Concatenate and Shuffle
shuffle_bucket = np.concatenate((group_short, group_long))
np.random.shuffle(shuffle_bucket)
# Split in the middle
slice_index = len(shuffle_bucket)//2
shuffled_half1 = shuffle_bucket[0:slice_index]
shuffled_half2 = shuffle_bucket[slice_index+1:]
Python으로 배우는 선형 모델 입문

재샘플링 및 재검정

# Resample shuffled populations
shuffled_sample1 = np.random.choice(shuffled_half1, size=500, replace=True)
shuffled_sample2 = np.random.choice(shuffled_half2, size=500, replace=True)
# Recompute effect size
shuffled_test_statistic = shuffled_sample2 - shuffled_sample1
effect_size = np.mean(shuffled_test_statistic)
Python으로 배우는 선형 모델 입문

p-값

빈도 수 대 검정 통계량 구간 축에 표시된 두 히스토그램: x=0 중심의 넓게 퍼진 파란색 히스토그램, x=10 중심의 좁은 빨간색 히스토그램, x=10의 수직 검은 선

Python으로 배우는 선형 모델 입문

연습해 봅시다!

Python으로 배우는 선형 모델 입문

Preparing Video For Download...