Skip to content

Commit

Permalink
remove intercept term from regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbern committed Mar 26, 2018
1 parent d35f179 commit 41cf6e6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test_convoys.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_exponential_regression_model(c=0.3, lambd=0.1, n=100000):

@flaky.flaky
def test_weibull_regression_model(cs=[0.3, 0.5, 0.7], lambd=0.1, k=0.5, n=100000):
X = numpy.array([[1] + [r % len(cs) == j for j in range(len(cs))] for r in range(n)])
X = numpy.array([[r % len(cs) == j for j in range(len(cs))] for r in range(n)])
C = numpy.array([bool(random.random() < cs[r % len(cs)]) for r in range(n)])
N = scipy.stats.uniform.rvs(scale=5./lambd, size=(n,))
E = numpy.array([sample_weibull(k, lambd) for r in range(n)])
Expand All @@ -63,7 +63,7 @@ def test_weibull_regression_model(cs=[0.3, 0.5, 0.7], lambd=0.1, k=0.5, n=100000
model.fit(X, B, T)

# Validate shape of results
x = numpy.ones((len(cs)+1,))
x = numpy.ones((len(cs),))
assert model.predict_final(x).shape == ()
assert model.predict_final(x, ci=0.95).shape == (3,)
assert model.predict(x, 1).shape == ()
Expand All @@ -73,7 +73,7 @@ def test_weibull_regression_model(cs=[0.3, 0.5, 0.7], lambd=0.1, k=0.5, n=100000

# Check results
for r, c in enumerate(cs):
x = [1] + [int(r == j) for j in range(len(cs))]
x = [int(r == j) for j in range(len(cs))]
assert 0.95 * c < model.predict_final(x) < 1.05 * c
expected_time = 1./lambd * scipy.special.gamma(1 + 1/k)
assert 0.80*expected_time < model.predict_time(x) < 1.20*expected_time
Expand Down

0 comments on commit 41cf6e6

Please sign in to comment.