コード例 #1
0
ファイル: fit_rf.py プロジェクト: flaxter/gbd
    def handle(self, *id_list, **options):
        asrfs = AgeSpecificRateFunction.objects.filter(id__in=id_list)

        #for asrf in asrfs:
        #    print "\n\nFast Fitting %s" % asrf.pk
        #    fit_rate_function.mcmc_fit(asrf, speed='fast')

        for asrf in asrfs:
            print "\n\nFitting %s" % asrf.id
            fit_rate_function.mcmc_fit(asrf)
コード例 #2
0
ファイル: run_tests.py プロジェクト: jjdu/gbd
    def handle(self, *args, **options):
        if args[0] == "dm":
            r = create_test_asrf(".05", rate_type="remission data", priors="smooth 10.0\nconfidence 1000 .1")
            p = create_test_asrf(
                ".2+.3*.01*age", rate_type="prevalence data", priors="smooth 10.0\nincreasing 0 100\nconfidence 1000 .1"
            )
            cf = create_test_asrf("0.", rate_type="case fatality data", priors="smooth 10.0\nconfidence 200 .1")

            dm = DiseaseModel(disease=cf.disease, region=cf.region, sex=cf.sex)
            dm.save()
            dm.rates = [r, p, cf]
            dm.save()

            print "Fitting %s\n  http://winthrop.gs.washington.edu:5432%s" % (dm.id, dm.get_absolute_url())
            fit_disease_model.mcmc_fit(dm)

            i = create_test_asrf("0.", rate_type="incidence data", priors="smooth 10.0\nconfidence 1000 .1")
            p = create_test_asrf(
                ".5 - .3*.01*age",
                rate_type="prevalence data",
                priors="smooth 10.0\ndecreasing 0 100\nconfidence 1000 .1",
            )
            cf = create_test_asrf("0.", rate_type="case fatality data", priors="smooth 10.0\nconfidence 1000 .1")

            dm = DiseaseModel(disease=cf.disease, region=cf.region, sex=cf.sex)
            dm.save()
            dm.rates = [i, p, cf]
            dm.save()

            print "Fitting %s\n  http://winthrop.gs.washington.edu:5432%s" % (dm.id, dm.get_absolute_url())
            fit_disease_model.mcmc_fit(dm)

            i = create_test_asrf("0.", rate_type="incidence data", priors="smooth 10.0\nconfidence 1000 .1")
            r = create_test_asrf(".05", rate_type="remission data", priors="smooth 10.0\nconfidence 1000 .1")
            cf = create_test_asrf("0.", rate_type="case fatality data", priors="smooth 10.0\nconfidence 1000 .1")

            dm = DiseaseModel(disease=cf.disease, region=cf.region, sex=cf.sex)
            dm.save()
            dm.rates = [i, r, cf]
            dm.save()

            print "Fitting %s\n  http://winthrop.gs.washington.edu:5432%s" % (dm.id, dm.get_absolute_url())
            fit_disease_model.mcmc_fit(dm)
            i = create_test_asrf(".1", rate_type="incidence data", priors="smooth 10.0\nconfidence 1000 .1")
            r = create_test_asrf(".05", rate_type="remission data", priors="smooth 10.0\nconfidence 1000 .1")
            p = create_test_asrf(
                ".07*(age/100.0)**2", rate_type="prevalence data", priors="smooth 10.0\nconfidence 1000 .1"
            )

            dm = DiseaseModel(disease=cf.disease, region=cf.region, sex=cf.sex)
            dm.save()
            dm.rates = [i, r, p]
            dm.save()

            print "Fitting %s\n  http://winthrop.gs.washington.edu:5432%s" % (dm.id, dm.get_absolute_url())
            fit_disease_model.mcmc_fit(dm)

            print "\nModel %d is fit\n  http://winthrop.gs.washington.edu:5432%s" % (dm.id, dm.get_absolute_url())
        elif args[0] == "rf":
            if args[1] == "unimodal":
                rf = create_test_asrf(
                    ".6-2.*(.5-age/100.0)**2",
                    rate_type="incidence data",
                    priors="smooth 10.0\nunimodal 0 100\nconfidence 1000 .1",
                )
                print "Fitting %s\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())
                fit_rate_function.mcmc_fit(rf)
                print "\nModel %d is fit\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())

                rf = create_test_asrf(
                    ".06-.2*(.5-age/100.0)**2", rate_type="incidence data", priors="smooth 10.0\nunimodal 0 100"
                )
                print "Fitting %s\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())
                fit_rate_function.mcmc_fit(rf)
                print "\nModel %d is fit\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())
            elif args[1] == "increasing":
                rf = create_test_asrf(
                    ".01 + .5*(age/100.0)**2",
                    rate_type="remission data",
                    priors="smooth 10.0\nincreasing 0 100\nconfidence 1000 .1",
                )
                print "Fitting %s\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())
                fit_rate_function.mcmc_fit(rf)
                print "\nModel %d is fit\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())

                rf = create_test_asrf(
                    ".001 + .05*(age/100.0)", rate_type="incidence data", priors="smooth 10.0\nincreasing 0 100"
                )
                print "Fitting %s\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())
                fit_rate_function.mcmc_fit(rf)
                print "\nModel %d is fit\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())
            elif args[1] == "decreasing":
                rf = create_test_asrf(
                    ".61 - .5*(age/100.0)**2", rate_type="remission data", priors="smooth 10.0\ndecreasing 0 100"
                )
                print "Fitting %s\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())
                fit_rate_function.mcmc_fit(rf)
                print "\nModel %d is fit\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())

                rf = create_test_asrf(
                    ".061 - .05*(age/100.0)", rate_type="incidence data", priors="smooth 10.0\ndecreasing 0 100"
                )
                print "Fitting %s\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())
                fit_rate_function.mcmc_fit(rf)
                print "\nModel %d is fit\n  http://winthrop.gs.washington.edu:5432%s" % (rf.id, rf.get_absolute_url())
コード例 #3
0
 def test_fit(self):
     from dismod3.bayesian_models import fit_rate_function
     from dismod3.tests import bayesian_probability_test
     bayesian_probability_test.add_priors(self.asrf)
     fit_rate_function.mcmc_fit(self.asrf, speed='testing fast')