cubist.default {Cubist}R Documentation

Fit a Cubist model


This function fits the rule-based model described in Quinlan (1992) (aka M5) with additional corrections based on nearest neighbors in the training set, as described in Quinlan (1993a).


## Default S3 method:
cubist(x, y, committees = 1, control = cubistControl(), weights = NULL, ...)



a matrix or data frame of predictor variables. Missing data are allowed but (at this time) only numeric, character and factor values are allowed. Must have column names.


a numeric vector of outcome


an integer: how many committee models (e.g.. boosting iterations) should be used?


options that control details of the cubist algorithm. See cubistControl()


an optional vector of case weights (the same length as y) for how much each instance should contribute to the model fit. From the RuleQuest website: "The relative weight assigned to each case is its value of this attribute divided by the average value; if the value is undefined, not applicable, or is less than or equal to zero, the case's relative weight is set to 1."


optional arguments to pass (not currently used)


Cubist is a prediction-oriented regression model that combines the ideas in Quinlan (1992) and Quinlan (1993).

Although it initially creates a tree structure, it collapses each path through the tree into a rule. A regression model is fit for each rule based on the data subset defined by the rules. The set of rules are pruned or possibly combined. and the candidate variables for the linear regression models are the predictors that were used in the parts of the rule that were pruned away. This part of the algorithm is consistent with the "M5" or Model Tree approach.

Cubist generalizes this model to add boosting (when committees > 1) and instance based corrections (see predict.cubist()). The number of instances is set at prediction time by the user and is not needed for model building.

This function links R to the GPL version of the C code given on the RuleQuest website.

The RuleQuest code differentiates missing values from values that are not applicable. Currently, this packages does not make such a distinction (all values are treated as missing). This will produce slightly different results.

To tune the cubist model over the number of committees and neighbors, the caret::train() function in the caret package has bindings to find appropriate settings of these parameters.


an object of class cubist with elements:

data, names, model

character strings that correspond to their counterparts for the command-line program available from RuleQuest


basic cubist output captured from the C code, including the rules, their terminal models and variable usage statistics


a list of control parameters passed in by the user

composite, neighbors, committees

mirrors of the values to these arguments that were passed in by the user


the output if dim(x)


information about the variables and values used in the rule conditions


the function call


a data frame of regression coefficients for each rule within each committee


a list with elements all and used listing the predictors passed into the function and used by any rule or model


a numeric vector of predictions on the training set.


a data frame with the percent of models where each variable was used. See summary.cubist() for a discussion.


R code by Max Kuhn, original C sources by R Quinlan and modifications be Steve Weston


Quinlan. Learning with continuous classes. Proceedings of the 5th Australian Joint Conference On Artificial Intelligence (1992) pp. 343-348

Quinlan. Combining instance-based and model-based learning. Proceedings of the Tenth International Conference on Machine Learning (1993a) pp. 236-243

Quinlan. C4.5: Programs For Machine Learning (1993b) Morgan Kaufmann Publishers Inc. San Francisco, CA

Wang and Witten. Inducing model trees for continuous classes. Proceedings of the Ninth European Conference on Machine Learning (1997) pp. 128-137

See Also

cubistControl(), predict.cubist(), summary.cubist(), dotplot.cubist(), caret::train()



## 1 committee, so just an M5 fit:
mod1 <- cubist(x = BostonHousing[, -14], y = BostonHousing$medv)

## Now with 10 committees
mod2 <- cubist(x = BostonHousing[, -14], y = BostonHousing$medv, committees = 10)

[Package Cubist version 0.3.0 Index]