predict.bsnsing {bsnsing} | R Documentation |
bsnsing
ModelImplements the generic predict
function to make predictions on new data using a trained bsnsing
model.
## S3 method for class 'bsnsing'
predict(object, newdata = NULL, type = c("prob", "class"), ...)
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. |
a vector containing the predicted values.
# 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'])