您的位置:首页 > 编程语言 > Python开发

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

2017-12-06 21:46 671 查看
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]))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐