predict.mbsnsing | R Documentation |
bsnsing
ModelMake Predictions with a bsnsing
Model
## S3 method for class 'mbsnsing' predict(object, newdata = NULL, type = c("prob", "class"), ...)
object |
an object of class |
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. |
a data frame containing the predicted values.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.