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]))