Learn R Programming

PivotalR (version 0.1.18.5)

plot.dt.madlib: Plot the result of madlib.rpart

Description

This is a visualization function which plots the result of madlib.rpart. This function internally calls R's plot.rpart function.

Usage

# S3 method for dt.madlib
plot(x, uniform = FALSE, branch = 1, compress = FALSE,
        nspace, margin = 0, minbranch = 0.3, ...)

Arguments

x

The fitted tree from the result of madlib.rpart

uniform

A boolean, if TRUE, uses uniform vertical spacing of the nodes.

branch

A double value, between 0 and 1, to control the shape of the branches from parent to child.

compress

A boolean, if FALSE, the leaf nodes will be at the horizontal plot coordinate of 1:nleaves. Use TRUE for a more compact arrangement.

nspace

A double value, indicating the amount of extra space between a node with children and a leaf. default is branch

margin

A double value, indicating the amount of extra space to leave around the borders of the tree.

minbranch

A double value, specifying the minimum length for a branch.

Arguments to be passed to or from other methods.

Value

The coordinates of the nodes are returned as a list, with components x and y.

References

[1] Documentation of decision tree in MADlib 1.6, https://madlib.apache.org/docs/latest/

See Also

madlib.rpart is the wrapper for MADlib's tree_train function for decision trees. text.dt.madlib, print.dt.madlib are other visualization functions.

madlib.lm, madlib.glm, madlib.rpart, madlib.summary, madlib.arima, madlib.elnet are all MADlib wrapper functions.

Examples

Run this code
# 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)

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

## decision tree using abalone data, using default values of minsplit,
## maxdepth etc.
key(x)<-"id"
fit <- madlib.rpart(rings < 10 ~ length + diameter + height + whole + shell,
       data=x, parms = list(split='gini'), control = list(cp=0.005))
fit

plot(fit, uniform =TRUE)
text(fit)

db.disconnect(cid)
# }

Run the code above in your browser using DataLab