5.1 About the ore.predict Function

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, to make predictions.

R allows you to build many kinds of models. When you score data to predict new results using an R model, the data to score must be in an R data.frame. With the ore.predict function, you can use an R model to score database-resident data in an ore.frame object.

The ore.predict function provides the fastest way to operationalize R-based models for scoring in Oracle Database. The function has no dependencies on PMML or any other plug-ins.

Some advantages of using the ore.predict function to score data in the database are the following:

  • Uses R-generated models to score in-database data.

    The data to score is in an ore.frame object.

  • Maximizes the use of Oracle Database as a compute engine.

    The database provides a commercial grade, high performance, scalable scoring engine.

  • Simplifies application workflow.

    You can go from a model to SQL scoring in one step.

The ore.predict function is a generic function. It has the following usage:

ore.predict(object, newdata, ...)

The value of the object argument is one of the model objects listed in Table 5-1. The value of the newdata argument is an ore.frame object that contains the data to score. The ore.predict function has methods for use with specific R model classes. The ... argument represents the various additional arguments that are accepted by the different methods.

Function ore.predict has methods that support the model objects listed in Table 5-1.

Table 5-1 Models Supported by the ore.predict Function

Class of Model Description of Model

glm

Generalized linear model

kmeans

k-Means clustering model

lm

Linear regression model

matrix

A matrix with no more than 1000 rows, for use in an hclust hierarchical clustering model

multinom

Multinomial log-linear model

nnet

Neural network model

ore.model

An Oracle R Enterprise model from the OREModels package

prcomp

Principal components analysis on a matrix

princomp

Principal components analysis on a numeric matrix

rpart

Recursive partitioning and regression tree model

For the function signatures of the ore.predict methods, invoke the help function on the following, as in help("ore.predict-kmeans"):

  • ore.predict-glm

  • ore.predict-kmeans

  • ore.predict-lm

  • ore.predict-matrix

  • ore.predict-multinom

  • ore.predict-nnet

  • ore.predict-ore.model

  • ore.predict-prcomp

  • ore.predict-princomp

  • ore.predict-rpart