Esempio n. 1
0
def test_do_model_predictions():
    """Test model predictions"""
    generate_model()
    os.rename(pjoin(cfg.MODELS_FOLDER, "TEMP_TEST01_RF.pkl"),
              pjoin(cfg.MODELS_FOLDER, "TEST001_RF.pkl"))
    for suffix in ["classes.npy", "features.csv"]:
        shutil.copy(
            pjoin(DATA_PATH, "test_%s" % suffix),
            pjoin(cfg.FEATURES_FOLDER, "TEST001_%s" % suffix))
    featset_key = "TEST001"
    model_type = "RF"
    features_to_use = ["std_err", "avg_err", "med_err", "n_epochs", "amplitude"]
    data_dict = pred.featurize_tsdata(
        pjoin(DATA_PATH, "dotastro_215153.dat"),
        "TEST001",
        None, None, False,
        features_to_use, False)
    print(data_dict)
    pred_results_dict = pred.do_model_predictions(data_dict, featset_key,
                                                  model_type, features_to_use,
                                                  5)
    assert("dotastro_215153" in pred_results_dict)
    assert("std_err" in
           pred_results_dict["dotastro_215153"]["features_dict"])
    assert(all(all(el[0] in ['Mira', 'Herbig_AEBE', 'Beta_Lyrae',
                             'Classical_Cepheid', 'W_Ursae_Maj', 'Delta_Scuti']
                   for el in pred_results_dict[fname]\
                   ["pred_results_list"]) for fname in pred_results_dict))
Esempio n. 2
0
def test_featurize_tsdata():
    """Test featurize_tsdata"""
    res_dict = pred.featurize_tsdata(
        pjoin(DATA_PATH, "dotastro_215153.dat"),
        "TEMP_TEST01",
        None, None, False,
        ['std_err'], False)
    assert all("std_err" in d["features_dict"]
               for fname, d in res_dict.items())
    assert all("ts_data" in d for fname, d in res_dict.items())