Py3上的调试问题 AttributeError: module 'types' has no attribute 'ListType'求解

来源:互联网 发布:电视机的电视直播软件 编辑:程序博客网 时间:2024/05/29 19:19



import types as Types

def TrainCART(df,feature_list,y, depth = 10000):
    '''
    :param df: 建立CART的数据集
    :param feature_list: 用于模型开发的特征的列表
    :param y: 标签,取值0,1
    :param depth: 树的深度。当指明深度时,设置该参数。
    :return: 叶子节点,或者子树。最终返回字典形式的CART树
    '''

    



    cartResult = {bestFeature:{}}
    if type(bestSplit) == Types.ListType: #按:出错,==types.ListType;试着改为Types.ListType
                                           #AttributeError: module 'types' has no attribute 'ListType'
        subTreeFeatures = [i for i in feature_list if i != bestFeature]
        bestFeaturesVals = list(set(df[bestFeature]))

阅读全文
0 0
原创粉丝点击