Пример #1
0
def test_scheme_acceptancerate():
    scheme = pyabc.AcceptanceRateScheme()
    temp = scheme(t=0, **scheme_args)
    assert 1.0 < temp

    # high acceptance probabilities
    _scheme_args = copy.deepcopy(scheme_args)
    # change normalization s.t. most have 1.0 acceptance rate
    records = pd.DataFrame(_scheme_args['get_all_records']())
    _scheme_args['pdf_norm'] = min(records['distance'])
    temp = scheme(t=0, **_scheme_args)
    assert temp == 1.0
Пример #2
0
def test_scheme_basic():
    schemes = [
        pyabc.AcceptanceRateScheme(),
        pyabc.ExponentialDecayScheme(),
        pyabc.PolynomialDecayScheme(),
        pyabc.DalyScheme(),
        pyabc.FrielPettittScheme(),
        pyabc.EssScheme()
    ]
    for scheme in schemes:
        # call them
        temp = scheme(t=0, **scheme_args)
        assert 1.0 < temp and temp < np.inf
Пример #3
0
    def __call__(
            self, prev_pdf_norm, get_weighted_distances, prev_temp, acceptance_rate, **kwargs):
        pdf_norm = pyabc.pdf_norm_max_found(prev_pdf_norm=prev_pdf_norm,
                                            get_weighted_distances=get_weighted_distances)
        print(" best: ", pdf_norm)
        if prev_temp is None or (acceptance_rate >= 0.1 and not self.hit):
            return pdf_norm
        self.hit = True
        temp = 0.6 * prev_temp
        offset = temp * np.log(10)
        used_norm = pdf_norm - offset
        used_norm = max(prev_pdf_norm, used_norm)
        print(" offsetted: ", pdf_norm - offset)
        return used_norm

prior = pyabc.Distribution(**{key: pyabc.RV("uniform", a, b-a)
                              for key, (a,b) in limits.items()})

acceptor = pyabc.StochasticAcceptor(log_file="acc_log_v5_higherc.json", pdf_norm_method=PDFNorm())
temperature = pyabc.Temperature(schemes=[pyabc.AcceptanceRateScheme(), pyabc.ExpDecayFixedRatioScheme(alpha=0.6)])
kernel = pyabc.IndependentNormalKernel(keys=keys, var=noise_vector**2)

sampler = pyabc.sampler.RedisEvalParallelSampler(host="icb-mona", port=8776)
#sampler = pyabc.sampler.MulticoreEvalParallelSampler(daemon=False)

abc = pyabc.ABCSMC(model, prior, kernel, sampler=sampler,
                   acceptor=acceptor, eps=temperature, population_size=500)
db_path="sqlite:///tumor2d_stoch_acc_v5_higherc.db"
abc.new(db_path, noisy_data)
abc.run()