predict.bsnsing: Make Predictions with a Fitted 'bsnsing' Model

View source: R/bsnsing.R

predict.bsnsingR Documentation

Make Predictions with a Fitted bsnsing Model

Description

Implements the generic predict function to make predictions on new data using a trained bsnsing model.

Usage

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

Arguments

object

a bsnsing model object.

newdata

a optional data frame in which to look for variables for prediction. If omitted, the fitted class or probability will be returned.

type

a character string indicating the type of prediction. 'prob' predicts the probability of being a positive case (i.e., y = 1), and 'class' predicts the class membership.

...

further arguments to predict.bsnsing.

Value

a vector containing the predicted values.

Examples

# Load data
n <- nrow(GlaucomaMVF)
train_index = sample(1:n, round(0.5*n))
test_index = setdiff(1:n, train_index)
# Fit a model using training set
bs <- bsnsing(Class ~ ., data = GlaucomaMVF, subset = train_index)
# Make predictions on the test set
pred <- predict(bs, GlaucomaMVF[test_index, ], type = 'class')
# Display the confusion matrix
table(pred, actual = GlaucomaMVF[test_index, 'Class'])

bsnsing documentation built on July 4, 2022, 1:06 a.m.