(self, datas, labels, split_index, split_value)
return gini, left_data, left_label, right_data, right_label
计算属性值gini值
        参数：
            datas   数据集合
            labels  label集合，与datas集合对应
计算属性值gini值
        参数：
            datas   数据集合
            labels  label集合，与datas集合对应
计算属性值gini值 参数： datas 数据集合 labels label集合，与datas集合对应
def calc_gini(self, datas, labels, split_index, split_value):
        """计算属性值gini值
        参数：
            datas   数据集合
            labels  label集合，与datas集合对应

        """
        labels_dict = Counter(labels)
        label_dist_dict = {
            label: defaultdict(int) for label in labels_dict.keys()}
        left_data = []
        left_label = []
        right_data = []
        right_label = []
        for i in range(len(labels)):
            if datas[i][split_index] > split_value:
                label_dist_dict[labels[i]][1] += 1.
                right_data.append(datas[i])
                right_label.append(labels[i])
            else:
                label_dist_dict[labels[i]][0] += 1.
                left_data.append(datas[i])
                left_label.append(labels[i])
        gini = 0.
        for label in labels_dict.keys():
            prob = labels_dict[label] / float(len(labels))
            prob_label = label_dist_dict[label][1] / float(len(labels))
            gini += (prob * 2 * prob_label * (1 - prob_label))
        return gini, left_data, left_label, right_data, right_label
def calc_gini ( self , datas , labels , split_index , split_value ) : labels_dict = Counter ( labels ) label_dist_dict = { label : defaultdict ( int ) for label in labels_dict . keys ( ) } left_data = [ ] left_label = [ ] right_data = [ ] right_label = [ ] for i in range ( len ( labels ) ) : if datas [ i ] [ split_index ] > split_value : label_dist_dict [ labels [ i ] ] [ 1 ] += 1. right_data . append ( datas [ i ] ) right_label . append ( labels [ i ] ) else : label_dist_dict [ labels [ i ] ] [ 0 ] += 1. left_data . append ( datas [ i ] ) left_label . append ( labels [ i ] ) gini = 0. for label in labels_dict . keys ( ) : prob = labels_dict [ label ] / float ( len ( labels ) ) prob_label = label_dist_dict [ label ] [ 1 ] / float ( len ( labels ) ) gini += ( prob * 2 * prob_label * ( 1 - prob_label ) ) return gini , left_data , left_label , right_data , right_label