Implementing equal-frequency discretization
Equal-width discretization is intuitive and easy to compute. However, if the variables are skewed, then there will be many empty bins or bins with only a few values, while most observations will be allocated to a few intervals. This could result in a loss of information. This problem can be solved by adaptively finding the interval cut-points so that each interval contains a similar fraction of observations.
Equal-frequency discretization divides the values of the variable into intervals that carry the same proportion of observations. The interval width is determined by quantiles. Quantiles are values that divide data into equal portions. For example, the median is a quantile that divides the data into two halves. Quartiles divide the data into four equal portions, and percentiles divide the data into 100 equal-sized portions. As a result, the intervals will most likely have different widths, but a similar number of observations. The number...