Help us understand the problem. What is going on with this article?

H2O AutoMLでR上でタイタニックの生存予測をしてみる

More than 1 year has passed since last update.

はじめに

SIGNATEの練習問題であるタイタニックの生存予測をRとH2Oでしてみます。ついでに、H2OのAutoMLを試してみてどんなモデルができるかを見てみます。

実行したコード

なにはともあれ、実行したコードを示します。

require(h2o)

# H2Oを起動
local.H2O <- h2o.init()

# データをロードする
train.df <- read.table("train.tsv", sep = "\t", header = T)
test.df <- read.table("test.tsv", sep = "\t", header = T)

# 欠損値を埋める
train.df$age <- ifelse(is.na(train.df$age), mean(train.df$age, na.rm = T), train.df$age)
test.df$age <- ifelse(is.na(test.df$age), mean(test.df$age, na.rm = T), test.df$age)

# H2Oのオブジェクトに変換する
train.hex <- as.h2o(train.df)
test.hex <- as.h2o(test.df)

# survivedを変換する
train.hex$survived <- as.factor(train.hex$survived)

# AutoMLを実行
automl.hex <- h2o.automl(x = c(3,4,5,6,7,8,9), y = 2, training_frame = train.hex)

# 予測を行う
predict.hex <- h2o.predict(automl.hex, test.hex)

# 予測結果を整える
predict.df <- as.data.frame(predict.hex)
submit.df <- data.frame(id = test.df$id, p = predict.df$p1)

# H2O を終了
h2o.shutdown(prompt = FALSE)

# 予測結果を保存
write.table(submit.df, file = "submit.tsv", sep = "\t", row.names = F, col.names = F)

コードそのものはいたってシンプルで、欠損値の見られる年齢を平均値で欠損を埋めて、H2OのAutoMLで2値予測をするコードです。

どんなモデルができたか

テスト実行したときの、実行結果のモデルを確認したところ、GBMとDeepLearningからなるStacked Ensembleなモデルができたようです。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away