예제 #1
0
def main(config, print_metrics=True):
    test = read_smiles_csv(config.test_path)
    test_scaffolds = None
    ptest = None
    ptest_scaffolds = None
    if config.test_scaffolds_path is not None:
        test_scaffolds = read_smiles_csv(config.test_scaffolds_path)
    if config.ptest_path is not None:
        if not os.path.exists(config.ptest_path):
            warnings.warn(f'{config.ptest_path} does not exist')
            ptest = None
        else:
            ptest = np.load(config.ptest_path)['stats'].item()
    if config.ptest_scaffolds_path is not None:
        if not os.path.exists(config.ptest_scaffolds_path):
            warnings.warn(f'{config.ptest_scaffolds_path} does not exist')
            ptest_scaffolds = None
        else:
            ptest_scaffolds = np.load(
                config.ptest_scaffolds_path)['stats'].item()
    gen = read_smiles_csv(config.gen_path)
    metrics = get_all_metrics(test,
                              gen,
                              k=config.ks,
                              n_jobs=config.n_jobs,
                              device=config.device,
                              test_scaffolds=test_scaffolds,
                              ptest=ptest,
                              ptest_scaffolds=ptest_scaffolds)

    if print_metrics:
        for name, value in metrics.items():
            print('{},{}'.format(name, value))
    else:
        return metrics
예제 #2
0
def main(config, print_metrics=True):
    test = None
    test_scaffolds = None
    ptest = None
    ptest_scaffolds = None
    train = None
    if config.test_path:
        test = read_smiles_csv(config.test_path)
    if config.test_scaffolds_path is not None:
        test_scaffolds = read_smiles_csv(config.test_scaffolds_path)
    if config.train_path is not None:
        train = read_smiles_csv(config.train_path)
    if config.ptest_path is not None:
        ptest = np.load(config.ptest_path, allow_pickle=True)['stats'].item()
    if config.ptest_scaffolds_path is not None:
        ptest_scaffolds = np.load(config.ptest_scaffolds_path,
                                  allow_pickle=True)['stats'].item()
    gen = read_smiles_csv(config.gen_path)
    metrics = get_all_metrics(gen=gen,
                              k=config.ks,
                              n_jobs=config.n_jobs,
                              device=config.device,
                              test_scaffolds=test_scaffolds,
                              ptest=ptest,
                              ptest_scaffolds=ptest_scaffolds,
                              test=test,
                              train=train)

    if print_metrics:
        for name, value in metrics.items():
            print('{},{}'.format(name, value))
    else:
        return metrics
예제 #3
0
파일: eval.py 프로젝트: sparel/moses
def main(config, print_metrics=True):
    ref = read_smiles_csv(config.ref_path)
    gen = read_smiles_csv(config.gen_path)
    metrics = get_all_metrics(ref, gen, k=config.ks, n_jobs=config.n_jobs,
                              gpu=config.device_code)

    if print_metrics:
        print('Metrics:')
        for name, value in metrics.items():
            print('\t' + name + ' = {}'.format(value))
    else:
        return metrics
예제 #4
0
def eval_metrics(eval_config, print_metrics=True):

    # need to detect if file has the header or not
    test = read_smiles_csv(model_config.test_path)
    test_scaffolds = None
    ptest = None
    ptest_scaffolds = None
    if model_config.test_scaffolds_path is not None:
        test_scaffolds = read_smiles_csv(model_config.test_scaffolds_path)
    if model_config.ptest_path is not None:
        if not os.path.exists(model_config.ptest_path):
            warnings.warn(f"{model_config.ptest_path} does not exist")
            ptest = None
        else:
            ptest = np.load(model_config.ptest_path)["stats"].item()
    if model_config.ptest_scaffolds_path is not None:
        if not os.path.exists(model_config.ptest_scaffolds_path):
            warnings.warn(f"{model_config.ptest_scaffolds_path} does not exist")
            ptest_scaffolds = None
        else:
            ptest_scaffolds = np.load(model_config.ptest_scaffolds_path)["stats"].item()
    gen = read_smiles_csv(model_config.gen_save)
    metrics = get_all_metrics(
        test,
        gen,
        k=model_config.ks,
        n_jobs=model_config.n_jobs,
        gpu=model_config.gpu,
        test_scaffolds=test_scaffolds,
        ptest=ptest,
        ptest_scaffolds=ptest_scaffolds,
    )

    if print_metrics:
        print("Metrics:")
        for name, value in metrics.items():
            print("\t" + name + " = {}".format(value))
        return metrics
    else:
        return metrics