Skip to content

Commit

Permalink
think ll makes more sense now, but added a breaking weibull test
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbern committed Jul 23, 2019
1 parent 386baf1 commit d9c229f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion convoys/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def generalized_gamma_loss(x, X, B, T, W, fix_k, fix_p,
elif flavor == 'linear': # L2 loss, linear
c = dot(X, beta)+b
LL_observed = -(1 - c)**2 + log_pdf
LL_censored = -c**2 * cdf - (1 - c)**2 * (1 - cdf)
LL_censored = -c**2 * cdf

LL_data = sum(
W * B * LL_observed +
Expand Down
7 changes: 7 additions & 0 deletions test_convoys.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ def test_weibull_regression_model(cs=[0.3, 0.5, 0.7],
x = [int(r == j) for j in range(len(cs))]
assert 0.80 * c < model.cdf(x, float('inf')) < 1.30 * c

# Fit a linear model
model = convoys.regression.Weibull(ci=False, flavor='linear')
model.fit(X, B, T)
model_cs = model.params['map']['b'] + model.params['map']['beta']
for model_c, c in zip(model_cs, cs):
assert 0.8 * c < model_c < 1.2 * c


@flaky.flaky
def test_gamma_regression_model(c=0.3, lambd=0.1, k=3.0, n=10000):
Expand Down

0 comments on commit d9c229f

Please sign in to comment.