Skip to content

Commit

Permalink
Merge pull request #3 from guillermo-navas-palencia/binning_process
Browse files Browse the repository at this point in the history
Binning process
  • Loading branch information
guillermo-navas-palencia authored Jan 31, 2020
2 parents 304266c + 1e5df63 commit 7067b2e
Show file tree
Hide file tree
Showing 10 changed files with 1,196 additions and 25 deletions.
7 changes: 7 additions & 0 deletions doc/source/binning_process.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Binning process
===============

.. autoclass:: optbinning.binning_process.BinningProcess
:members:
:inherited-members:
:show-inheritance:
1 change: 1 addition & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ written in Python implementing a **rigorous** and **flexible** mathematical prog
binning_binary
binning_continuous
binning_multiclass
binning_process
binning_tables
binning_utilities
5 changes: 4 additions & 1 deletion optbinning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from .continuous_binning import ContinuousOptimalBinning
from .multiclass_binning import MulticlassOptimalBinning

from .binning_process import BinningProcess


__all__ = ['OptimalBinning',
'ContinuousOptimalBinning',
'MulticlassOptimalBinning']
'MulticlassOptimalBinning',
'BinningProcess']
24 changes: 12 additions & 12 deletions optbinning/binning_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,21 @@
def print_header():
header = (
"optbinning (Version 0.1.1)\n"
"Copyright (c) 2019 Guillermo Navas-Palencia, Apache License 2.0\n")
"Copyright (c) 2020 Guillermo Navas-Palencia, Apache License 2.0\n")

print(header)


def print_optional_parameters(binning_type, dict_user_options):
if binning_type == "optimalbinning":
dict_default_options = optimal_binning_default_options
elif binning_type == "multiclassoptimalbinning":
dict_default_options = multiclass_optimal_binning_default_options
elif binning_type == "continuousoptimalbinning":
dict_default_options = continuous_optimal_binning_default_options

option_format = " {:<20} {:>19} * {}\n"
def print_optional_parameters(dict_default_options, dict_user_options):
option_format = " {:<24} {:>19} * {}\n"
str_options = " Begin options\n"
for key, value in dict_default_options.items():
user_value = dict_user_options[key]
user_flag = "d" if value == user_value else "U"

if user_value is None:
user_value = "no"
elif isinstance(user_value, (list, np.ndarray)):
elif isinstance(user_value, (list, np.ndarray, dict)):
user_value = "yes"

str_options += option_format.format(key, str(user_value), user_flag)
Expand Down Expand Up @@ -174,7 +167,14 @@ def print_binning_information(binning_type, print_level, name, status,
print_header()

if print_level == 2:
print_optional_parameters(binning_type, dict_user_options)
if binning_type == "optimalbinning":
dict_default_options = optimal_binning_default_options
elif binning_type == "multiclassoptimalbinning":
dict_default_options = multiclass_optimal_binning_default_options
elif binning_type == "continuousoptimalbinning":
dict_default_options = continuous_optimal_binning_default_options

print_optional_parameters(dict_default_options, dict_user_options)

if print_level == 0:
print_main_info(name, status, time_total)
Expand Down
Loading

0 comments on commit 7067b2e

Please sign in to comment.