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

View source: R/bsnsing.R

predict.mbsnsingR Documentation

Make Predictions with a bsnsing Model

Description

Make Predictions with a bsnsing Model

Usage

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

Arguments

object

an object of class mbsnsing.

newdata

an 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 in each class, and 'class' predicts the class membership.

...

further arguments to predict.mbsnsing.

Value

a data frame containing the predicted values.

Examples

## Not run: 
n <- nrow(iris)
train_index <- sample(1:n, round(0.5*n))
test_index <- setdiff(1:n, train_index)
# Fit a model on the training set
bs <- bsnsing(Species ~ ., data = iris, subset = train_index)
# Make predictions on the test set
pred <- predict(bs, iris[test_index, ], type = 'class')
# Display the confusion matrix
table(pred, actual = iris[test_index, 'Species'])
# Predict the probabilities
predprob <- predict(bs, iris[test_index, ], type = 'prob')
head(predprob)

## End(Not run)

profyliu/bsnsing documentation built on July 5, 2022, 8:10 a.m.