Ejemplo n.º 1
0
        make_dataset.make_dataset(settings)
        lu.print_blue("Finished constructing dataset")

    ################
    # TRAINING
    ################
    if settings.train_rnn:

        # Train
        if settings.cyclic:
            train_rnn.train_cyclic(settings)
        else:
            train_rnn.train(settings)

        # Obtain predictions
        validate_rnn.get_predictions(settings)
        # Compute metrics
        metrics.get_metrics_singlemodel(settings, model_type="rnn")
        # Plot some lightcurves
        early_prediction.make_early_prediction(settings)

        lu.print_blue(
            "Finished rnn training, validating, testing and plotting lcs")

    if settings.train_rf:

        train_randomforest.train(settings)
        # Obtain predictions
        validate_randomforest.get_predictions(settings)
        # Compute metrics
        metrics.get_metrics_singlemodel(settings, model_type="rf")
if installed by "pip install supernnova"
you can run this code in the parent folder (where run.py is)
"""

# get config args
args = conf.get_args()

# create database
args.data = True  # conf: making new dataset
args.dump_dir = "tests/dump"  # conf: where the dataset will be saved
args.raw_dir = "tests/raw"  # conf: where raw photometry files are saved
args.fits_dir = "tests/fits"  # conf: where salt2fits are saved
settings = conf.get_settings(args)  # conf: set settings
make_dataset.make_dataset(settings)  # make dataset

# train model
args.data = False  # conf: no database creation
args.train_rnn = True  # conf: train rnn
args.dump_dir = "tests/dump"  # conf: where the dataset is saved
args.nb_epoch = 2  # conf: training epochs
settings = conf.get_settings(args)  # conf: set settings
train_rnn.train(settings)  # train rnn

# validate (test set classificatio)
args.data = False  # conf: no database creation
args.train_rnn = False  # conf: no train rnn
args.validate_rnn = False  # conf: validate rnn
args.dump_dir = "tests/dump"  # conf: where the dataset is saved
settings = conf.get_settings(args)  # conf: set settings
validate_rnn.get_predictions(settings)  # classify test set