# BioMoR Benchmarking Tutorial

This vignette provides a short, fast example of benchmarking models with BioMoR.

    # Prepare dataset
    data(iris)
    iris$Label <- ifelse(iris$Species == "setosa", "Active", "Inactive")

    # Cross-validation control
    ctrl <- get_cv_control(cv = 3)

    # Train a Random Forest model
    fit <- train_rf(iris, outcome_col = "Label", ctrl = ctrl)

    ## Loading required namespace: randomForest

    ## Loading required package: ggplot2

    ## Loading required package: lattice

    ## Loading required package: dplyr

    ##
    ## Attaching package: 'dplyr'

    ## The following objects are masked from 'package:stats':
    ##
    ##     filter, lag

    ## The following objects are masked from 'package:base':
    ##
    ##     intersect, setdiff, setequal, union

    ##
    ## Attaching package: 'recipes'

    ## The following object is masked from 'package:stats':
    ##
    ##     step

    ## randomForest 4.7-1.2

    ## Type rfNews() to see new features/changes/bug fixes.

    ##
    ## Attaching package: 'randomForest'

    ## The following object is masked from 'package:dplyr':
    ##
    ##     combine

    ## The following object is masked from 'package:ggplot2':
    ##
    ##     margin

    # Compute simple benchmark metrics
    metrics <- biomor_benchmark(fit, iris, outcome_col = "Label")

    ## Warning in bake(object$recipe, new_data = newdata, all_predictors()): ! There was 1 column that was a factor when the recipe was prepped:
    ## • `Label`
    ## ℹ This may cause errors when processing new data.
    ## ! There was 1 column that was a factor when the recipe was prepped:
    ## • `Label`
    ## ℹ This may cause errors when processing new data.

    ## Warning in confusionMatrix.default(y_pred, y_true): Levels are not in the same
    ## order for reference and data. Refactoring data to match.

    ## Setting direction: controls > cases

    metrics

    ## $Accuracy
    ## [1] 1
    ##
    ## $F1
    ## [1] 1
    ##
    ## $ROC_AUC
    ## Area under the curve: 1

For more elaborate visualizations (ROC, PR curves, calibration plots), users can combine the model predictions with packages such as yardstick and ggplot2.