8.2 Use the ore.predict Function
These examples demonstrate the use of the ore.predict function.
Example 8-2 Using the ore.predict Function on a Generalized Linear Regression Model
This example builds a generalized linear model using the infert data set and then calls the ore.predict function on the model.
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)Listing for This Example
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
Example 8-3 Using the ore.predict Function on an ore.model Model
This example pushes the iris data set to the database as the temporary table IRIS and the corresponding ore.frame proxy, IRIS. The example builds a linear regression model, IRISModel2, using the ore.lm function. It scores the model and adds a column to IRIS.
IRIS <- ore.push(iris) IRISModel2 <- ore.lm(Sepal.Length ~ ., data = IRIS) IRIS$PRED <- ore.predict(IRISModel2, IRIS) head(IRIS, 3)
Listing for This Example
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.773097Parent topic: Prediction With R Models