predict.bsnsing {bsnsing} | R 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 |
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'])
[Package bsnsing version 1.0.1 Index]