Description Usage Arguments Value Author(s) References See Also Examples
A generic function to do boostrap aggregating for a given machine learning model. The user might need to write a wrapper for the training function so that they could satisfy the format requirements desceribed in the following.
1 | generic.bagging(train, data, nbags = 10, fraction = 1)
|
train |
A training function. It must have only one argument
|
data |
A |
nbags |
An integer, default is 10. The number of bagging sampling. |
fraction |
A double, default is 1. The fraction of data in each bagging sample. |
A bagging.model
object, which is actually a list of fitted
models.
Author: Predictive Analytics Team at Pivotal Inc.
Maintainer: Frank McQuillan, Pivotal Inc. fmcquillan@pivotal.io
[1] Wiki: bagging https://en.wikipedia.org/wiki/Bootstrap_aggregating
predict.bagging.model
makes predictions using the result
of this function.
generic.cv
for cross-validation
sample,db.obj-method
samples data from a table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## 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)
delete("abalone", conn.id = cid)
as.db.data.frame(abalone, "abalone", conn.id = cid, verbose = FALSE)
y <- db.data.frame("abalone", conn.id = cid)
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.