C5.0 Decision Trees and Rule-Based Models
Fit classification tree models or rule-based models using Quinlan's C5.0 algorithm
## Default S3 method: C5.0( x, y, trials = 1, rules = FALSE, weights = NULL, control = C5.0Control(), costs = NULL, ... ) ## S3 method for class 'formula' C5.0(formula, data, weights, subset, na.action = na.pass, ...)
x |
a data frame or matrix of predictors. |
y |
a factor vector with 2 or more levels |
trials |
an integer specifying the number of boosting iterations. A value of one indicates that a single model is used. |
rules |
A logical: should the tree be decomposed into a rule-based model? |
weights |
an optional numeric vector of case weights. Note that the data used for the case weights will not be used as a splitting variable in the model (see http://www.rulequest.com/see5-win.html#CASEWEIGHT for Quinlan's notes on case weights). |
control |
a list of control parameters; see
|
costs |
a matrix of costs associated with the possible errors. The matrix should have C columns and rows where C is the number of class levels. |
... |
other options to pass into the function (not currently used with default method) |
formula |
a formula, with a response and at least one predictor. |
data |
an optional data frame in which to interpret the variables named in the formula. |
subset |
optional expression saying that only a subset of the rows of the data should be used in the fit. |
na.action |
a function which indicates what should happen
when the data contain |
This model extends the C4.5 classification algorithms described in Quinlan (1992). The details of the extensions are largely undocumented. The model can take the form of a full decision tree or a collection of rules (or boosted versions of either).
When using the formula method, factors and other classes are preserved (i.e. dummy variables are not automatically created). This particular model handles non-numeric data of some types (such as character, factor and ordered data).
The cost matrix should by CxC, where C is the number of
classes. Diagonal elements are ignored. Columns should
correspond to the true classes and rows are the predicted
classes. For example, if C = 3 with classes Red, Blue and Green
(in that order), a value of 5 in the (2,3) element of the matrix
would indicate that the cost of predicting a Green sample as
Blue is five times the usual value (of one). Note that when
costs are used, class probabilities cannot be generated using
predict.C5.0()
.
Internally, the code will attempt to halt boosting if it
appears to be ineffective. For this reason, the value of
trials
may be different from what the model actually
produced. There is an option to turn this off in
C5.0Control()
.
An object of class C5.0
with elements:
boostResults |
a parsed version of the boosting table(s) shown in the output |
call |
the function call |
caseWeights |
not currently supported. |
control |
an echo of the specifications from
|
cost |
the text version of the cost matrix (or "") |
costMatrix |
an echo of the model argument |
dims |
original dimensions of the predictor matrix or data frame |
levels |
a character vector of factor levels for the outcome |
names |
a string version of the names file |
output |
a string version of the command line output |
predictors |
a character vector of predictor names |
rbm |
a logical for rules |
rules |
a character version of the rules file |
size |
n integer vector of the tree/rule size (or sizes in the case of boosting) |
.
tree |
a string version of the tree file |
trials |
a named vector with elements |
The command line version currently supports more data types than the R port. Currently, numeric, factor and ordered factors are allowed as predictors.
Original GPL C code by Ross Quinlan, R code and modifications to C by Max Kuhn, Steve Weston and Nathan Coulter
Quinlan R (1993). C4.5: Programs for Machine Learning. Morgan Kaufmann Publishers, http://www.rulequest.com/see5-unix.html
library(modeldata) data(mlc_churn) treeModel <- C5.0(x = mlc_churn[1:3333, -20], y = mlc_churn$churn[1:3333]) treeModel summary(treeModel) ruleModel <- C5.0(churn ~ ., data = mlc_churn[1:3333, ], rules = TRUE) ruleModel summary(ruleModel)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.