9.2 ore.predict関数の使用
次の例では、ore.predict
関数の使用方法を示します。
例9-2 一般化線形回帰モデルでのore.predict関数の使用方法
この例では、infert
データセットを使用して一般化線形モデルを構築した後、そのモデルでore.predict
関数をコールします。
infertModel <- glm(case ~ age + parity + education + spontaneous + induced, data = infert, family = binomial()) INFERT <- ore.push(infert) INFERTpred <- ore.predict(infertModel, INFERT, type = "response", se.fit = TRUE) INFERT <- cbind(INFERT, INFERTpred) head(INFERT)
この例のリスト
R> infertModel <-
+ glm(case ~ age + parity + education + spontaneous + induced,
+ data = infert, family = binomial())
R> INFERT <- ore.push(infert)
R> INFERTpred <- ore.predict(infertModel, INFERT, type = "response",
+ se.fit = TRUE)
R> INFERT <- cbind(INFERT, INFERTpred)
R> head(INFERT)
education age parity induced case spontaneous stratum pooled.stratum
1 0-5yrs 26 6 1 1 2 1 3
2 0-5yrs 42 1 1 1 0 2 1
3 0-5yrs 39 6 2 1 0 3 4
4 0-5yrs 34 4 2 1 0 4 2
5 6-11yrs 35 3 1 1 1 5 32
6 6-11yrs 36 4 2 1 1 6 36
PRED SE.PRED
1 0.5721916 0.20630954
2 0.7258539 0.17196245
3 0.1194459 0.08617462
4 0.3684102 0.17295285
5 0.5104285 0.06944005
6 0.6322269 0.10117919
例9-3 ore.modelモデルでのore.predict関数の使用方法
この例では、iris
データセットを一時表IRISおよび対応するore.frame
プロキシIRIS
としてデータベースにプッシュします。ore.lm
関数を使用して線形回帰モデルIRISModel2
を構築します。モデルをスコアリングし、列がIRIS
に追加します。
IRIS <- ore.push(iris) IRISModel2 <- ore.lm(Sepal.Length ~ ., data = IRIS) IRIS$PRED <- ore.predict(IRISModel2, IRIS) head(IRIS, 3)
この例のリスト
R> IRIS <- ore.push(iris)
R> IRISModel2 <- ore.odmGLM(Sepal.Length ~ ., data = IRIS)
R> IRIS$PRED <- ore.predict(IRISModel, IRIS)
R> head(IRIS, 3)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species PRED
1 5.1 3.5 1.4 0.2 setosa 5.004788
2 4.9 3.0 1.4 0.2 setosa 4.756844
3 4.7 3.2 1.3 0.2 setosa 4.773097
親トピック: Rモデルでの予測