Beispiel #1
0
def experiment2(filename, ret_val):
    mmre = []
    for _ in xrange(30):
        method = guo_random(filename)
        training_data, testing_data = method.generate_test_data(ret_val)
        assert(len(training_data[0]) == len(training_data[-1])), "Something is wrong"
        assert(len(testing_data[0]) == len(testing_data[-1])), "Something is wrong"
        mmre.append(generate_model(training_data, testing_data))

    print round(np.mean(mmre) * 100, 3), round(np.std(mmre) * 100, 3),
Beispiel #2
0
def experiment1(filename, normalize=None):
    if normalize is not None:
        filename = normalize(filename)
    mmre = []
    for _ in xrange(30):
        print "# ",
        sys.stdout.flush()
        method = what(filename)
        training_data, testing_data = method.generate_test_data()
        assert (len(training_data[0]) == len(
            training_data[-1])), "Something is wrong"
        assert (len(testing_data[0]) == len(
            testing_data[-1])), "Something is wrong"
        mmre.append(generate_model(training_data, testing_data))

    print round(np.mean(mmre) * 100, 3), round(np.std(mmre) * 100, 3),
    return len(training_data[0])
Beispiel #3
0
def experiment1(filename, normalize=None, feature_weights=False):
    if normalize is not None:
        name = filename.split('/')[-1]
        norm_filename = "./NData/zscore/norm_" + name

    mmre = []
    for _ in xrange(30):
        if feature_weights is True:
            filename = add_feature_weights(norm_filename)
        method = what(filename)
        training_data, testing_data = method.generate_test_data()
        assert(len(training_data[0]) == len(training_data[-1])), "Something is wrong"
        assert(len(testing_data[0]) == len(testing_data[-1])), "Something is wrong"
        mmre.append(generate_model(training_data, testing_data))

    print round(np.mean(mmre) * 100, 3), round(np.std(mmre) * 100, 3),
    return len(training_data[0])
Beispiel #4
0
            test_independent.append(map(float, content[ti][:-1]))
            test_dependent.append(float(content[ti][-1]))

        assert (
            len(test_independent) == len(test_dependent)), "something wrong"

        train_indexes = range(len(train_independent))
        shuffle(train_indexes)

        selected_points_indep = [
            train_independent[i] for i in xrange(len(train_indexes[:number]))
        ]
        selected_points_dep = [
            train_dependent[i] for i in xrange(len(train_indexes[:number]))
        ]
        return [selected_points_indep,
                selected_points_dep], [test_independent, test_dependent]


if __name__ == "__main__":
    mmre = []
    for _ in xrange(30):
        method = guo_random("./Data/Apache_AllMeasurements.csv")
        training_data, testing_data = method.generate_test_data()
        assert (len(training_data[0]) == len(
            training_data[-1])), "Something is wrong"
        assert (len(testing_data[0]) == len(
            testing_data[-1])), "Something is wrong"
        mmre.append(generate_model(training_data, testing_data))

    print np.median(mmre)