summary method for "optimal_bins". summary metrics to evaluate the performance of binomial classification model.

# S3 method for optimal_bins
summary(object, ...)

## Arguments

object

an object of class "optimal_bins", usually, a result of a call to binning_by().

...

further arguments to be passed from or to other methods.

NULL.

## Details

print() to print only binning table information of "optimal_bins" objects. summary.performance_bin() includes general metrics and result of significance tests life follows.:

• Binning Table : Metrics by bins.

• CntRec, CntPos, CntNeg, RatePos, RateNeg, Odds, WoE, IV, JSD, AUC.

• General Metrics.

• Gini index.

• Jeffrey's Information Value.

• Jensen-Shannon Divergence.

• Kolmogorov-Smirnov Statistics.

• Herfindahl-Hirschman Index.

• normalized Herfindahl-Hirschman Index.

• Cramer's V Statistics.

• Table of Significance Tests.

binning_by, plot.optimal_bins

## Examples

library(dplyr)

# Generate data for the example
heartfailure2 <- heartfailure
heartfailure2[sample(seq(NROW(heartfailure2)), 5), "creatinine"] <- NA

# optimal binning
bin <- binning_by(heartfailure2, "death_event", "creatinine")
#> Warning: The factor y has been changed to a numeric vector consisting of 0 and 1.
#> 'Yes' changed to 1 (positive) and 'No' changed to 0 (negative).
bin
#> binned type: optimal
#> number of bins: 3
#> x
#> [0.5,0.9] (0.9,1.8] (1.8,9.4]      <NA>
#>        78       168        48         5
=======
#>        78       169        47         5
>>>>>>> 2455413f029244b566a37aeed1916eea79ac483b

# summary optimal_bins class
summary(bin)
#> ── Binning Table ──────────────────────── Several Metrics ──
#>         Bin CntRec CntPos CntNeg RatePos RateNeg    Odds      WoE      IV
#> 1 [0.5,0.9]     78      9     69 0.09375 0.33990 0.13043 -1.28802 0.31705
#> 2 (0.9,1.8]    168     52    116 0.54167 0.57143 0.44828 -0.05349 0.00159
#> 3 (1.8,9.4]     48     35     13 0.36458 0.06404 2.69231  1.73926 0.52272
=======
#> 2 (0.9,1.8]    169     52    117 0.54167 0.57635 0.44444 -0.06207 0.00215
#> 3 (1.8,9.4]     47     35     12 0.36458 0.05911 2.91667  1.81930 0.55574
>>>>>>> 2455413f029244b566a37aeed1916eea79ac483b
#> 4      <NA>      5      0      5 0.00000 0.02463 0.00000       NA      NA
#> 5     Total    299     96    203 1.00000 1.00000 0.47291       NA      NA
#>       JSD     AUC
#> 1 0.03710 0.01593
#> 2 0.00020 0.20833
#> 3 0.05818 0.05237
#> 4      NA 0.02463
#> 5      NA 0.30126
#>
#> ── General Metrics ─────────────────────────────────────────
#> • Gini index                       :  -0.39748
#> • IV (Jeffrey)                     :  NA
#> • JS (Jensen-Shannon) Divergence   :  NA
#> • Kolmogorov-Smirnov Statistics    :  0.27591
#> • HHI (Herfindahl-Hirschman Index) :  0.40981
#> • HHI (normalized)                 :  0.21307
#> • Cramer's V                       :  0.41821
#>
#> ── Significance Tests ──────────────────── Chisquare Test ──
#>       Bin A     Bin B statistics      p_value
#> 1 [0.5,0.9] (0.9,1.8]   10.76624 1.033685e-03
#> 2 (0.9,1.8] (1.8,9.4]   27.33097 1.714438e-07
=======
#> 2 0.00027 0.21013
#> 3 0.06124 0.04834
#> 4      NA 0.02463
#> 5      NA 0.29903
#>
#> ── General Metrics ─────────────────────────────────────────
#> • Gini index                       :  -0.40194
#> • IV (Jeffrey)                     :  NA
#> • JS (Jensen-Shannon) Divergence   :  NA
#> • Kolmogorov-Smirnov Statistics    :  0.28084
#> • HHI (Herfindahl-Hirschman Index) :  0.41251
#> • HHI (normalized)                 :  0.21668
#> • Cramer's V                       :  0.42641
#>
#> ── Significance Tests ──────────────────── Chisquare Test ──
#>       Bin A     Bin B statistics      p_value
#> 1 [0.5,0.9] (0.9,1.8]   10.61277 1.123093e-03
#> 2 (0.9,1.8] (1.8,9.4]   29.19238 6.553656e-08
>>>>>>> 2455413f029244b566a37aeed1916eea79ac483b
#>

# performance table
attr(bin, "performance")
#>         Bin CntRec CntPos CntNeg CntCumPos CntCumNeg RatePos RateNeg RateCumPos
#> 1 [0.5,0.9]     78      9     69         9        69 0.09375 0.33990    0.09375
#> 2 (0.9,1.8]    168     52    116        61       185 0.54167 0.57143    0.63542
#> 3 (1.8,9.4]     48     35     13        96       198 0.36458 0.06404    1.00000
=======
#> 2 (0.9,1.8]    169     52    117        61       186 0.54167 0.57635    0.63542
#> 3 (1.8,9.4]     47     35     12        96       198 0.36458 0.05911    1.00000
>>>>>>> 2455413f029244b566a37aeed1916eea79ac483b
#> 4      <NA>      5      0      5        96       203 0.00000 0.02463    1.00000
#> 5     Total    299     96    203        NA        NA 1.00000 1.00000         NA
#>   RateCumNeg    Odds   LnOdds      WoE      IV     JSD     AUC
#> 1    0.33990 0.13043 -2.03688 -1.28802 0.31705 0.03710 0.01593
#> 2    0.91133 0.44828 -0.80235 -0.05349 0.00159 0.00020 0.20833
#> 3    0.97537 2.69231  0.99040  1.73926 0.52272 0.05818 0.05237
#> 4    1.00000 0.00000     -Inf       NA      NA      NA 0.02463
#> 5         NA 0.47291 -0.74886       NA      NA      NA 0.30126
=======
#> 2    0.91626 0.44444 -0.81093 -0.06207 0.00215 0.00027 0.21013
#> 3    0.97537 2.91667  1.07044  1.81930 0.55574 0.06124 0.04834
#> 4    1.00000 0.00000     -Inf       NA      NA      NA 0.02463
#> 5         NA 0.47291 -0.74886       NA      NA      NA 0.29903
>>>>>>> 2455413f029244b566a37aeed1916eea79ac483b

# extract binned results
if (!is.null(bin)) {
extract(bin) %>%