# Path: DSTK/FeatureBinning/decision_tree_binner.py
# def _recurse_tree(tree, lst, mdlp, node_id=0, depth=0, min_val=np.NINF, max_val=np.PINF):
# def _convert_count_buckets_to_split_and_vals(sorted_nodes):
# def _check_mdlp_stop(tree, node_id):
# def _calculate_entropy(array):
# def _calculate_gain(tree, node_id):
# def _calculate_noise_delta(tree, node_id):
# def _get_variables_for_entropy_calculation(tree, node_id):
#     def is_fit(self):
#     def values(self):
#     def splits(self):
#     def is_fit(self, is_fit):
#     def values(self, values):
#     def splits(self, splits):
#     def __init__(self, name, **kwargs):
#     def fit(self, values, target):
# class DecisionTreeBinner(BaseBinner):


import sklearn.datasets as ds
import numpy as np
from DSTK.FeatureBinning import decision_tree_binner as tfb

    np.testing.assert_equal(binner.splits, [13.094999313354492, 15.045000076293945, 16.924999237060547, np.PINF, np.NaN])
    np.testing.assert_equal(binner.values, [[0.04905660377358491, 0.9509433962264151],
                                            [0.2878787878787879, 0.7121212121212122],
                                            [0.8148148148148148, 0.18518518518518517],
                                            [0.9915254237288136, 0.00847457627118644],
                                            [0.37258347978910367, 0.62741652021089633]])


def test_recursion_with_mdlp():
    binner = tfb.DecisionTreeBinner('test', mdlp=True)
    binner.fit(data[:, 0], target)

    np.testing.assert_equal(binner.splits, [13.094999313354492, 15.045000076293945, 17.880001068115234, np.PINF, np.NaN])
    np.testing.assert_equal(binner.values, [[0.04905660377358491, 0.9509433962264151],
                                            [0.2878787878787879, 0.7121212121212122],
                                            [0.8533333333333334, 0.14666666666666667],
                                            [1.0, 0.0],
                                            [0.37258347978910367, 0.62741652021089633]])


def test_str_repr_with_mdlp():

    assert_str = \
    """<= 13.0949993134: [ 0.0490566  0.9509434]
<= 15.0450000763: [ 0.28787879  0.71212121]
<= 17.8800010681: [ 0.85333333  0.14666667]
<= inf: [ 1.  0.]
NaN: [ 0.37258348  0.62741652]"""


# Path: DSTK/FeatureBinning/decision_tree_binner.py
# def _recurse_tree(tree, lst, mdlp, node_id=0, depth=0, min_val=np.NINF, max_val=np.PINF):
# def _convert_count_buckets_to_split_and_vals(sorted_nodes):
# def _check_mdlp_stop(tree, node_id):
# def _calculate_entropy(array):
# def _calculate_gain(tree, node_id):
# def _calculate_noise_delta(tree, node_id):
# def _get_variables_for_entropy_calculation(tree, node_id):
#     def is_fit(self):
#     def values(self):
#     def splits(self):
#     def is_fit(self, is_fit):
#     def values(self, values):
#     def splits(self, splits):
#     def __init__(self, name, **kwargs):
#     def fit(self, values, target):
# class DecisionTreeBinner(BaseBinner):


# Path: DSTK/tests/test_feature_binner/test_recursive_feature_binner.py
import sklearn.datasets as ds
import numpy as np
from DSTK.FeatureBinning import decision_tree_binner as tfb


    np.testing.assert_equal(binner.splits, [13.094999313354492, 15.045000076293945, 16.924999237060547, np.PINF, np.NaN])
    np.testing.assert_equal(binner.values, [[0.04905660377358491, 0.9509433962264151],
                                            [0.2878787878787879, 0.7121212121212122],
                                            [0.8148148148148148, 0.18518518518518517],
                                            [0.9915254237288136, 0.00847457627118644],
                                            [0.37258347978910367, 0.62741652021089633]])


def test_recursion_with_mdlp():
    binner = tfb.DecisionTreeBinner('test', mdlp=True)
    binner.fit(data[:, 0], target)

    np.testing.assert_equal(binner.splits, [13.094999313354492, 15.045000076293945, 17.880001068115234, np.PINF, np.NaN])
    np.testing.assert_equal(binner.values, [[0.04905660377358491, 0.9509433962264151],
                                            [0.2878787878787879, 0.7121212121212122],
                                            [0.8533333333333334, 0.14666666666666667],
                                            [1.0, 0.0],
                                            [0.37258347978910367, 0.62741652021089633]])


def test_str_repr_with_mdlp():

    assert_str = \
    """<= 13.0949993134: [ 0.0490566  0.9509434]
<= 15.0450000763: [ 0.28787879  0.71212121]
<= 17.8800010681: [ 0.85333333  0.14666667]
<= inf: [ 1.  0.]
NaN: [ 0.37258348  0.62741652]"""


    binner = tfb.DecisionTreeBinner('test', mdlp=True)