mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-09-16 22:20:23 +00:00
Only allow a Prophet object to be fit once
This commit is contained in:
parent
961716ba55
commit
34c0f80684
2 changed files with 6 additions and 0 deletions
|
|
@ -473,6 +473,9 @@ logistic_growth_init <- function(df) {
|
|||
#'
|
||||
#' @export
|
||||
fit.prophet <- function(m, df, ...) {
|
||||
if (!is.null(m$history)) {
|
||||
stop("Prophet object can only be fit once. Instantiate a new object.")
|
||||
}
|
||||
history <- df %>%
|
||||
dplyr::filter(!is.na(y))
|
||||
m$history.dates <- sort(zoo::as.Date(df$ds))
|
||||
|
|
|
|||
|
|
@ -479,6 +479,9 @@ class Prophet(object):
|
|||
-------
|
||||
The fitted Prophet object.
|
||||
"""
|
||||
if self.history is not None:
|
||||
raise Exception('Prophet object can only be fit once. '
|
||||
'Instantiate a new object.')
|
||||
history = df[df['y'].notnull()].copy()
|
||||
self.history_dates = pd.to_datetime(df['ds']).sort_values()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue