Check for Inf values in history; roxygen version bump.

This commit is contained in:
bl 2017-07-04 01:12:22 -07:00
parent efe8299c0a
commit 1339aada96
34 changed files with 6 additions and 32 deletions

View file

@ -31,5 +31,5 @@ Suggests:
readr readr
License: BSD_3_clause + file LICENSE License: BSD_3_clause + file LICENSE
LazyData: true LazyData: true
RoxygenNote: 5.0.1 RoxygenNote: 6.0.1
VignetteBuilder: knitr VignetteBuilder: knitr

View file

@ -514,6 +514,9 @@ fit.prophet <- function(m, df, ...) {
} }
history <- df %>% history <- df %>%
dplyr::filter(!is.na(y)) dplyr::filter(!is.na(y))
if (any(is.infinite(history$y))) {
stop("Found infinity in column y.")
}
m$history.dates <- sort(zoo::as.Date(df$ds)) m$history.dates <- sort(zoo::as.Date(df$ds))
out <- setup_dataframe(m, history, initialize_scales = TRUE) out <- setup_dataframe(m, history, initialize_scales = TRUE)

View file

@ -16,4 +16,3 @@ Stan model.
\description{ \description{
Compile Stan model Compile Stan model
} }

View file

@ -14,4 +14,3 @@ df_for_plotting(m, fcst)
\description{ \description{
Merge history and forecast for plotting. Merge history and forecast for plotting.
} }

View file

@ -24,4 +24,3 @@ with the following elements:
sigma_obs (M array): Noise level. sigma_obs (M array): Noise level.
Note that M=1 if MAP estimation. Note that M=1 if MAP estimation.
} }

View file

@ -19,4 +19,3 @@ Matrix with seasonality features.
\description{ \description{
Provides Fourier series components with the specified frequency and order. Provides Fourier series components with the specified frequency and order.
} }

View file

@ -15,4 +15,3 @@ array of indexes.
\description{ \description{
Gets changepoint matrix for history dataframe. Gets changepoint matrix for history dataframe.
} }

View file

@ -16,4 +16,3 @@ Stan model.
\description{ \description{
Load compiled Stan model Load compiled Stan model
} }

View file

@ -19,4 +19,3 @@ Provides a strong initialization for linear growth by calculating the
growth and offset parameters that pass the function through the first and growth and offset parameters that pass the function through the first and
last points in the time series. last points in the time series.
} }

View file

@ -19,4 +19,3 @@ Provides a strong initialization for logistic growth by calculating the
growth and offset parameters that pass the function through the first and growth and offset parameters that pass the function through the first and
last points in the time series. last points in the time series.
} }

View file

@ -17,4 +17,3 @@ Dataframe with seasonality.
\description{ \description{
Dataframe with seasonality features. Dataframe with seasonality features.
} }

View file

@ -23,4 +23,3 @@ Dataframe that extends forward from the end of m$history for the
\description{ \description{
Make dataframe with future dates for forecasting. Make dataframe with future dates for forecasting.
} }

View file

@ -17,4 +17,3 @@ A dataframe with a column for each holiday.
\description{ \description{
Construct a matrix of holiday features. Construct a matrix of holiday features.
} }

View file

@ -21,4 +21,3 @@ Dataframe with seasonality.
\description{ \description{
Data frame with seasonality features. Data frame with seasonality features.
} }

View file

@ -23,4 +23,3 @@ Vector y(t).
\description{ \description{
Evaluate the piecewise linear function. Evaluate the piecewise linear function.
} }

View file

@ -25,4 +25,3 @@ Vector y(t).
\description{ \description{
Evaluate the piecewise logistic function. Evaluate the piecewise logistic function.
} }

View file

@ -41,4 +41,3 @@ plot(m, forecast)
} }
} }

View file

@ -19,4 +19,3 @@ A ggplot2 plot.
\description{ \description{
Plot the holidays component of the forecast. Plot the holidays component of the forecast.
} }

View file

@ -20,4 +20,3 @@ A ggplot2 plot.
\description{ \description{
Plot the prophet trend. Plot the prophet trend.
} }

View file

@ -21,4 +21,3 @@ A ggplot2 plot.
\description{ \description{
Plot the weekly component of the forecast. Plot the weekly component of the forecast.
} }

View file

@ -21,4 +21,3 @@ A ggplot2 plot.
\description{ \description{
Plot the yearly component of the forecast. Plot the yearly component of the forecast.
} }

View file

@ -32,4 +32,3 @@ plot(m, forecast)
} }
} }

View file

@ -17,4 +17,3 @@ Dataframe with seasonal components.
\description{ \description{
Predict seasonality broken down into components. Predict seasonality broken down into components.
} }

View file

@ -17,4 +17,3 @@ Vector with trend on prediction dates.
\description{ \description{
Predict trend using the prophet model. Predict trend using the prophet model.
} }

View file

@ -17,4 +17,3 @@ Dataframe with uncertainty intervals.
\description{ \description{
Prophet uncertainty intervals. Prophet uncertainty intervals.
} }

View file

@ -79,4 +79,3 @@ m <- prophet(history)
} }
} }

View file

@ -36,4 +36,3 @@ Plot the components of a prophet forecast.
Prints a ggplot2 with panels for trend, weekly and yearly seasonalities if Prints a ggplot2 with panels for trend, weekly and yearly seasonalities if
present, and holidays if present. present, and holidays if present.
} }

View file

@ -21,4 +21,3 @@ List of trend, seasonality, and yhat, each a vector like df$t.
\description{ \description{
Simulate observations from the extrapolated generative model. Simulate observations from the extrapolated generative model.
} }

View file

@ -19,4 +19,3 @@ Vector of simulated trend over df$t.
\description{ \description{
Simulate the trend using the extrapolated generative model. Simulate the trend using the extrapolated generative model.
} }

View file

@ -17,4 +17,3 @@ Turns on yearly seasonality if there is >=2 years of history.
Turns on weekly seasonality if there is >=2 weeks of history, and the Turns on weekly seasonality if there is >=2 weeks of history, and the
spacing between dates in the history is <7 days. spacing between dates in the history is <7 days.
} }

View file

@ -20,4 +20,3 @@ Sets m$changepoints to the dates of changepoints. Either:
2) We are generating a grid of them. 2) We are generating a grid of them.
3) The user prefers no changepoints be used. 3) The user prefers no changepoints be used.
} }

View file

@ -21,4 +21,3 @@ Adds a time index and scales y. Creates auxillary columns 't', 't_ix',
'y_scaled', and 'cap_scaled'. These columns are used during both fitting 'y_scaled', and 'cap_scaled'. These columns are used during both fitting
and predicting. and predicting.
} }

View file

@ -12,4 +12,3 @@ validate_inputs(m)
\description{ \description{
Validates the inputs to Prophet. Validates the inputs to Prophet.
} }

View file

@ -490,6 +490,8 @@ class Prophet(object):
raise Exception('Prophet object can only be fit once. ' raise Exception('Prophet object can only be fit once. '
'Instantiate a new object.') 'Instantiate a new object.')
history = df[df['y'].notnull()].copy() history = df[df['y'].notnull()].copy()
if np.isinf(history['y'].values).any():
raise ValueError('Found infinity in column y.')
self.history_dates = pd.to_datetime(df['ds']).sort_values() self.history_dates = pd.to_datetime(df['ds']).sort_values()
history = self.setup_dataframe(history, initialize_scales=True) history = self.setup_dataframe(history, initialize_scales=True)