improvements in docstrings and testing for disabling uncertainty

This commit is contained in:
Ben Letham 2020-02-04 13:22:08 -08:00
parent 8d0f23f8be
commit be25372090
4 changed files with 10 additions and 6 deletions

View file

@ -242,8 +242,8 @@ performance_metrics <- function(df, metrics = NULL, rolling_window = 0.1) {
if (is.null(metrics)) { if (is.null(metrics)) {
metrics <- valid_metrics metrics <- valid_metrics
} }
if (!('yhat_lower' %in% colnames(df)) | (!('yhat_upper' %in% colnames(df))) & ('coverage' %in% metrics)){ if ((!('yhat_lower' %in% colnames(df)) | !('yhat_upper' %in% colnames(df))) & ('coverage' %in% metrics)){
metrics <- valid_metrics[valid_metrics != 'coverage'] metrics <- metrics[metrics != 'coverage']
} }
if (length(metrics) != length(unique(metrics))) { if (length(metrics) != length(unique(metrics))) {

View file

@ -99,6 +99,8 @@ test_that("cross_validation_uncertainty_disabled", {
m, horizon = 4, units = "days", period = 4, initial = 115) m, horizon = 4, units = "days", period = 4, initial = 115)
expected.cols <- c('y', 'ds', 'yhat', 'cutoff') expected.cols <- c('y', 'ds', 'yhat', 'cutoff')
expect_equal(expected.cols, colnames(df.cv)) expect_equal(expected.cols, colnames(df.cv))
df.p <- performance_metrics(df.cv)
expect_false('coverage' %in% colnames(df.p))
} }
}) })

View file

@ -114,6 +114,8 @@ class TestDiagnostics(TestCase):
m, horizon='4 days', period='4 days', initial='115 days') m, horizon='4 days', period='4 days', initial='115 days')
expected_cols = ['ds', 'yhat', 'y', 'cutoff'] expected_cols = ['ds', 'yhat', 'y', 'cutoff']
self.assertTrue(all(col in expected_cols for col in df_cv.columns.tolist())) self.assertTrue(all(col in expected_cols for col in df_cv.columns.tolist()))
df_p = diagnostics.performance_metrics(df_cv)
self.assertTrue('coverage' not in df_p.columns)
def test_performance_metrics(self): def test_performance_metrics(self):
m = Prophet() m = Prophet()