dx_g_mean | R Documentation |
Calculates the Geometric Mean (G-mean) for the provided confusion matrix. G-mean is a measure of a model's performance that considers both the sensitivity (True Positive Rate) and specificity (True Negative Rate), especially useful in imbalanced datasets.
dx_g_mean(cm, detail = "full", boot = FALSE, bootreps = 1000)
cm |
A dx_cm object created by |
detail |
Character specifying the level of detail in the output: "simple" for raw estimate, "full" for detailed estimate including 95% confidence intervals. |
boot |
Logical specifying if confidence intervals should be generated via bootstrapping. Note, this can be slow. |
bootreps |
The number of bootstrap replications for calculating confidence intervals. |
G-mean is the geometric mean of sensitivity and specificity. It tries to maximize the accuracy on each of the two classes while keeping these accuracies balanced. For a classifier to achieve a high G-mean score, it must perform well on both positive and negative classes.
The formula for G-mean is:
G-mean = \sqrt{Sensitivity \times Specificity}
Depending on the detail
parameter, returns a numeric value
representing the calculated metric or a data frame/tibble with
detailed diagnostics including confidence intervals and possibly other
metrics relevant to understanding the metric.
dx_cm()
to understand how to create and interact with a 'dx_cm' object.
dx_sensitivity()
, dx_specificity()
for components of G-mean.
cm <- dx_cm(dx_heart_failure$predicted, dx_heart_failure$truth, threshold = 0.5, poslabel = 1)
simple_g_mean <- dx_g_mean(cm, detail = "simple")
detailed_g_mean <- dx_g_mean(cm)
print(simple_g_mean)
print(detailed_g_mean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.