Prediction using the parametric model are calculated using the method of Quinlan (1992). If neighbors is greater than zero, these predictions are adjusted by training set instances nearby using the approach of Quinlan (1993).

# S3 method for class 'cubist'
predict(object, newdata = NULL, neighbors = 0, ...)

Arguments

object

an object of class cubist

newdata

a data frame of predictors (in the same order as the original training data). Must have column names.

neighbors

an integer from 0 to the number of training set rows: how many instances to use to correct the rule-based prediction? Quinlan's original code limited this to 9. Only training set points that are closer than the average distance between training points are used as neighbors. If fewer than half of the requested neighbors are found within that distance, the rule-based prediction is returned without correction. Because of this, large values of neighbors can result in fewer corrected predictions. Prediction time also increases with neighbors.

...

other options to pass through the function (not currently used)

Value

a numeric vector is returned

Details

If a factor or character column in newdata has a value that was not in the training set, that value is treated as missing and a warning is issued. As for other missing values, Cubist then uses the most frequent training set value. Infinite values are an error.

References

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 (1993) pp. 236-243

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

http://rulequest.com/cubist-info.html

Author

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

Examples


library(mlbench)
data(BostonHousing)

## 1 committee and no instance-based correction, so just an M5 fit:
mod1 <- cubist(x = BostonHousing[, -14], y = BostonHousing$medv)
predict(mod1, BostonHousing[1:4, -14])
#> [1] 29.00493 22.19729 34.17934 32.97410

## now add instances
predict(mod1, BostonHousing[1:4, -14], neighbors = 5)
#> [1] 26.07685 21.67079 33.87119 34.64103

# New levels are treated as missing values
iris_test <- iris
iris_test$Species <- as.character(iris_test$Species)

mod <- cubist(x = iris_test[1:99, 2:5],
              y = iris_test$Sepal.Length[1:99])

# 'virginica' is not in the training set:
predict(mod, iris_test[100:105, 2:5])
#> Warning: `newdata` has values that were not in the training set; they are treated as
#> missing:
#> • Species: "virginica"
#> [1] 5.888 7.100 6.308 6.872 6.668 6.824