Skip Headers
Oracle® R Enterprise User's Guide
Release 1.3 for Windows, Linux, Solaris, and AIX

E36761-08
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

5 Predicting with R Models

Predictive models allow you to predict future behavior based on past behavior. After you build a model, you use it to score new data, that is, make predictions.

R allows you to build many kinds of models. When you predict new results (score data) using an R model, the data must be in an R frame. The ore.predict package, included with Oracle R Enterprise, allows you to use an R model to score data that is in an ore.frame, that is, database resident- data.

ore.predict() allows you to make predictions only using ore.frame objects; you cannot rebuild the model.

If you need to build models with data in a database table, consider building an Oracle Data Mining model using the OREdm package, described in In-Database Predictive Models in Oracle R Enterprise.

For more information, see the R help associated with ore.predict().

ore.predict for R Models

ore.predict() allows you to score (predict using) these R models:

  • lm()Linear regression models

  • glm() Generalized linear models

  • hclust() Hierarchical clustering models

  • kmeans() (k-Means clustering)

  • negbin() (glm.nb) Negative binomial generalized binomial models

  • nnet::multinom Multinomial log-linear model

  • nnet::nnet neural network models

  • rpart::rpart Recursive partitioning and regression tree models

Examples

This code builds a linear regression model irisModel (built using lm) on the iris data and then scores IRIS (a table that could be created by pushing iris to the database):

R> irisModel <- lm(Sepal.Length ~ ., data = iris)
R> IRIS <- ore.push(iris)
R> IRISpred <- ore.predict(irisModel, IRIS, se.fit = TRUE, interval = "prediction")
R> IRIS <- cbind(IRIS, IRISpred)
R> head(IRIS)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species     PRED    SE.PRED LOWER.PRED UPPER.PRED
1          5.1         3.5          1.4         0.2  setosa 5.004788 0.04479188   4.391895   5.617681
2          4.9         3.0          1.4         0.2  setosa 4.756844 0.05514933   4.140660   5.373027
3          4.7         3.2          1.3         0.2  setosa 4.773097 0.04690495   4.159587   5.386607
4          4.6         3.1          1.5         0.2  setosa 4.889357 0.05135928   4.274454   5.504259
5          5.0         3.6          1.4         0.2  setosa 5.054377 0.04736842   4.440727   5.668026
6          5.4         3.9          1.7         0.4  setosa 5.388886 0.05592364   4.772430   6.005342