(data_event_count, adjustment_factor)
return BinColResults(woe_array=woe_array, iv_array=iv_array, event_count_array=event_count_array,
                             non_event_count_array=non_event_count_array,
                             event_rate_array=event_rate_array, non_event_rate_array=non_event_rate_array, iv=iv)
Given event and non-event count in one column, calculate its woe value.

        Parameters
        ----------
        data_event_count : list
            [(event_sum, non-event_sum), (same sum in second_bin), (in third bin) ...]

        adjustment_factor : float
            The adjustment factor when calculating WOE

        Returns
        -------
        IVAttributes : object
            Stored information that related iv and woe value
Given event and non-event count in one column, calculate its woe value.
Given event and non - event count in one column calculate its woe value .
def woe_1d(data_event_count, adjustment_factor):
        """
        Given event and non-event count in one column, calculate its woe value.

        Parameters
        ----------
        data_event_count : list
            [(event_sum, non-event_sum), (same sum in second_bin), (in third bin) ...]

        adjustment_factor : float
            The adjustment factor when calculating WOE

        Returns
        -------
        IVAttributes : object
            Stored information that related iv and woe value
        """
        event_total = 0
        non_event_total = 0
        for bin_res in data_event_count:
            if len(bin_res) != 2:
                raise ValueError(f"bin_res should has length of 2,"
                                 f" data_event_count: {data_event_count}, bin_res: {bin_res}")
            event_total += bin_res[0]
            non_event_total += bin_res[1]

        if event_total == 0:
            # raise ValueError("NO event label in target data")
            event_total = 1
        if non_event_total == 0:
            # raise ValueError("NO non-event label in target data")
            non_event_total = 1

        iv = 0
        event_count_array = []
        non_event_count_array = []
        event_rate_array = []
        non_event_rate_array = []
        woe_array = []
        iv_array = []

        for event_count, non_event_count in data_event_count:

            if event_count == 0 or non_event_count == 0:
                event_rate = 1.0 * (event_count + adjustment_factor) / event_total
                non_event_rate = 1.0 * (non_event_count + adjustment_factor) / non_event_total
            else:
                event_rate = 1.0 * event_count / event_total
                non_event_rate = 1.0 * non_event_count / non_event_total
            woe_i = math.log(event_rate / non_event_rate)

            event_count_array.append(int(event_count))
            non_event_count_array.append(int(non_event_count))
            event_rate_array.append(event_rate)
            non_event_rate_array.append(non_event_rate)
            woe_array.append(woe_i)
            iv_i = (event_rate - non_event_rate) * woe_i
            iv_array.append(iv_i)
            iv += iv_i
        return BinColResults(woe_array=woe_array, iv_array=iv_array, event_count_array=event_count_array,
                             non_event_count_array=non_event_count_array,
                             event_rate_array=event_rate_array, non_event_rate_array=non_event_rate_array, iv=iv)
def woe_1d ( data_event_count , adjustment_factor ) : event_total = 0 non_event_total = 0 for bin_res in data_event_count : if len ( bin_res ) != 2 : raise ValueError ( f"bin_res should has length of 2," f" data_event_count: {data_event_count}, bin_res: {bin_res}" ) event_total += bin_res [ 0 ] non_event_total += bin_res [ 1 ] if event_total == 0 : # raise ValueError("NO event label in target data") event_total = 1 if non_event_total == 0 : # raise ValueError("NO non-event label in target data") non_event_total = 1 iv = 0 event_count_array = [ ] non_event_count_array = [ ] event_rate_array = [ ] non_event_rate_array = [ ] woe_array = [ ] iv_array = [ ] for event_count , non_event_count in data_event_count : if event_count == 0 or non_event_count == 0 : event_rate = 1.0 * ( event_count + adjustment_factor ) / event_total non_event_rate = 1.0 * ( non_event_count + adjustment_factor ) / non_event_total else : event_rate = 1.0 * event_count / event_total non_event_rate = 1.0 * non_event_count / non_event_total woe_i = math . log ( event_rate / non_event_rate ) event_count_array . append ( int ( event_count ) ) non_event_count_array . append ( int ( non_event_count ) ) event_rate_array . append ( event_rate ) non_event_rate_array . append ( non_event_rate ) woe_array . append ( woe_i ) iv_i = ( event_rate - non_event_rate ) * woe_i iv_array . append ( iv_i ) iv += iv_i return BinColResults ( woe_array = woe_array , iv_array = iv_array , event_count_array = event_count_array , non_event_count_array = non_event_count_array , event_rate_array = event_rate_array , non_event_rate_array = non_event_rate_array , iv = iv )