ConfusionMatrix {MBMethPred} | R Documentation |
Confusion matrix
Description
A function to calculate the confusion matrix of the machine and deep learning models. It outputs Accuracy, Precision, Sensitivity, F1-Score, Specificity, and AUC_average.
Usage
ConfusionMatrix(y_true, y_pred)
Arguments
y_true |
True labels |
y_pred |
Predicted labels |
Value
A data frame
Examples
set.seed(1234)
data <- Data1[1:10,]
data$subgroup <- factor(data$subgroup)
fac <- ncol(data)
split <- caTools::sample.split(data[, fac], SplitRatio = 0.8)
training_set <- subset(data, split == TRUE)
test_set <- subset(data, split == FALSE)
rf <- randomForest::randomForest(x = training_set[-fac],
y = training_set[, fac],
ntree = 10)
y_pred <- predict(rf, newdata = test_set[-fac])
ConfusionMatrix(y_true = test_set[, fac],
y_pred = y_pred)
[Package MBMethPred version 0.1.4.2 Index]