def command_line():
    args = parser.parse_args()

    if (args.validation):
        if (args.kfolds):
            fin = get_file(args.trainx[0])
            finy = get_file(args.trainy[0])
            if (args.method and args.method[0] == 'forest'):
                kcrossvalidation.do_kcross_validation(fin, finy,
                                                      int(args.kfolds[0]))

    if (args.testx):
        fin = get_file(args.trainx[0])
        finy = get_file(args.trainy[0])
        (training,
         validation) = get_training_validation_set(fin,
                                                   finy,
                                                   training_start=0,
                                                   training_end=2500,
                                                   validation_start=0,
                                                   validation_end=1)
        if (args.method and args.method[0] == 'forest'):
            forest = train_randomized_forest(training)
            classify_output(forest, treerandom)
            #print "accuracy : " + str(accuracy(validation,forest, treerandom))
            print "done"
示例#2
0
def run_k_times(k=1):
    for i in range(0,k):

        fin = get_file("trainx.txt")
        finy = get_file("trainy.csv")

        kcrossvalidation.do_kcross_validation(fin,finy,10)

        #kcrossvalidation.do_simpletree_kcross_validation(fin,finy,5)

        #(training,validation) = get_training_validation_set(fin,finy,training_start=0,training_end=2500,validation_start=2000,validation_end=2500)

        #tree = train_simple_tree(training)

        #treepredict.prune(tree,1)

        #print "accuracy : " + str(accuracy(validation,tree, treepredict))

        #forest = train_randomized_forest(training)
        #print "accuracy : " + str(accuracy(validation,forest, treerandom))

        #big_forest = train_big_randomized_forest(training)
        #print "accuracy : " + str(accuracy(validation,big_forest, big_treerandom))

        #classify_output(forest, treerandom)
        #classify_output(forest, big_treerandom)

        fin.close()
        finy.close()
def run_k_times(k=1):
    for i in range(0, k):

        fin = get_file("trainx.txt")
        finy = get_file("trainy.csv")

        kcrossvalidation.do_kcross_validation(fin, finy, 10)

        #kcrossvalidation.do_simpletree_kcross_validation(fin,finy,5)

        #(training,validation) = get_training_validation_set(fin,finy,training_start=0,training_end=2500,validation_start=2000,validation_end=2500)

        #tree = train_simple_tree(training)

        #treepredict.prune(tree,1)

        #print "accuracy : " + str(accuracy(validation,tree, treepredict))

        #forest = train_randomized_forest(training)
        #print "accuracy : " + str(accuracy(validation,forest, treerandom))

        #big_forest = train_big_randomized_forest(training)
        #print "accuracy : " + str(accuracy(validation,big_forest, big_treerandom))

        #classify_output(forest, treerandom)
        #classify_output(forest, big_treerandom)

        fin.close()
        finy.close()
示例#4
0
def command_line():
    args = parser.parse_args()

    if(args.validation):
        if(args.kfolds):
            fin = get_file(args.trainx[0])
            finy = get_file(args.trainy[0])
            if(args.method and args.method[0]=='forest'):
                kcrossvalidation.do_kcross_validation(fin,finy,int(args.kfolds[0]))           
           
    if(args.testx):
        fin = get_file(args.trainx[0])
        finy = get_file(args.trainy[0])
        (training,validation) = get_training_validation_set(fin,finy,training_start=0,training_end=2500,validation_start=0,validation_end=1)
        if(args.method and args.method[0]=='forest'):
            forest = train_randomized_forest(training)
            classify_output(forest, treerandom)
            #print "accuracy : " + str(accuracy(validation,forest, treerandom))
            print "done"