
Area Under the Curve of Binomial Random Forest predictions vs. observations
Source:R/f_binomial_rf.R
f_binomial_rf.RdFits a univariate random forest model y ~ x with the binomial (values 0 and 1) response y and the numeric, character or factor predictor x using ranger::ranger() and returns the area under the ROC curve between the observed responses and the model predictions (see score_auc()).
Cases are weighted with case_weights() to prevent issues arising from class imbalance.
Supports cross-validation via the arguments arguments cv_training_fraction (numeric between 0 and 1) and cv_iterations (integer between 1 and n) introduced via ellipsis (...). See preference_order() for further details.
See also
Other preference_order_functions:
f_binomial_gam(),
f_binomial_glm(),
f_categorical_rf(),
f_count_gam(),
f_count_glm(),
f_count_rf(),
f_numeric_gam(),
f_numeric_glm(),
f_numeric_rf(),
preference_order()
Examples
data(vi_smol)
df <- data.frame(
y = vi_smol[["vi_binomial"]],
x = vi_smol[["swi_max"]]
)
#no cross-validation
f_binomial_rf(df = df)
#> [1] 0.8995467
#cross-validation
f_binomial_rf(
df = df,
cv_training_fraction = 0.5,
cv_iterations = 10
)
#> [1] 0.7632825 0.7761184 0.7781599 0.7363415 0.7222196 0.7676069 0.7459511
#> [8] 0.7651879 0.7656979 0.7516886
#categorical predictor
df <- data.frame(
y = vi_smol[["vi_binomial"]],
x = vi_smol[["koppen_zone"]]
)
f_binomial_rf(df = df)
#> [1] 0.9328657