예제 #1
0
def signle_svm(train_file, test_file, kernel):
    print("Single SVM", flush=True)
    start_time = time.time()
    RS_SVM = RandomSamplingSVM(kernel)
    model = RS_SVM.train_single(train_file)
    print("Remain SVs: " + str(model.n_support_), flush=True)
    print("Training time: %s" % (time.time() - start_time), flush=True)
    X_test, y_test = datasets.load_svmlight_file(test_file)
    ratio = model.score(X_test,y_test)
    print("Accuracy %f" % ratio, flush=True)
    print("Total time: %s" % (time.time() - start_time), flush=True)