svm = SVC(kernel=kern)
headers = "Size,Time (s),Percent Correct, Percent +, Percent -, Percent + correct, Percent - correct, False + percent, False - percent\n"

if multipleTests:
    file = open(approach + config.pulsar_analysis, 'w')
    file.write(kern + "\n")
    file.write(headers)
    err_cnt = 0

    for i in range(3):
        trialTime = datetime.datetime.now()
        svm = SVC(kernel=kern)
        line = "%d," % ((i + 1) * pulsar_step)

        logging.info('Getting Data............')
        pulsar_data = data_handler.getPulsarData(1, (i + 1) * pulsar_step)

        logging.info('Fitting Data............')
        svm.fit(pulsar_data[0], pulsar_data[1])

        logging.info('Testing Data............')
        test_data_prediction = svm.predict(pulsar_data[2])

        res = data_handler.recordResults(1, 0, config.pulsar_results,
                                         pulsar_data[3], test_data_prediction,
                                         approach, False)

        trialTime = (datetime.datetime.now() - trialTime).seconds
        line += "%.2f," % trialTime

        for item in res:
示例#2
0
headers = "Min split,Time (s),Percent Correct, Percent +, Percent -, Percent + correct, Percent - correct, False + percent, False - percent\n"

if multipleTests:
    file = open("./DT/_DT_" + config.pulsar_analysis, 'w')
    file.write("leaf,split = 100,depth = 9\n")
    file.write(headers)

    for i in range(1, 6):
        trialTime = datetime.datetime.now()
        clf = DecisionTreeClassifier(max_depth=best_depth,
                                     min_samples_leaf=best_leaf,
                                     min_samples_split=pow(10, i))
        line = "%d," % (pow(10, i))

        logging.info('Getting Data............')
        pulsar_data = data_handler.getPulsarData(1, pulsar_size)

        logging.info('Fitting Data............')
        clf.fit(pulsar_data[0], pulsar_data[1])

        logging.info('Testing Data............')
        test_data_prediction = clf.predict(pulsar_data[2])

        res = data_handler.recordResults(1, 0, config.pulsar_results,
                                         pulsar_data[3], test_data_prediction,
                                         "./DT/DT_", False)

        trialTime = (datetime.datetime.now() - trialTime).seconds
        line += "%.2f," % trialTime

        for item in res: