ソナーでのロジスティック回帰

Rで学ぶ caret を使った Machine Learning

Max Kuhn

Software Engineer at RStudio and creator of caret

分類モデル

  • 目的変数はカテゴリ(質的)
  • 例:ローンはデフォルトするか?
  • 依然として教師あり学習
  • 性能評価に訓練/テスト分割を使用
  • Sonar データセットを使用
  • 目標:岩石と機雷を判別
Rで学ぶ caret を使った Machine Learning

例:Sonar データ

# Load the Sonar dataset
library(mlbench)
data(Sonar)
# Look at the data
Sonar[1:6, c(1:5, 61)]
      V1     V2     V3     V4     V5 Class
1 0.0200 0.0371 0.0428 0.0207 0.0954     R
2 0.0453 0.0523 0.0843 0.0689 0.1183     R
3 0.0262 0.0582 0.1099 0.1083 0.0974     R
4 0.0100 0.0171 0.0623 0.0205 0.0205     R
5 0.0762 0.0666 0.0481 0.0394 0.0590     R
6 0.0286 0.0453 0.0277 0.0174 0.0384     R
Rで学ぶ caret を使った Machine Learning

データ分割

  • データを訓練用とテスト用にランダム分割
  • 80/20 ではなく 60/40 を使用
  • Sonar は小規模のため、60/40 でテストが大きく信頼性向上
Rで学ぶ caret を使った Machine Learning

データ分割

# Randomly order the dataset
rows <- sample(nrow(Sonar))
Sonar <- Sonar[rows, ]
# Find row to split on
split <- round(nrow(Sonar) * 0.60)
train <- Sonar[1:split, ]
test <- Sonar[(split + 1):nrow(Sonar), ]
# Confirm test set size
nrow(train) / nrow(Sonar)
0.6009615
Rで学ぶ caret を使った Machine Learning

Let's practice!

Rで学ぶ caret を使った Machine Learning

Preparing Video For Download...