예제 #1
0
파일: run_igsp.py 프로젝트: csquires/utigsp
    # === CREATE DAGS AND SAMPLES: THIS MUST BE DONE THE SAME WAY EVERY TIME FOR THIS TO WORK
    save_dags_and_samples(ndags,
                          nnodes,
                          nneighbors,
                          nsamples,
                          nsettings,
                          num_known,
                          num_unknown,
                          intervention,
                          nonlinear=nonlinear)
    sample_folders = [
        get_sample_folder(ndags,
                          nnodes,
                          nneighbors,
                          nsamples,
                          nsettings,
                          num_known,
                          num_unknown,
                          intervention,
                          dag_num,
                          nonlinear=nonlinear) for dag_num in range(ndags)
    ]

    def _run_igsp(dag_num):
        # === GENERATE FILENAME
        sample_folder = sample_folders[dag_num]
        alg_folder = os.path.join(sample_folder, 'estimates', 'igsp')
        os.makedirs(alg_folder, exist_ok=True)
        filename = os.path.join(
            alg_folder,
            'nruns=%d,depth=%d,alpha=%.2e,alpha_invariant=%.2e.npy' %
            (nruns, depth, alpha, alpha_invariant))
예제 #2
0
파일: run_icp.py 프로젝트: csquires/utigsp
    ndags = args.ndags
    nnodes = args.nnodes
    nneighbors = args.nneighbors

    nsamples = args.nsamples
    nsettings = args.nsettings
    num_known = args.num_known
    num_unknown = args.num_unknown
    intervention = args.intervention

    alpha = args.alpha

    # === CREATE DAGS AND SAMPLES: THIS MUST BE DONE THE SAME WAY EVERY TIME FOR THIS TO WORK
    save_dags_and_samples(ndags, nnodes, nneighbors, nsamples, nsettings, num_known, num_unknown, intervention)
    sample_folders = [
        get_sample_folder(ndags, nnodes, nneighbors, nsamples, nsettings, num_known, num_unknown, intervention, dag_num)
        for dag_num in range(ndags)
    ]


    def _run_icp(dag_num):
        # === GENERATE FILENAME
        sample_folder = sample_folders[dag_num]
        alg_folder = os.path.join(sample_folder, 'estimates', 'icp')
        os.makedirs(alg_folder, exist_ok=True)
        filename = os.path.join(alg_folder, 'alpha=%.2e' % alpha)

        # === RUN ALGORITHM
        if not os.path.exists(filename) or overwrite:
            est_amat = run_icp(
                sample_folder,