mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-09-16 22:20:23 +00:00
Meaningful error message if predict is called before fit (for #462)
This commit is contained in:
parent
c11e668c0d
commit
35d470cbff
2 changed files with 6 additions and 0 deletions
|
|
@ -1305,6 +1305,9 @@ fit.prophet <- function(m, df, ...) {
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
predict.prophet <- function(object, df = NULL, ...) {
|
predict.prophet <- function(object, df = NULL, ...) {
|
||||||
|
if (is.null(object$history)) {
|
||||||
|
stop("Model must be fit before predictions can be made.")
|
||||||
|
}
|
||||||
if (is.null(df)) {
|
if (is.null(df)) {
|
||||||
df <- object$history
|
df <- object$history
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1147,6 +1147,9 @@ class Prophet(object):
|
||||||
-------
|
-------
|
||||||
A pd.DataFrame with the forecast components.
|
A pd.DataFrame with the forecast components.
|
||||||
"""
|
"""
|
||||||
|
if self.history is None:
|
||||||
|
raise Exception('Model must be fit before predictions can be made.')
|
||||||
|
|
||||||
if df is None:
|
if df is None:
|
||||||
df = self.history.copy()
|
df = self.history.copy()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue