Fits a 100-tree Random Forest on training data and reports a
classification report (precision / recall / F1 / support per class)
on the held-out test set. Mirrors morie.ml.eval_robustness.
Value
Named list keyed by class label and accuracy with
precision / recall / f1-score / support per class, mirroring
sklearn's classification_report(output_dict=True).
Examples
set.seed(1)
n <- 80
X <- data.frame(x1 = rnorm(n), x2 = rnorm(n))
y <- factor(ifelse(X$x1 + X$x2 + rnorm(n, 0, 0.3) > 0, "yes", "no"))
idx <- sample.int(n, floor(n * 0.7))
if (requireNamespace("randomForest", quietly = TRUE)) {
r <- morie_ml_eval_robustness(X[idx, ], y[idx], X[-idx, ], y[-idx],
n_estimators = 20L)
r$accuracy
}
#> [1] 0.875
