predict.ULDA {folda} | R Documentation |
Predict Method for ULDA Model
Description
This function predicts the class labels or class probabilities for new data
using a fitted ULDA model. The prediction can return either the most likely
class ("response"
) or the posterior probabilities for each class
("prob"
).
Usage
## S3 method for class 'ULDA'
predict(object, newdata, type = c("response", "prob"), ...)
Arguments
object |
A fitted |
newdata |
A data frame containing the new predictor variables for which predictions are to be made. |
type |
A character string specifying the type of prediction to return.
|
... |
Additional arguments. |
Value
If type = "response"
, the function returns a vector of predicted
class labels. If type = "prob"
, it returns a matrix of posterior
probabilities, where each row corresponds to a sample and each column to a
class.
Examples
fit <- folda(datX = iris[, -5], response = iris[, 5], subsetMethod = "all")
# Predict class labels
predictions <- predict(fit, iris, type = "response")
# Predict class probabilities
prob_predictions <- predict(fit, iris, type = "prob")