Description Usage Arguments Value Examples

View source: R/01_PCT_BINNING.R

`pct.bin`

implements percentile-based monotonic binning by the iterative discretization.

1 2 3 4 5 6 7 8 9 10 |

`x` |
Numeric vector to be binned. |

`y` |
Numeric target vector (binary or continuous). |

`sc` |
Numeric vector with special case elements. Default values are |

`sc.method` |
Define how special cases will be treated, all together or in separate bins.
Possible values are |

`g` |
Number of starting groups. Default is 15. |

`y.type` |
Type of |

`woe.trend` |
Applied only for a continuous target ( |

`force.trend` |
If the expected trend should be forced. Possible values: |

The command `pct.bin`

generates a list of two objects. The first object, data frame `summary.tbl`

presents a summary table of final binning, while `x.trans`

is a vector of discretized values.
In case of single unique value for `x`

or `y`

of complete cases (cases different than special cases),
it will return data frame with info.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
suppressMessages(library(monobin))
data(gcd)
#binary target
mat.bin <- pct.bin(x = gcd$maturity, y = gcd$qual)
mat.bin[[1]]
table(mat.bin[[2]])
#continuous target, separate groups for special cases
set.seed(123)
gcd$age.d <- gcd$age
gcd$age.d[sample(1:nrow(gcd), 10)] <- NA
gcd$age.d[sample(1:nrow(gcd), 3)] <- 9999999999
age.d.bin <- pct.bin(x = gcd$age.d,
y = gcd$qual,
sc = c(NA, NaN, Inf, 9999999999),
sc.method = "separately",
force.trend = "d")
age.d.bin[[1]]
gcd$age.d.bin <- age.d.bin[[2]]
gcd %>% group_by(age.d.bin) %>% summarise(n = n(), y.avg = mean(qual))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.