Meaningful error message if predict is called before fit (for #462)

This commit is contained in:
Ben Letham 2019-05-02 14:53:57 -07:00
parent c11e668c0d
commit 35d470cbff
2 changed files with 6 additions and 0 deletions

View file

@ -1305,6 +1305,9 @@ fit.prophet <- function(m, df, ...) {
#'
#' @export
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)) {
df <- object$history
} else {

View file

@ -1147,6 +1147,9 @@ class Prophet(object):
-------
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:
df = self.history.copy()
else: