mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-11-18 08:53:42 +00:00
improvements in docstrings and testing for disabling uncertainty
This commit is contained in:
parent
8d0f23f8be
commit
be25372090
4 changed files with 10 additions and 6 deletions
|
|
@ -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))) {
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ prophet_plot_components <- function(
|
||||||
#' @param fcst Dataframe output of `predict`.
|
#' @param fcst Dataframe output of `predict`.
|
||||||
#' @param name String name of the component to plot (column of fcst).
|
#' @param name String name of the component to plot (column of fcst).
|
||||||
#' @param uncertainty Optional boolean to plot uncertainty intervals, which will
|
#' @param uncertainty Optional boolean to plot uncertainty intervals, which will
|
||||||
#' only be done if m$uncertainty.samples > 0.
|
#' only be done if m$uncertainty.samples > 0.
|
||||||
#' @param plot_cap Boolean indicating if the capacity should be shown in the
|
#' @param plot_cap Boolean indicating if the capacity should be shown in the
|
||||||
#' figure, if available.
|
#' figure, if available.
|
||||||
#'
|
#'
|
||||||
|
|
@ -233,7 +233,7 @@ seasonality_plot_df <- function(m, ds) {
|
||||||
#'
|
#'
|
||||||
#' @param m Prophet model object
|
#' @param m Prophet model object
|
||||||
#' @param uncertainty Optional boolean to plot uncertainty intervals, which will
|
#' @param uncertainty Optional boolean to plot uncertainty intervals, which will
|
||||||
#' only be done if m$uncertainty.samples > 0.
|
#' only be done if m$uncertainty.samples > 0.
|
||||||
#' @param weekly_start Integer specifying the start day of the weekly
|
#' @param weekly_start Integer specifying the start day of the weekly
|
||||||
#' seasonality plot. 0 (default) starts the week on Sunday. 1 shifts by 1 day
|
#' seasonality plot. 0 (default) starts the week on Sunday. 1 shifts by 1 day
|
||||||
#' to Monday, and so on.
|
#' to Monday, and so on.
|
||||||
|
|
@ -276,7 +276,7 @@ plot_weekly <- function(m, uncertainty = TRUE, weekly_start = 0,
|
||||||
#'
|
#'
|
||||||
#' @param m Prophet model object.
|
#' @param m Prophet model object.
|
||||||
#' @param uncertainty Optional boolean to plot uncertainty intervals, which
|
#' @param uncertainty Optional boolean to plot uncertainty intervals, which
|
||||||
#' will only be done if m$uncertainty.samples > 0.
|
#' will only be done if m$uncertainty.samples > 0.
|
||||||
#' @param yearly_start Integer specifying the start day of the yearly
|
#' @param yearly_start Integer specifying the start day of the yearly
|
||||||
#' seasonality plot. 0 (default) starts the year on Jan 1. 1 shifts by 1 day
|
#' seasonality plot. 0 (default) starts the year on Jan 1. 1 shifts by 1 day
|
||||||
#' to Jan 2, and so on.
|
#' to Jan 2, and so on.
|
||||||
|
|
@ -321,7 +321,7 @@ plot_yearly <- function(m, uncertainty = TRUE, yearly_start = 0,
|
||||||
#' @param m Prophet model object.
|
#' @param m Prophet model object.
|
||||||
#' @param name String name of the seasonality.
|
#' @param name String name of the seasonality.
|
||||||
#' @param uncertainty Optional boolean to plot uncertainty intervals, which
|
#' @param uncertainty Optional boolean to plot uncertainty intervals, which
|
||||||
#' will only be done if m$uncertainty.samples > 0.
|
#' will only be done if m$uncertainty.samples > 0.
|
||||||
#'
|
#'
|
||||||
#' @return A ggplot2 plot.
|
#' @return A ggplot2 plot.
|
||||||
#'
|
#'
|
||||||
|
|
|
||||||
|
|
@ -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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue