in python/prophet/forecaster.py [0:0]
def validate_inputs(self):
"""Validates the inputs to Prophet."""
if self.growth not in ('linear', 'logistic', 'flat'):
raise ValueError(
'Parameter "growth" should be "linear", "logistic" or "flat".')
if ((self.changepoint_range < 0) or (self.changepoint_range > 1)):
raise ValueError('Parameter "changepoint_range" must be in [0, 1]')
if self.holidays is not None:
if not (
isinstance(self.holidays, pd.DataFrame)
and 'ds' in self.holidays # noqa W503
and 'holiday' in self.holidays # noqa W503
):
raise ValueError('holidays must be a DataFrame with "ds" and '
'"holiday" columns.')
self.holidays['ds'] = pd.to_datetime(self.holidays['ds'])
if (
self.holidays['ds'].isnull().any()
or self.holidays['holiday'].isnull().any()
):
raise ValueError('Found a NaN in holidays dataframe.')
has_lower = 'lower_window' in self.holidays
has_upper = 'upper_window' in self.holidays
if has_lower + has_upper == 1:
raise ValueError('Holidays must have both lower_window and ' +
'upper_window, or neither')
if has_lower:
if self.holidays['lower_window'].max() > 0:
raise ValueError('Holiday lower_window should be <= 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)
if self.seasonality_mode not in ['additive', 'multiplicative']:
raise ValueError(
'seasonality_mode must be "additive" or "multiplicative"'
)