Пример #1
0
    def testBootstrapAccuracy(self):
        if IGNORE_TEST:
            return
        model = """
            J1: S1 -> S2; k1*S1
            J2: S2 -> S3; k2*S2
           
            S1 = 1; S2 = 0; S3 = 0;
            k1 = 0; k2 = 0; 
        """
        columns = ["S1", "S3"]
        fitter = ModelFitter(model,
                             BENCHMARK_PATH, ["k1", "k2"],
                             selectedColumns=columns,
                             isPlot=IS_PLOT)
        fitter.fitModel()
        print(fitter.reportFit())
        print(fitter.getParameterMeans())

        fitter.bootstrap(numIteration=1000, reportInterval=500)
        #calcObservedFunc=ModelFitter.calcObservedTSNormal, std=0.01)
        fitter.plotParameterEstimatePairs(['k1', 'k2'], markersize=2)
        print("Mean: %s" % str(fitter.getParameterMeans()))
        print("Std: %s" % str(fitter.getParameterStds()))
        fitter.reportBootstrap()
Пример #2
0
 def testWolfBug(self):
     if IGNORE_TEST:
         return
     trueParameterDct = {
         "J1_n": 4,
         "J4_kp": 76411,
         "J5_k": 80,
         "J6_k": 9.7,
         "J9_k": 28,
     }
     parametersToFit = [
         SBstoat.Parameter("J1_n", lower=1, value=1, upper=8),  # 4
         SBstoat.Parameter("J4_kp", lower=3600, value=36000,
                           upper=150000),  #76411
         SBstoat.Parameter("J5_k", lower=10, value=10, upper=160),  # 80
         SBstoat.Parameter("J6_k", lower=1, value=1, upper=10),  # 9.7
         SBstoat.Parameter("J9_k", lower=1, value=50, upper=50),  # 28
     ]
     ts = NamedTimeseries(csvPath=WOLF_DATA)
     methods = []
     for optName in ["differential_evolution", "leastsq"]:
         methods.append(SBstoat.OptimizerMethod(optName, {cn.MAX_NFEV: 10}))
     fitter = ModelFitter(WOLF_MODEL,
                          ts,
                          parametersToFit=parametersToFit,
                          fitterMethods=methods)
     fitter.fitModel()
     for name in [p.name for p in parametersToFit]:
         expected = trueParameterDct[name]
         actual = fitter.params.valuesdict()[name]
         self.assertLess(np.abs(np.log10(expected) - np.log10(actual)), 1.5)
         self.assertTrue(name in fitter.reportFit())
Пример #3
0
 def testWolfBug(self):
     if IGNORE_TEST:
         return
     fullDct = {
        #"J1_n": (1, 1, 8),  # 4
        #"J4_kp": (3600, 36000, 150000),  #76411
        #"J5_k": (10, 10, 160),  # 80
        #"J6_k": (1, 1, 10),  # 9.7
        "J9_k": (1, 50, 50),   # 28
        }
     for parameter in fullDct.keys():
         logger = Logger(logLevel=LEVEL_MAX)
         logger = Logger()
         ts = NamedTimeseries(csvPath=WOLF_DATA)
         parameterDct = {parameter: fullDct[parameter]}
         fitter = ModelFitter(WOLF_MODEL, ts[0:100],
               parameterDct=parameterDct,
               logger=logger, fitterMethods=[
                      "differential_evolution", "leastsq"]) 
         fitter.fitModel()
         self.assertTrue("J9_k" in fitter.reportFit())
Пример #4
0
SproutyFunc: -> Spry2; HillTime(V_0, K_0, n_0, t)


// Species IVs
Spry2 = 0;

// Parameter values
V_0 = 19.9059673;
K_0 = 10153.3568;
n_0 = 2.52290790;
t := time

end
''')

# sim = model.simulate(0, 7200, 7201)
# model.plot()
# quit()

fitter = ModelFitter(model,
                     "spry2_2a.txt", ["V_0", "K_0", "n_0"],
                     fitterMethods='differential_evolution',
                     parameterDct={
                         "V_0": (10, 20, 40),
                         "K_0": (1800, 6000, 20000),
                         "n_0": (1, 2, 12)
                     })
fitter.fitModel()
print(fitter.reportFit())