def plot_test_prediction(target, predictions, model_name, data_desc,
                         error_func):
    save_plot = options.save_plot
    if save_plot:
        pp_path = get_path(options, "prediction_%s" % data_desc, "pdf")
        pp = PdfPages(pp_path)
    error = concat_and_calc_error(predictions, target, error_func)
    if np.any(target == 0):
        mapestr = "no MAPE due to 0's in observations"
    else:
        mapestr = 'MAPE: %3.2f' % concat_and_calc_error(
            predictions, target, sg.utils.mape)
    title = 'Test data prediction, %s, %s, %i days, model error: ' \
      '%3.2f, RMSE: %3.2f, %s' % \
      (model_name, data_desc, len(predictions), error,
       concat_and_calc_error(predictions, target, Oger.utils.rmse), mapestr)
    print "%s." % title
    plt.figure()
    plt.title(title)
    plot_target_predictions(target, predictions)
    if save_plot:
        pp.savefig()
        pp.close()
    if not options.no_show_plot:
        plt.ioff()  # In case --live-plot is chosen, since that sets ion().
        plt.show()
def plot_test_prediction(target, predictions, 
                         model_name, data_desc, error_func):
    save_plot = options.save_plot
    if save_plot:
        pp_path = get_path(options, "prediction_%s" % data_desc, "pdf")
        pp = PdfPages(pp_path)
    error = concat_and_calc_error(predictions, target, error_func)
    if np.any(target == 0):
        mapestr = "no MAPE due to 0's in observations"
    else:
        mapestr = 'MAPE: %3.2f' % concat_and_calc_error(predictions, target, 
                                              sg.utils.mape)
    title = 'Test data prediction, %s, %s, %i days, model error: ' \
      '%3.2f, RMSE: %3.2f, %s' % \
      (model_name, data_desc, len(predictions), error, 
       concat_and_calc_error(predictions, target, Oger.utils.rmse), mapestr)
    print "%s." % title
    plt.figure()
    plt.title(title)
    plot_target_predictions(target, predictions)
    if save_plot:
        pp.savefig()
        pp.close()
    if not options.no_show_plot:
        plt.ioff() # In case --live-plot is chosen, since that sets ion().
        plt.show()
def _save_test_prediction(target, predictions, data_desc):
    path = get_path(options, "test_series_%s" % data_desc, "pickle")
    with open(path, "a+") as f:
        pickle.dump((target, predictions), f)
def _save_test_prediction(target, 
                          predictions, data_desc):
    path = get_path(options, "test_series_%s" % data_desc, "pickle")
    with open(path, "a+") as f:
        pickle.dump((target, predictions), f)