predict.modelBag {ebmc} | R Documentation |
Predict Method for modelBag Object
Description
Predicting instances in test set using modelBag object
Usage
## S3 method for class 'modelBag'
predict(object, newdata, type = "prob", ...)
Arguments
object |
A object of modelBag class. |
newdata |
A data frame object containing new instances. |
type |
Types of output, which can be prob (probability) and class (predicted label). Default is prob. |
... |
Not used currently. |
Value
Two type of output can be selected:
prob |
Estimated probability of being a minority instance (i.e. 1). The probability is averaged by using an equal-weight majority vote by all weak learners. |
class |
Predicted class of the instance. Instances of probability larger than 0.5 are predicted as 1, otherwise 0. |
Examples
data("iris")
iris <- iris[1:70, ]
iris$Species <- factor(iris$Species, levels = c("setosa", "versicolor"), labels = c("0", "1"))
samp <- sample(nrow(iris), nrow(iris) * 0.7)
train <- iris[samp, ]
test <- iris[-samp, ]
model <- ub(Species ~ ., data = train, size = 10, alg = "c50") # Build UnderBagging model
prob <- predict(model, newdata = test, type = "prob") # return probability estimation
pred <- predict(model, newdata = test, type = "class") # return predicted class
[Package ebmc version 1.0.1 Index]