predict.bagging.model: Make predictions using the result of 'generic.bagging'

Description Usage Arguments Value Author(s) See Also Examples

View source: R/generic.bagging.R

Description

Make predictions using boostrap aggregating models

Usage

1
2
## S3 method for class 'bagging.model'
predict(object, newdata, combine = "mean", ...)

Arguments

object

A bagging.model, which is the result of generic.bagging.

newdata

A db.obj object, which wraps the data in the database.

combine

A string, default is "mean". The other choice is "vote". How to summarize the predictions of the multiple models in the fitting result of generic.bagging. "mean" will produce the average of the predictions, while "vote" will select the prediction with the most votes.

...

Extra parameters. Not implemented yet.

Value

A db.Rquery object, which contains the SQL query to compute the prediction. One can use the function lk to look at the values.

Author(s)

Author: Predictive Analytics Team at Pivotal Inc.

Maintainer: Frank McQuillan, Pivotal Inc. [email protected]

See Also

generic.bagging generates the models of boostrap aggregating.

predict.lm.madlib and predict.logregr.madlib produce predictions for linear and logistic models.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 


## set up the database connection
## Assume that .port is port number and .dbname is the database name
cid <- db.connect(port = .port, dbname = .dbname, verbose = FALSE)

y <- as.db.data.frame(abalone, conn.id = cid, verbose = FALSE)

fit <- generic.bagging(function(data) {
                           madlib.lm(rings ~ . - id - sex, data = data)
                       }, data = y, nbags = 25, fraction = 0.7)

pred <- predict(fit, newdata = y) # make prediction

lookat(mean((y$rings - pred)^2)) # mean squared error

db.disconnect(cid, verbose = FALSE)

## End(Not run)

PivotalR documentation built on May 30, 2017, 8:18 a.m.