mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-11-16 08:38:30 +00:00
implemented disabling calculation of uncertainties if uncertainty_samples is 0
This commit is contained in:
parent
480b67b8fe
commit
0679e69dba
1 changed files with 16 additions and 10 deletions
|
|
@ -75,7 +75,8 @@ class Prophet(object):
|
||||||
model. If mcmc.samples>0, this will be integrated over all model
|
model. If mcmc.samples>0, this will be integrated over all model
|
||||||
parameters, which will include uncertainty in seasonality.
|
parameters, which will include uncertainty in seasonality.
|
||||||
uncertainty_samples: Number of simulated draws used to estimate
|
uncertainty_samples: Number of simulated draws used to estimate
|
||||||
uncertainty intervals.
|
uncertainty intervals. Settings this value to 0 or False will disable
|
||||||
|
uncertainty estimation and speed up the calculation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
@ -1173,7 +1174,10 @@ class Prophet(object):
|
||||||
|
|
||||||
df['trend'] = self.predict_trend(df)
|
df['trend'] = self.predict_trend(df)
|
||||||
seasonal_components = self.predict_seasonal_components(df)
|
seasonal_components = self.predict_seasonal_components(df)
|
||||||
intervals = self.predict_uncertainty(df)
|
if self.uncertainty_samples:
|
||||||
|
intervals = self.predict_uncertainty(df)
|
||||||
|
else:
|
||||||
|
intervals = None
|
||||||
|
|
||||||
# Drop columns except ds, cap, floor, and trend
|
# Drop columns except ds, cap, floor, and trend
|
||||||
cols = ['ds', 'trend']
|
cols = ['ds', 'trend']
|
||||||
|
|
@ -1289,8 +1293,9 @@ class Prophet(object):
|
||||||
seasonal_features, _, component_cols, _ = (
|
seasonal_features, _, component_cols, _ = (
|
||||||
self.make_all_seasonality_features(df)
|
self.make_all_seasonality_features(df)
|
||||||
)
|
)
|
||||||
lower_p = 100 * (1.0 - self.interval_width) / 2
|
if self.uncertainty_samples:
|
||||||
upper_p = 100 * (1.0 + self.interval_width) / 2
|
lower_p = 100 * (1.0 - self.interval_width) / 2
|
||||||
|
upper_p = 100 * (1.0 + self.interval_width) / 2
|
||||||
|
|
||||||
X = seasonal_features.values
|
X = seasonal_features.values
|
||||||
data = {}
|
data = {}
|
||||||
|
|
@ -1301,12 +1306,13 @@ class Prophet(object):
|
||||||
if component in self.component_modes['additive']:
|
if component in self.component_modes['additive']:
|
||||||
comp *= self.y_scale
|
comp *= self.y_scale
|
||||||
data[component] = np.nanmean(comp, axis=1)
|
data[component] = np.nanmean(comp, axis=1)
|
||||||
data[component + '_lower'] = np.nanpercentile(
|
if self.uncertainty_samples:
|
||||||
comp, lower_p, axis=1,
|
data[component + '_lower'] = np.nanpercentile(
|
||||||
)
|
comp, lower_p, axis=1,
|
||||||
data[component + '_upper'] = np.nanpercentile(
|
)
|
||||||
comp, upper_p, axis=1,
|
data[component + '_upper'] = np.nanpercentile(
|
||||||
)
|
comp, upper_p, axis=1,
|
||||||
|
)
|
||||||
return pd.DataFrame(data)
|
return pd.DataFrame(data)
|
||||||
|
|
||||||
def sample_posterior_predictive(self, df):
|
def sample_posterior_predictive(self, df):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue