Learn R Programming

OneR (version 2.2)

predict.OneR: Predict method for OneR models

Description

Predict cases or probabilities based on OneR model object.

Usage

# S3 method for OneR
predict(object, newdata, type = c("class", "prob"), ...)

Arguments

object
object of class "OneR".
newdata
data frame in which to look for the feature variable with which to predict.
type
character string denoting the type of predicted value returned. Default "class" gives a named vector with the predicted classes, "prob" gives a matrix whose columns are the probability of the first, second, etc. class.
...
further arguments passed to or from other methods.

Value

The default is a factor with the predicted classes, if "type = prob" a matrix is returned whose columns are the probability of the first, second, etc. class.

Details

newdata can have the same format as used for building the model but must at least have the feature variable that is used in the OneR rules. If cases appear that were not present when building the model the predicted case is UNSEEN or NA when "type = prob".

References

https://github.com/vonjd/OneR

See Also

OneR

Examples

Run this code
model <- OneR(iris)
prediction <- predict(model, iris[1:4])
eval_model(prediction, iris[5])

## type prob
predict(model, data.frame(Petal.Width = seq(0, 3, 0.5)))
predict(model, data.frame(Petal.Width = seq(0, 3, 0.5)), type = "prob")

Run the code above in your browser using DataLab