predict.OneR {OneR}R Documentation

Predict method for OneR models

Description

Predict cases or probabilities based on OneR model object.

Usage

## S3 method for class '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.

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".

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.

Author(s)

Holger von Jouanne-Diedrich

References

https://github.com/vonjd/OneR

See Also

OneR

Examples

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")

[Package OneR version 2.2 Index]