def get_data_file_name(basename):
    for fn in [
            basename, basename + '.gz', 'data/' + basename,
            'data/' + basename + '.gz',
            utilmlab.get_proj_dir() + '/alg/gcit/ccle_experiments/data/' +
            basename,
            utilmlab.get_proj_dir() + '/alg/gcit/ccle_experiments/data/' +
            basename + '.gz'
    ]:
        if os.path.isfile(fn):
            return fn
    print(f'***')
    print(f'*** Error: cannot find file {basename}, see README.md of how'
          'to obtain the required data ***')
    print(f'***')
    assert 0
Exemplo n.º 2
0
def impute_gain(x, odir):
    python_exe = 'python3'
    script = '{}/gain/gain.py'.format(utilmlab.get_proj_dir())
    fn_i = '{}/xmissing.csv.gz'.format(odir)
    fn_o = '{}/ximputed.csv'.format(odir)
    x.to_csv(fn_i, compression='gzip', index=False)
    if os.path.isfile(fn_o):
        os.remove(fn_o)
    utilmlab.exe_cmd(
        logger, '{} {} -i {} -o {} --testall 1'.format(python_exe, script,
                                                       fn_i, fn_o))
    return pd.read_csv(fn_o)
Exemplo n.º 3
0
def init_arg():
    parser = argparse.ArgumentParser()
    parser.add_argument('--exe', help='python interpreter to use')
    parser.add_argument('--it', default=5000, type=int)
    parser.add_argument('--projdir')
    parser.add_argument("-n", "--numexp", default=10, type=int)
    return parser.parse_args()


if __name__ == '__main__':

    args = init_arg()

    numexp = args.numexp

    proj_dir = utilmlab.get_proj_dir() \
        if args.projdir is None else args.projdir

    alg = 'asac'

    if args.exe is not None:
        python_exe = args.exe
    else:
        python_exe = 'python' if sys.version_info[0] < 3 else 'python3'

    niter = args.it
    version = 1

    resdir = '{}/result/{}/v_{}/h_{}'.format(
        proj_dir, alg, version,
        os.environ['HOSTNAME'] if 'HOSTNAME' in os.environ else 'unknown')
    fn_model = get_temp_filename()

    verbose = args.verbose
    niter = args.it
    nstage = args.nstage

    if args.exe is not None:
        python_exe = args.exe
    else:
        python_exe = 'python' if sys.version_info[0] < 3 else 'python3'

    version = 1

    resdir = '{}/result/autoprognosis/v_{}/h_{}'.format(
        utilmlab.get_proj_dir(), version,
        os.environ['HOSTNAME'] if 'HOSTNAME' in os.environ else 'unknown')

    utilmlab.ensure_dir(resdir)

    logger = utilmlab.init_logger(resdir, 'log_test_autoprognosis.txt')

    result_all_d = dict()

    for dataset, nsample, sep in [('bc', 0, ','), ('cover', 5000, ';')]:

        odir = '{}/misc/dataset_{}'.format(resdir, dataset)

        fn_csv = set_filenames(odir)

        proj_dir = utilmlab.get_proj_dir() if args.projdir is None \
    model.nmax_model = nmax_model
    fn_i = args.i
    label = args.target
    p_miss = args.pmiss

    logger.info('autoprognosis version'.format(version))
    logger.info('ds:{} stages:{} n:{} metric:{} pmiss:{} it:{} '
                'model:{} aqt:{}'.format(
                    ds, nmax_model, nsample,
                    metric, p_miss, niter, fn_model,
                    acquisition_type))

    logger.info('{}'.format(args))
    if ds is not None and os.path.isfile(
            '{}/util/datasets.py'.format(
                utilmlab.get_proj_dir())):
        import datasets
        X_, Y_ = datasets.load_dataset(ds)
    else:
        assert fn_i is not None
        assert label is not None
        logger.info('loading {} lbl:{} sep:{}'.format(
            fn_i, label, sep))
        df = pd.read_csv(fn_i, sep=sep)
        features = list(df.columns)
        assert label in features
        features.remove(label)
        assert len(df)
        assert len(features) > 1
        X_ = df[features]
        Y_ = df[label]
Exemplo n.º 6
0
    parser.add_argument('--onlynotebook', type=int, default=0)
    return parser.parse_args()


if __name__ == '__main__':

    args = init_arg()

    is_only_notebook = args.onlynotebook

    if args.exe is not None:
        python_exe = args.exe
    else:
        python_exe = 'python' if sys.version_info[0] < 3 else 'python3'

    proj_dir = utilmlab.get_proj_dir() \
        if args.projdir is None else args.projdir

    logger = utilmlab.init_logger(
            '.', 
            'log_test_alg_{}.txt'.format(utilmlab.get_hostname()))

    if not is_only_notebook:

        # execute all unit tests

        f_lst = utilmlab.find_file_dir(
            '{}/alg'.format(proj_dir),
            'test_*.py')

        logger.info('Unit tests found:{}'.format(f_lst))