NameError:名称“ buildtree”未定义

时间:2019-11-01 21:54:59

标签: python

问题是关于2决策树。我想构建它们,但它向我显示此消息:“ NameError:名称'buildtree'未定义”。这是简单的错误,但我是python的新手,所以任何帮助都会很好。谢谢

if __name__ == "__main__":


    att1=float(input())
    att2=float(input())
    att3=float(input())
    att4=float(input())
    planttype=input()
    testCase=[att1,att2,att3,att4,planttype]

    tmp = [att1, att2, att3, att4]
    p1 = []
    p2 = []
    leng = len(trainingData)

    for i in range(0,int(leng/2)):
        p1.append(trainingData[i])
    for i in range(int(leng/2),len(trainingData)):
        p2.append(trainingData[i])

    d1 = buildtree(p1)
    d2 = buildtree(p2)

    print('Drvo 1')
    printtree(d1)
    print('Drvo 2')
    printtree(d2)

    k1 = classify(tmp,d1)
    k2 = classify(tmp,d2)

    print (k1)
    print (k2)

    if (k1 == k2):
        print (k1)
    else:
        print('KONTRADIKCIJA')
    t=build_tree(trainingData)
    print(classify(testCase,t))

0 个答案:

没有答案