申请评分卡regroup['temp']的更新问题

@田野老师,在while循环中,groupIntervals每remove一次,regroup['temp']应该更新一次吧?我看代码中没有更新,是不是有问题?
while (len(groupIntervals) > split_intervals):  # 终止条件: 当前分箱数=预设的分箱数
    # 每次循环时, 计算合并相邻组别后的卡方值。具有最小卡方值的合并方案,是最优方案
    chisqList = 
    for k in range(len(groupIntervals)-1):
        temp_group = groupIntervals[k] + groupIntervals[k+1]
        df2b = regroup.loc[regroup['temp'].isin(temp_group)]
        #chisq = Chi2(df2b, 'total', 'bad', overallRate)
        chisq = Chi2(df2b, 'total', 'bad')
        chisqList.append(chisq)
    best_comnbined = chisqList.index(min(chisqList))
    groupIntervals[best_comnbined] = groupIntervals[best_comnbined] + groupIntervals[best_comnbined+1]
    # after combining two intervals, we need to remove one of them
    groupIntervals.remove(groupIntervals[best_comnbined+1])
groupIntervals = [sorted(i) for i in groupIntervals]
cutOffPoints = [max(i) for i in groupIntervals[:-1]]

要回复问题请先登录注册