予測のためのモデリング問題

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...