tree | R Documentation |
Create either a classification or regression tree model.
tree(x, data, cp = 0.01, minsplit = 20, ...)
x |
Formula. An expression of the form |
data |
Data frame. The data where the variables can be found. |
cp |
Number. Stands for complexity parameter, which determins how simple or complex to build the model. Default value is 0.01. Smaller values result in more complex models. |
minsplit |
Integer. The minimum number of data points that need to be categorized into a node before the algorithm decides to split the node into a pair of branches. |
m1 <- tree(survived ~ age + embarked + class, data = titanic)
treeplot(m1)
# For a more complex model
m2 <- tree(survived ~ age + embarked + class, data = titanic, cp = 0.001, minsplit = 5)
treeplot(m2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.