예측을 위한 모델링 문제

Tidyverse로 하는 데이터 모델링

Albert Y. Kim

Assistant Professor of Statistical and Data Sciences

모델링 문제

$y = f(\vec{x}) + \epsilon$을 고려합니다.

  1. $f()$와 $\epsilon$은 알 수 없음
  2. $y$와 $\vec{x}$의 $n$개 관측값은 데이터에 주어짐
  3. 목표: $\epsilon$을 무시하고 $f()$를 근사하는 모델 $\hat{f}()$ 적합
  4. 목표 재정의: 신호노이즈 분리
  5. 적합/예측값 $\hat{y} = \hat{f}(\vec{x})$ 생성 가능
Tidyverse로 하는 데이터 모델링

설명과 예측의 차이

모델링 목표의 주요 차이:

  1. 설명: $\hat{f}()$의 형태, 특히 $y$와 $\vec{x}$ 간의 관계를 나타내는 값에 관심
  2. 예측: $\hat{f}()$의 형태보다 $\vec{x}$를 기반으로 $y$를 "잘" 예측하는 $\hat{y}$ 생성에 관심
Tidyverse로 하는 데이터 모델링

주택 상태

house_prices %>% 
  select(log10_price, condition) %>% 
  glimpse()
Observations: 21,613
Variables: 2
$ log10_price <dbl> 5.346157, 5.730782, 5.255273...
$ condition   <fct> 3, 3, 3, 5, 3, 3, 3, 3, 3, 3, 3...
Tidyverse로 하는 데이터 모델링

탐색적 데이터 시각화: 박스플롯

library(ggplot2)
library(dplyr)
library(moderndive)

# Apply log10-transformation to outcome variable
house_prices <- house_prices %>%
  mutate(log10_price = log10(price))

# Boxplot ggplot(house_prices, aes(x = condition, y = log10_price)) + geom_boxplot() + labs(x = "house condition", y = "log10 price", title = "log10 house price over condition")
Tidyverse로 하는 데이터 모델링

탐색적 데이터 시각화: 박스플롯

Tidyverse로 하는 데이터 모델링

탐색적 데이터 요약

house_prices %>% 
  group_by(condition) %>% 
  summarize(mean = mean(log10_price),
            sd = sd(log10_price), n = n())
# A tibble: 5 x 4
  condition  mean    sd     n
  <fct>     <dbl> <dbl> <int>
1 1          5.42 0.293    30
2 2          5.45 0.233   172
3 3          5.67 0.224 14031
4 4          5.65 0.228  5679
5 5          5.71 0.244  1701
Tidyverse로 하는 데이터 모델링

탐색적 데이터 요약

# Prediction for new house with condition 4 in dollars
10^(5.65)
446683.6
Tidyverse로 하는 데이터 모델링

연습해 봅시다!

Tidyverse로 하는 데이터 모델링

Preparing Video For Download...