More Related Content More from TokorosawaYoshio (9) TokyoR4015. データベース(dplyr)
library(dplyr)
# コネクションの作成
mysrc <- src_mysql(host="hoge.com",
user="johndoe",password="12345")
# hogeテーブルを呼び出す
mytbl <- tbl(mysrc, "hoge")
# hogeテーブルに対しカウントをかける
mytbl %>% summarise(count=n())
dplyrのデータベース周りは下記から
http://rpubs.com/dichika/dplyr_db
32. SVM(サポートベクターマシン)
library(kernlab)
train <- ksvm(survived ~ pclass + sex + age + sibsp,
data = titanic.train)
predict(train, type="response", newdata=titanic.pred)
liblinearを使うものとJuliaで全部書いたものの2種類があ
ります。後者については下記が有用です。
http://qiita.com/chezou/items/d090f26dcb31818d6964
SVMのパラメータチューニングについては以下が有用。
http://d.hatena.ne.jp/sleepy_yoshi/20120624/p1
33. ランダムフォレスト
library(randomForest)
train <- randomForest (
as.factor(survived) ~ pclass + sex + age + sibsp,
data = titanic.train, na.action=na.omit)
predict(train, type="prob", newdata=titanic.pred)
パッケージはこちら
https://github.com/bensadeghi/DecisionTree.jl
決定木も含めた使用例はこちら
http://bensadeghi.com/decision-trees-julia/
34. GBM
library(gbm)
train <- gbm (survived ~ pclass + sex + age + sibsp,
data = titanic.train)
predict(train, type="response", newdata=titanic.pred,
n.trees=100)
Juliaのパッケージは見つけられず
GBMはパラメータが多いのでチューニングが面倒
チューニングの初歩として下記動画が有用
http://vimeo.com/71992876
35. ニューラルネットワーク
localH2O = h2o.init()
titanic.train.h2o <- as.h2o(localH2O,titanic.train)
titanic.pred.h2o <- as.h2o(localH2O,titanic.pred)
train <-h2o.deeplearning(x=c(1,4,5,6),
y=2,
data=titanic.train.h2o)
h2o.predict(train, newdata=titanic.pred.h2o)
Juliaのパッケージは見つけられず
h2oについては山下勝司さんの資料が有用
http://www.slideshare.net/yamakatu/mlct01-lt