Example #1
0
 def _plot(frame, variable_suffix, filename=None, dirname='./'):
     x = frame['gen_' + variable_suffix]
     y = frame['final_' + variable_suffix]
     _scatter(x, y)
     pylab.title(variable_suffix)
     if filename is not None:
         pu.save_current_figure(filename, dir=dirname, close=True)
         pass
     return
Example #2
0
def plot_diagnostic_data(
    forward_diagnostics_data,
    diagnostics_data_list,
    kl_series_list,
    variable_name,
    parameters=None,
    save_kwargs=None,
):
    plotter = plotter_lookup[variable_name]
    mapped_variable_name = map_variable_name(variable_name)
    which_idx = numpy.random.randint(len(diagnostics_data_list))
    diagnostics_data = diagnostics_data_list[which_idx]
    forward = forward_diagnostics_data[variable_name]
    not_forward_list = [el[variable_name] for el in diagnostics_data_list]
    pylab.figure()
    #
    pylab.subplot(311)
    pylab.title('Geweke analysis for %s' % mapped_variable_name)
    plotter(variable_name,
            forward_diagnostics_data,
            new_figure=False,
            do_labelling=False)
    pylab.ylabel('Forward samples\n mass')
    #
    pylab.subplot(312)
    plotter(variable_name,
            diagnostics_data,
            new_figure=False,
            do_labelling=False)
    pylab.ylabel('Posterior samples\n mass')
    #
    pylab.subplot(313)
    map(pylab.plot, kl_series_list)
    pylab.xlabel('iteration')
    pylab.ylabel('KL')
    # FIXME: remove, or do something "better"
    pylab.gca().set_ylim((0., 0.1))
    if parameters is not None:
        pu.show_parameters(parameters)
        pass
    if save_kwargs is not None:
        filename = variable_name + '_hist.png'
        pu.save_current_figure(filename, format=image_format, **save_kwargs)
        #
        filename = variable_name + '_pp.png'
        pylab.figure()
        for not_forward in not_forward_list:
            pp_plot(forward, not_forward, 100)
            pass
        pu.save_current_figure(filename, format=image_format, **save_kwargs)
        pass
    return
Example #3
0
def plot_diagnostic_data(forward_diagnostics_data, diagnostics_data_list,
        kl_series_list, variable_name,
        parameters=None, save_kwargs=None,
        ):
    plotter = plotter_lookup[variable_name]
    mapped_variable_name = map_variable_name(variable_name)
    which_idx = numpy.random.randint(len(diagnostics_data_list))
    diagnostics_data = diagnostics_data_list[which_idx]
    forward = forward_diagnostics_data[variable_name]
    not_forward_list = [el[variable_name] for el in diagnostics_data_list]
    pylab.figure()
    #
    pylab.subplot(311)
    pylab.title('Geweke analysis for %s' % mapped_variable_name)
    plotter(variable_name, forward_diagnostics_data, new_figure=False,
            do_labelling=False)
    pylab.ylabel('Forward samples\n mass')
    #
    pylab.subplot(312)
    plotter(variable_name, diagnostics_data, new_figure=False,
            do_labelling=False)
    pylab.ylabel('Posterior samples\n mass')
    #
    pylab.subplot(313)
    map(pylab.plot, kl_series_list)
    pylab.xlabel('iteration')
    pylab.ylabel('KL')
    # FIXME: remove, or do something "better"
    pylab.gca().set_ylim((0., 0.1))
    if parameters is not None:
        pu.show_parameters(parameters)
        pass
    if save_kwargs is not None:
        filename = variable_name + '_hist.png'
        pu.save_current_figure(filename, format=image_format, **save_kwargs)
        #
        filename = variable_name + '_pp.png'
        pylab.figure()
        for not_forward in not_forward_list:
            pp_plot(forward, not_forward, 100)
            pass
        pu.save_current_figure(filename, format=image_format, **save_kwargs)
        pass
    return