Description
Easily Get True-Positive Rate and False-Positive Rate and KS Statistic.
Description
The Kolmogorov-Smirnov (K-S) statistic is a standard method to measure the model strength for credit risk scoring models. This package calculates the K–S statistic and plots the true-positive rate and false-positive rate to measure the model strength. This package was written with the credit marketer, who uses risk models in conjunction with his campaigns. The users could read more details from Thrasher (1992) <doi:10.1002/dir.4000060408> and 'pyks' <https://pypi.org/project/pyks/>.
README.md
rawKS
The goal of rawKS is to easily extract the raw KS statistics to plot and report. The Python version pyks is hosted from GitHub.
Installation
The development version from GitHub with:
# install.packages("devtools")
devtools::install_github("JiaxiangBU/rawKS")
Example
library(tidyverse)
#> Registered S3 methods overwritten by 'ggplot2':
#> method from
#> [.quosures rlang
#> c.quosures rlang
#> print.quosures rlang
#> ── Attaching packages ───────────────────────────────────────────────────────── tidyverse 1.2.1 ──
#> <U+2713> ggplot2 3.1.1 <U+2713> purrr 0.3.3
#> <U+2713> tibble 2.1.3 <U+2713> dplyr 0.8.3
#> <U+2713> tidyr 0.8.3 <U+2713> stringr 1.4.0
#> <U+2713> readr 1.3.1 <U+2713> forcats 0.4.0
#> Warning: package 'purrr' was built under R version 3.6.1
#> Warning: package 'dplyr' was built under R version 3.6.1
#> ── Conflicts ──────────────────────────────────────────────────────────── tidyverse_conflicts() ──
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag() masks stats::lag()
library(rawKS)
data("two_class_example_edited")
max(ks_table(two_class_example_edited$yhat, two_class_example_edited$y)$ks)
#> [1] 0.7276892
ks_table(two_class_example_edited$yhat, two_class_example_edited$y) %>%
ks_plot()