Learn R Programming

randomMachines (version 0.1.1)

predict.rm_class: Prediction function for the rm_class_model

Description

This function predicts the outcome for a RM object model using new data

Usage

# S4 method for rm_class
predict(object,newdata)

Value

A vector of predicted outcomes: probabilities in case of `prob_model = TRUE` and classes in case of `prob_model = FALSE`.

Arguments

object

A fitted RM model object of class rm_class.

newdata

A data frame or matrix containing the new data to be predicted.

Examples

Run this code
# Generating a sample for the simulation
library(randomMachines)
sim_data <- sim_class(n = 75)
sim_new <- sim_class(n = 25)
rm_mod <- randomMachines(y~., train = sim_data)
y_hat <- predict(rm_mod, newdata = sim_new)

Run the code above in your browser using DataLab