(data_bin_with_table, sparse_bin_points)
return list(result_sum.items())
Add all label, so that become convenient to calculate woe and iv

        Parameters
        ----------
        data_bin_with_table : Table
            The input data, the Table is like:
            (id, {'x1': 1, 'x2': 5, 'x3': 2}, y)

        sparse_bin_points: dict
            Dict of sparse bin num
                {0: 2, 1: 3, 2:5 ... }

        Returns
        -------
        result_sum: the result Table. It is like:
            {'x1': [[event_count, total_num], [event_count, total_num] ... ],
             'x2': [[event_count, total_num], [event_count, total_num] ... ],
             ...
            }
Add all label, so that become convenient to calculate woe and iv
Add all label so that become convenient to calculate woe and iv
def add_label_in_partition_bak(data_bin_with_table, sparse_bin_points):
        """
        Add all label, so that become convenient to calculate woe and iv

        Parameters
        ----------
        data_bin_with_table : Table
            The input data, the Table is like:
            (id, {'x1': 1, 'x2': 5, 'x3': 2}, y)

        sparse_bin_points: dict
            Dict of sparse bin num
                {0: 2, 1: 3, 2:5 ... }

        Returns
        -------
        result_sum: the result Table. It is like:
            {'x1': [[event_count, total_num], [event_count, total_num] ... ],
             'x2': [[event_count, total_num], [event_count, total_num] ... ],
             ...
            }

        """
        result_sum = {}
        for _, datas in data_bin_with_table:
            bin_idx_dict = datas[0]
            y = datas[1]

            # y = y_combo[0]
            # inverse_y = y_combo[1]
            for col_name, bin_idx in bin_idx_dict.items():
                result_sum.setdefault(col_name, [])
                col_sum = result_sum[col_name]
                while bin_idx >= len(col_sum):
                    col_sum.append([0, 0])
                if bin_idx == sparse_bin_points[col_name]:
                    continue
                label_sum = col_sum[bin_idx]
                label_sum[0] = label_sum[0] + y
                label_sum[1] = label_sum[1] + 1
                col_sum[bin_idx] = label_sum
                result_sum[col_name] = col_sum

        return list(result_sum.items())
def add_label_in_partition_bak ( data_bin_with_table , sparse_bin_points ) : result_sum = { } for _ , datas in data_bin_with_table : bin_idx_dict = datas [ 0 ] y = datas [ 1 ] # y = y_combo[0] # inverse_y = y_combo[1] for col_name , bin_idx in bin_idx_dict . items ( ) : result_sum . setdefault ( col_name , [ ] ) col_sum = result_sum [ col_name ] while bin_idx >= len ( col_sum ) : col_sum . append ( [ 0 , 0 ] ) if bin_idx == sparse_bin_points [ col_name ] : continue label_sum = col_sum [ bin_idx ] label_sum [ 0 ] = label_sum [ 0 ] + y label_sum [ 1 ] = label_sum [ 1 ] + 1 col_sum [ bin_idx ] = label_sum result_sum [ col_name ] = col_sum return list ( result_sum . items ( ) )