Open yoavram opened 9 years ago
def test_covar_is_none(self):
df = randomize_data(logistic_ode, reps=5)
params = curveball.models.logistic_model.make_params(r=0.1, y0=df.OD.min(), K=df.OD.max())
params['r'].set(min=0.5, max=1.0)
model_fit = curveball.models.logistic_model.fit(data=df.OD, t=df.Time, params=params)
self.assertIsNotNone(model_fit.covar)
t = np.linspace(0, 12)
y0=0.1; r=0.75; K=1.0
v = r
nu = 1.0
_lam = 2.0
q0 = 1.0 / (np.exp(_lam * v) - 1.0)
df = randomize_data(baranyi_roberts_ode, t=t, y0=y0, r=r, K=K, nu=nu, q0=q0, v=v, reps=1)
t = df.Time.as_matrix()
y = df.OD.as_matrix()
model = curveball.baranyi_roberts_model.BaranyiRobertsModel()
params = model.guess(data=y, t=t)
result = model.fit(data=y, t=t, params=params)
print('nu={}, lam={}'.format(nu, _lam))
print(result.fit_report())
v and q0 are ~1e12, doesn't happen when t goes to 24.
This problem can be circumvent using bootstrap_params
.
Sometimes when the fit fails,
ModelResult.covar
isNone
. In this case, some things will fails (sample_params
, who knows what else). One example - it happens when the bounds (min max) or params are too tight.