Exemplo n.º 1
0
def main(filename):
    plotname = filename[:-4]  # remove ".csv"

    x, y, ids = util.process_csv_list(filename)
    heatmap, xedges, yedges = np.histogram2d(x, y, bins=(10, 4))
    heatmap = heatmap[::-1]

    extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
    plt.imshow(heatmap, extent=extent, interpolation='nearest')
    plt.colorbar()
    plt.savefig(plotname)

    print "Generated heatmap image %s.png" % plotname
Exemplo n.º 2
0
def main(filename):    
    plotname = filename[:-4] # remove ".csv"

    x, y, ids = util.process_csv_list(filename)
    heatmap, xedges, yedges = np.histogram2d(x, y, bins=(10, 4))
    heatmap = heatmap[::-1]
    
    extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
    plt.imshow(heatmap, extent=extent, interpolation='nearest')
    plt.colorbar()
    plt.savefig(plotname)

    print "Generated heatmap image %s.png" % plotname
Exemplo n.º 3
0
def main(dirname):    

    filenames = os.listdir(dirname)
    for filename in filenames:
        if not ".json" in filename:
            continue

        filename = filename[:-5] + ".csv"
        print "Processing %s... " % filename[:-4],
        x, y, ids = util.process_csv_list(os.path.join(dirname, filename))
        new_x, new_y, removed = mahalanobis.remove_outliers(x, y) 
        print "done"
        print "Removed %d outlying point(s)" % (len(x) - len(new_x))
        print "Average error: %f, standard error: %f" % (rmse.calculate_rmse(new_x, new_y))
        print
Exemplo n.º 4
0
def make_arrays(dirname):
    data, predictions, boost_labels, maxent_labels = [], [], [], []

    filenames = os.listdir(dirname)
    for filename in filenames:
        if not ".json" in filename:
            continue

        print "Collecting data from %s... " % filename[:-5],
        conditions = util.process_json(os.path.join(dirname, filename))

        x, y, idx = util.process_csv_list(
            os.path.join(dirname, filename[:-5] + ".csv"))
        for i in range(len(x)):
            tempd, tempp = [0] * (util.num_conditions +
                                  1), [0] * (util.num_conditions + 1)
            for j in conditions:
                tempd[j] = 1
                tempp[j] = -1
            data.append(tempd)
            predictions.append(tempp)

            error = rmse.get_single_rmse(x[i], y[i])
            if error <= util.base_error / 2:
                boost_labels.append(1)
                maxent_labels.append(1)
            else:
                boost_labels.append(-1)
                maxent_labels.append(0)

        print "done"
        print

    data = np.array(data)
    predictions = np.array(predictions)
    boost_labels = np.array(boost_labels)
    maxent_labels = np.array(maxent_labels)
    return (data, predictions, boost_labels, maxent_labels)
Exemplo n.º 5
0
def make_arrays(dirname):
    data, predictions, boost_labels, maxent_labels = [], [], [], []

    filenames = os.listdir(dirname)
    for filename in filenames:
        if not ".json" in filename:
            continue

        print "Collecting data from %s... " % filename[:-5],
        conditions = util.process_json(os.path.join(dirname, filename))

        x, y, idx = util.process_csv_list(os.path.join(dirname, filename[:-5] + ".csv"))
        for i in range(len(x)):
            tempd, tempp = [0] * (util.num_conditions + 1), [0] * (util.num_conditions + 1)
            for j in conditions:
                tempd[j] = 1
                tempp[j] = -1
            data.append(tempd)
            predictions.append(tempp)

            error = rmse.get_single_rmse(x[i], y[i])
            if error <= util.base_error / 2:
                boost_labels.append(1)
                maxent_labels.append(1)
            else:
                boost_labels.append(-1)
                maxent_labels.append(0)

        print "done"
        print

    data = np.array(data)
    predictions = np.array(predictions)
    boost_labels = np.array(boost_labels)
    maxent_labels = np.array(maxent_labels)
    return (data, predictions, boost_labels, maxent_labels)
Exemplo n.º 6
0
def main(filename):
    actual, data = util.process_csv_list(filename)
    print "average error: %f \nstandard error: %f" % (calculate_rmse(
        actual, data))
Exemplo n.º 7
0
def main(filename):
    x, y = util.process_csv_list(filename)
    dm = calculate_mahalanobis(x, y)
    dm.sort()
    print dm
Exemplo n.º 8
0
def main(filename):
    x, y = util.process_csv_list(filename)
    dm = calculate_mahalanobis(x, y)
    dm.sort()
    print dm
Exemplo n.º 9
0
def main(filename):
    actual, data = util.process_csv_list(filename)
    print "average error: %f \nstandard error: %f" % (calculate_rmse(actual, data))