def run(model_creator_class):
    """Main entry point for specific models. model_creator is an instance of a
    class used to set up the model and the data."""
    get_options()
    if not is_mpi_slave(options):
        timer = SimpleTimer()
    prev_handler = np.seterrcall(float_err_handler)
    prev_err = np.seterr(all='call')
    np.seterr(under='ignore')
    random.seed(options.seed)
    np.random.seed(options.seed)
    model_creator = model_creator_class(options)
    model = model_creator.get_model()
    if not is_mpi_slave(options):
        _print_sim_context(model.dataset)
    _run_models([model], model.dataset)
    ul.tempfeeder_exp().close()
def run(model_creator_class): 
    """Main entry point for specific models. model_creator is an instance of a
    class used to set up the model and the data."""
    get_options()
    if not is_mpi_slave(options):
        timer = SimpleTimer()
    prev_handler = np.seterrcall(float_err_handler)
    prev_err = np.seterr(all='call')
    np.seterr(under='ignore')
    random.seed(options.seed)
    np.random.seed(options.seed)
    model_creator = model_creator_class(options)
    model = model_creator.get_model()
    if not is_mpi_slave(options):
        _print_sim_context(model.dataset)
    _run_models([model], model.dataset)
    ul.tempfeeder_exp().close()
def _run_models(models, dataset):
    data_desc = dataset.desc
    for model in models:
        if not is_mpi_slave(options):
            print "Optimizing parameters for model", model.name, "."
        run_GA(model, options)
        if is_mpi_slave(options):
            continue
        raw_genes = pu.raw_genes(model.genome, strip=True)
        print "Best genes found during evolution: ", raw_genes
        target, predictions = test_genome(raw_genes, model)
        _save_test_prediction(target, predictions, data_desc)
        error = concat_and_calc_error(predictions, target, model.error_func)
        print "Error on test phase for best genome found, " \
          "%s, %i days: %5.4f" % (data_desc, len(predictions), error)
        if not options.no_plot:
            plot_test_prediction(target, predictions, model.name, data_desc,
                                 model.error_func)
def _run_models(models, dataset):
    data_desc = dataset.desc
    for model in models:
        if not is_mpi_slave(options):
            print "Optimizing parameters for model", model.name, "."
        run_GA(model, options)
        if is_mpi_slave(options):
            continue
        raw_genes = pu.raw_genes(model.genome, strip=True)
        print "Best genes found during evolution: ", raw_genes
        target, predictions = test_genome(raw_genes, model)
        _save_test_prediction(target, predictions, data_desc)
        error = concat_and_calc_error(predictions, target, model.error_func)
        print "Error on test phase for best genome found, " \
          "%s, %i days: %5.4f" % (data_desc, len(predictions), error)
        if not options.no_plot:
            plot_test_prediction(target, predictions, 
                                 model.name, data_desc, model.error_func)