# NOT RUN {
<!-- %% @test .port Database port number -->
<!-- %% @test .dbname Database name -->
## 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)
# }
Run the code above in your browser using DataLab