浏览代码

Merge in some minor fixes from master

Ben Letham 7 年之前
父节点
当前提交
0c30f6efcf
共有 3 个文件被更改,包括 14 次插入4 次删除
  1. 5 1
      R/R/prophet.R
  2. 1 1
      README.md
  3. 8 2
      python/fbprophet/forecaster.py

+ 5 - 1
R/R/prophet.R

@@ -321,7 +321,8 @@ setup_dataframe <- function(m, df, initialize_scales = FALSE) {
   df$ds <- set_date(df$ds)
   if (anyNA(df$ds)) {
     stop(paste('Unable to parse date format in column ds. Convert to date ',
-               'format. Either %Y-%m-%d or %Y-%m-%d %H:%M:%S'))
+               'format (%Y-%m-%d or %Y-%m-%d %H:%M:%S) and check that there',
+               'are no NAs.'))
   }
   for (name in names(m$extra_regressors)) {
     if (!(name %in% colnames(df))) {
@@ -1361,6 +1362,9 @@ make_future_dataframe <- function(m, periods, freq = 'day',
   if (freq == 'm') {
     freq <- 'month'
   }
+  if (is.null(m$history.dates)) {
+    stop('Model must be fit before this can be used.')
+  }
   dates <- seq(max(m$history.dates), length.out = periods + 1, by = freq)
   dates <- dates[2:(periods + 1)]  # Drop the first, which is max(history$ds)
   if (include_history) {

+ 1 - 1
README.md

@@ -54,7 +54,7 @@ On Windows, PyStan requires a compiler so you'll need to [follow the instruction
 
 ### Linux
 
-Make sure compilers (gcc, g++) and Python development tools (python-dev) are installed. If you are using a VM, be aware that you will need at least 4GB of memory to install fbprophet, and at least 2GB of memory to use fbprophet.
+Make sure compilers (gcc, g++, build-essential) and Python development tools (python-dev, python3-dev) are installed. If you are using a VM, be aware that you will need at least 4GB of memory to install fbprophet, and at least 2GB of memory to use fbprophet.
 
 ### Anaconda
 

+ 8 - 2
python/fbprophet/forecaster.py

@@ -162,9 +162,9 @@ class Prophet(object):
                 raise ValueError('Holidays must have both lower_window and ' +
                                  'upper_window, or neither')
             if has_lower:
-                if max(self.holidays['lower_window']) > 0:
+                if self.holidays['lower_window'].max() > 0:
                     raise ValueError('Holiday lower_window should be <= 0')
-                if min(self.holidays['upper_window']) < 0:
+                if self.holidays['upper_window'].min() < 0:
                     raise ValueError('Holiday upper_window should be >= 0')
             for h in self.holidays['holiday'].unique():
                 self.validate_column_name(h, check_holidays=False)
@@ -1218,6 +1218,8 @@ class Prophet(object):
         pd.Dataframe that extends forward from the end of self.history for the
         requested number of periods.
         """
+        if self.history_dates is None:
+            raise Exception('Model must be fit before this can be used.')
         last_date = self.history_dates.max()
         dates = pd.date_range(
             start=last_date,
@@ -1307,6 +1309,9 @@ class Prophet(object):
         fig, axes = plt.subplots(npanel, 1, facecolor='w',
                                  figsize=(9, 3 * npanel))
 
+        if npanel == 1:
+            axes = [axes]
+
         for ax, plot in zip(axes, components):
             if plot == 'trend':
                 self.plot_forecast_component(
@@ -1468,6 +1473,7 @@ class Prophet(object):
 
         Parameters
         ----------
+        name: Seasonality name, like 'daily', 'weekly'.
         ax: Optional matplotlib Axes to plot on. One will be created if
             this is not provided.
         uncertainty: Optional boolean to plot uncertainty intervals.