get_psi_plots: Plot PSI(Population Stability Index)

Description Usage Arguments Examples

View source: R/data_visualization.R

Description

You can use the psi_plot to plot PSI of your data. get_psi_plots can loop through plots for all specified independent variables.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
get_psi_plots(
  dat_train,
  dat_test = NULL,
  x_list = NULL,
  ex_cols = NULL,
  breaks_list = NULL,
  occur_time = NULL,
  g = 10,
  plot_show = TRUE,
  save_data = FALSE,
  file_name = NULL,
  parallel = FALSE,
  g_width = 8,
  dir_path = tempdir()
)

psi_plot(
  dat_train,
  x,
  dat_test = NULL,
  occur_time = NULL,
  g_width = 8,
  breaks_list = NULL,
  breaks = NULL,
  g = 10,
  plot_show = TRUE,
  save_data = FALSE,
  dir_path = tempdir()
)

Arguments

dat_train

A data.frame with independent variables.

dat_test

A data.frame of test data. Default is NULL.

x_list

Names of independent variables.

ex_cols

A list of excluded variables. Regular expressions can also be used to match variable names. Default is NULL.

breaks_list

A table containing a list of splitting points for each independent variable. Default is NULL.

occur_time

The name of occur time.

g

Number of initial breakpoints for equal frequency binning.

plot_show

Logical, show model performance in current graphic device. Default is FALSE.

save_data

Logical, save results in locally specified folder. Default is FALSE.

file_name

The name for periodically saved data file. Default is NULL.

parallel

Logical, parallel computing. Default is FALSE.

g_width

The width of graphs.

dir_path

The path for periodically saved graphic files.

x

The name of an independent variable.

breaks

Splitting points for a continues variable.

Examples

1
2
3
4
5
train_test = train_test_split(UCICreditCard[1:1000,], split_type = "Random",
 prop = 0.8, save_data = FALSE)
dat_train = train_test$train
dat_test = train_test$test
get_psi_plots(dat_train[, c(8, 9)], dat_test = dat_test[, c(8, 9)])

Example output

Package 'creditmodel' version 1.2.7
   Feature         Bins actual expected Ac_pct Ex_pct PSI_i   PSI
1    PAY_0        00.NA     43      171  21.5%  21.4% 0.000 0.007
2    PAY_0  01.(-Inf,0]    112      440    56%    55% 0.000 0.007
3    PAY_0     02.(0,1]     24      112    12%    14% 0.003 0.007
4    PAY_0     03.(1,2]     19       65   9.5%   8.1% 0.002 0.007
5    PAY_0  04.(2, Inf]      2       12     1%   1.5% 0.002 0.007
6    PAY_2        00.NA     44      161    22%  20.1% 0.002 0.006
7    PAY_2 01.(-Inf,-2]     27      103  13.5%  12.9% 0.000 0.006
8    PAY_2    02.(-2,0]    104      421    52%  52.6% 0.000 0.006
9    PAY_2     03.(0,2]     23      103  11.5%  12.9% 0.002 0.006
10   PAY_2  04.(2, Inf]      2       12     1%   1.5% 0.002 0.006

creditmodel documentation built on Jan. 7, 2022, 5:06 p.m.