Optimal binning algorithm based on the paper: https://www.researchgate.net/publication/322520135_Monotone_optimal_binning_algorithm_for_credit_risk_modeling.
Also taking some insights from https://github.com/jstephenj14/Monotonic-WOE-Binning-Algorithm.
And functions to apply on a pandas DataFrame, being a single variable or the whole dataset.