def main():
    # define the question # and question column set
    problem = 2

    csv = 'project510Data.csv'

    dataTotal = dTools.dataTotal(csv)

    q = qTools.Question(problem)
    q.getInputDataAndLabels(dataTotal._dataList)

    dataQ = dTools.dataQuestion(q, 0.90)

    nRuns = 10

    allRuns = []
    print "----"
    for ratio in range(950, 1000, 50):
        dataQ = dTools.dataQuestion(q, 1.0 * ratio / 1000)
        for maxIter in range(100, 300, 25):
            print "RATIO:", 1.0 * ratio / 1000
            print "MAX ITER: %d" % (maxIter)
            classifier = aiTools.classifier(q, dataQ, aiTools.featureExtractor,
                                            maxIter)

            allRuns.append((avgNruns(dataQ, classifier,
                                     nRuns), 1.0 * ratio / 1000, maxIter))
            print "--"
        print "----"

    allRuns.sort()
    print "TOP 15 RUNS:"
    for x in allRuns[-14:][::-1]:
        print x
Exemplo n.º 2
0
def main(problem, dataTotal):

    import questionTools as qTools
    import dataTools as dTools
    import aiTools

    q = qTools.Question(problem)
    q.getInputDataAndLabels(dataTotal._dataList)
    dataQ = dTools.dataQuestion(q, 0.90)

    classifier = aiTools.classifier(q, dataQ, aiTools.featureExtractor, 200)

    manager = multiprocessing.Manager()
    return_dict = manager.dict()
    tasks = manager.Queue()
    num_processes = 10
    pool = multiprocessing.Pool(num_processes)
    proc = []
    for i in range(num_processes):
        process_name = 'Proc%i' % i
        p = multiprocessing.Process(target=avgNruns,
                                    args=(dataQ, classifier, problem,
                                          return_dict, i))
        proc.append(p)
        p.start()

    for p in proc:
        p.join()

    runs = return_dict.values()
    avg = 1.0 * sum(runs) / len(runs)
    print "\nPROBLEM %d\nOver %d runs, accuracy averaged: %.2f%s\n" % (
        problem, len(runs), avg * 100, "%")
Exemplo n.º 3
0
def main(problem, dataTotal):

    import questionTools as qTools
    import dataTools as dTools
    import aiTools

    q = qTools.Question(problem)
    q.getInputDataAndLabels(dataTotal._dataList)

    num_processes = 5
    allRuns = []
    for RATIO in range(35, 60, 5):
        dataQ = dTools.dataQuestion(q, RATIO / 100.0)

        for MAX_ITER in range(20, 80, 5):
            classifier = aiTools.classifier(q, dataQ, aiTools.featureExtractor,
                                            MAX_ITER)

            manager = multiprocessing.Manager()
            return_dict = manager.dict()
            tasks = manager.Queue()
            pool = multiprocessing.Pool(num_processes)
            proc = []

            for i in range(num_processes):
                process_name = 'Proc%i' % i
                p = multiprocessing.Process(target=avgNruns,
                                            args=(dataQ, classifier, problem,
                                                  return_dict, i))
                proc.append(p)
                p.start()

            for p in proc:
                p.join()

            runs = return_dict.values()
            avg = 1.0 * sum(runs) / len(runs)
            print "\nPROBLEM %d\t%d\t%.2f\nOver %d runs, accuracy averaged: %.2f%s\n" % (
                problem, MAX_ITER, RATIO / 100.0, len(runs), avg * 100, "%")
            allRuns.append((avg, MAX_ITER, RATIO / 100.0))
            allRuns.sort()
            allRuns = allRuns[-14:]
            del classifier
            del manager, return_dict, p, proc, runs
        del dataQ
        print "TOP 15 RUNS:"
        for x in allRuns[::-1]:
            print x
Exemplo n.º 4
0
def main():
    # define the question # and question column set
    problem = 2

    csv = 'project510Data.csv'

    dataTotal = dTools.dataTotal(csv)

    q = qTools.Question(problem)
    q.getInputDataAndLabels(dataTotal._dataList)

    trainToTestRatio = 0.9

    dataQ = dTools.dataQuestion(q, trainToTestRatio)

    classifier = aiTools.classifier(q, dataQ, aiTools.featureExtractor,
                                    maxIter)

    classifier.prepDataTrain()
    classifier.train()
    tests.append(classifier.test())
Exemplo n.º 5
0
def main():
    # define the question # and question column set
    problem = 2

    csv = 'project510Data.csv'

    dataTotal = dTools.dataTotal(csv)

    q = qTools.Question(problem)
    q.getInputDataAndLabels(dataTotal._dataList)

    trainToTestRatio = 0.9

    dataQ = dTools.dataQuestion(q, trainToTestRatio)

    nRuns = 10

    classifier = aiTools.classifier(q, dataQ, aiTools.featureExtractor,
                                    maxIter)

    avgNruns(dataQ, classifier, nRuns)