Learn R Programming

dlookr (version 0.5.0)

plot.optimal_bins: Visualize Distribution for an "optimal_bins" Object

Description

It generates plots for understand distribution, frequency, bad rate, and weight of evidence using optimal_bins.

See vignette("transformation") for an introduction to these concepts.

Usage

# S3 method for optimal_bins
plot(
  x,
  type = c("all", "dist", "freq", "posrate", "WoE"),
  typographic = TRUE,
  rotate_angle = 0,
  ...
)

Arguments

x

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

type

character. options for visualization. Distribution ("dist"), Relateive Frequency ("freq"), Positive Rate ("posrate"), and Weight of Evidence ("WoE"). and default "all" draw all plot.

typographic

logical. Whether to apply focuses on typographic elements to ggplot2 visualization. The default is TRUE. if TRUE provides a base theme that focuses on typographic elements using hrbrthemes package.

rotate_angle

integer. specifies the rotation angle of the x-axis label. This is useful when the x-axis labels are long and overlap. The default is 0 to not rotate the label.

...

further arguments to be passed from or to other methods.

See Also

binning_by, summary.optimal_bins

Examples

Run this code
# NOT RUN {
# Generate data for the example
heartfailure2 <- heartfailure
heartfailure2[sample(seq(NROW(heartfailure2)), 5), "creatinine"] <- NA

# optimal binning using binning_by()
bin <- binning_by(heartfailure2, "death_event", "creatinine")
bin

# summary optimal_bins class.
summary(bin)

# visualize all information for optimal_bins class
plot(bin)

# rotate the x-axis labels by 45 degrees so that they do not overlap.
plot(bin, rotate_angle = 45)

# visualize WoE information for optimal_bins class
plot(bin, type = "WoE")

# visualize all information with typographic
plot(bin)

# }

Run the code above in your browser using DataLab