Beispiel #1
0
def multiclass_on_binary_svms(Xnew, Y, testXnew, testY):

    print "Classifying with a one vs one SVM"
    classify(Xnew, Y, testXnew, testY, True, 0.2)

    print "Classifying with a one vs all SVM"
    classify(Xnew, Y, testXnew, testY, False, 0.2)
def monb_crossvalidate(X, Y, c, onevone):
    iters = select_cross_validation_subsets(X, Y, 6)
    #crange = [0.000001, 0.00001, 0.0001, 0.001, 0.01, 0.1,
    #          1.0, 10.0, 100.0, 1000.0]
    crange = [1.0]
    for c in crange:
        print "C=%f"%c
        for d in iters:
            X = d["train"][0]
            Y = d["train"][1]
            testX = d["test"][0]
            testY = d["test"][1]
            classify(X, Y, testX, testY, onevone, c)
def monb_test(X, Y, c, onevone, ntest):
    X, Y, testX, testY = select_test_set(X, Y, ntest)
    Y = map(lambda v: v*1.0, Y)
    classify(X, Y, testX, testY, onevone, c)