predict.modelBag: Predict Method for modelBag Object

Description Usage Arguments Value Examples

View source: R/ebmc.R

Description

Predicting instances in test set using modelBag object

Usage

1
2
 ## 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

1
2
3
4
5
6
7
8
9
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

ebmc documentation built on Jan. 11, 2022, 1:06 a.m.

Related to predict.modelBag in ebmc...