Beispiel #1
0
def plotmixing(samples, param_name, filename=None):
    p = Plot(title='%s mixing plot' % param_name)
    points = Points([(i,s[param_name]) for i,s in enumerate(samples)],
            style='lines')
    points.linewidth=1
    p.append(points)
    p.show()
    if filename:
        p.write(filename)
Beispiel #2
0
def make_histogram(image, filename, numbins=32):
    width, height = image.size
    data = []
    for i in range(width):
        for j in range(height):
            pixel = image.getpixel((i,j))
            data.append(pixel)
    p = Plot()
    hist = Histogram(data, numbins)
    p.append(hist)
    p.write(filename)
Beispiel #3
0
def plotposterior(samples, param_name, min=None, max=None, prior=None,
        filename=None):
    p = Plot(title='Posterior of %s' % param_name)
    density = Density([s[param_name] for s in samples], title='Posterior')
    p.append(density)
    if prior:
        priord = Function(prior, title='Prior')
        p.append(priord)
    if min is not None:
        p.xmin = min
    if max is not None:
        p.xmax = max
    p.show()
    if filename:
        p.write(filename)
Beispiel #4
0
def do_iris_HAC():
    numvars, names, data, labels = read_data('iris.cluster.txt')
    DE = HAC(data, .1)
    data = []
    for grouping in DE:
        if grouping[0] != 0:
            K = grouping[2]
            K.compute_means()
            data.append((grouping[1], K.error()))
            print grouping[0], grouping[1], K.error()
            for cluster in K.clusters:
                cluster.indices.sort()
                print cluster.indices
    plot = Plot()
    plot.title = 'SSE as a function of number of clusters in HAC'
    plot.append(Points(data, style='lines'))
    plot.write('hac_clusters.gpi')
Beispiel #5
0
def main():
    tm_results = parse_file('with_topic_model.log')
    ntm_results = parse_file('without_topic_model.log')
    p = Plot(title="Precision/Recall for Labeled Mentions")
    p.xmin = 0
    p.xmax = 1
    p.ymin = 0
    p.ymax = 1
    p.append(Points(tm_results[0].prec_rec,
        style='lines', title='With topic model'))
    p.append(Points(ntm_results[4].prec_rec,
        style='lines', title='Without topic model'))
    p.append(Points(tm_results[14].prec_rec,
        style='lines', title='With topic model after sampling'))
    p.append(Points(ntm_results[14].prec_rec,
        style='lines', title='Without topic model after sampling'))
    p.append(Points([(tm_results[0].baseline_rec,
        tm_results[0].baseline_prec)],
        title='Baseline performance'))
    p.write('prec_rec.gpi')
    p.show()
Beispiel #6
0
if not args:
    parser.error('Log file not specified.')

plot = Plot()
plot.ylogscale = 10
plot.xlabel = 'Function Evaluations'
plot.ylabel = 'Best Function Value'

for filename in args:
    data = PSOData(open(filename))
    trim = int(len(data) / 10)
    points = []
    bars = []
    iterations = len(data[0])
    samples_step = int(math.ceil(iterations / MAX_SAMPLES))
    bar_samples_step = int(math.ceil(iterations / MAX_BAR_SAMPLES))
    for iteration in islice(data[0], 0, None, samples_step):
        points.append((iteration, data.average(iteration)))
    for iteration in islice(data[0], 0, None, bar_samples_step):
        low, med, high = data.statistics(iteration, trim)
        bars.append((iteration, med, low, high))
    plot.append(Points(points, title=filename, style='lines'))
    plot.append(RawData(bars, style='errorbars'))

plot.show()

if opts.print_page:
    plot.print_page()

# vim: et sw=4 sts=4