def test_invalid_cdf(self): from helpers import metrics pred = [metrics._heavyside(self.thresholds, actual) for actual in self.actuals] pred[1] = [0, 0.5, 0.3, 0.8, 1.0] # not a valid CDF print(pred) crps = metrics.mean_crps(self.thresholds, pred, self.actuals) print("Invalid CDF for one case: answer = {0}".format(crps)) assert_almost_equal(crps, 1.0 / 4) # since one case is wrong
def test_exact_answer(self): from helpers import metrics # if the user supplies the exact answers, CRPS is zero. pred = [metrics._heavyside(self.thresholds, actual) for actual in self.actuals] print(pred) crps = metrics.mean_crps(self.thresholds, pred, self.actuals) print("Exact answer = {0}".format(crps)) assert_almost_equal(crps, 0.)