Skip to content

Commit

Permalink
Further disable prophet
Browse files Browse the repository at this point in the history
  • Loading branch information
sjtrny committed Oct 5, 2023
1 parent d5492fa commit 6949521
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion dash/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ numpy==1.22.4
openpyxl==3.0.10
pandas==1.4.2
plotly==5.8.0
prophet==1.1
#prophet==1.1
python-dateutil==2.8.2
python-slugify==6.1.2
pytz==2022.1
Expand Down
84 changes: 42 additions & 42 deletions updater/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import torch

from prophet import Prophet
# from prophet import Prophet

import warnings

Expand Down Expand Up @@ -681,47 +681,47 @@ class RComb(RDirectForecastModel):
r_forecast_model_name = "comb"


# prophet model
class FBProphet(ForecastModel):
name = "facebook-prophet"

method = "facebook-prophet"

def fit(self, y):
# rename two column as `date` and `y` per prophet requirement
self.y = y.reset_index().rename(columns={"date": "ds", "value": "y"})

self.model = Prophet().fit(self.y)

def _make_future(self):
"""make future dataframe for prediction"""
return self.model.make_future_dataframe(periods=self.h).tail(self.h)

def predict(self):
# make future prediction dataframe
future = self._make_future()
return self.model.predict(future)["yhat"].to_numpy()

def predict_withci(self):
future = self._make_future()
forecast_dict = {"forecast": self.predict()}

for i in range(len(self.level)):
self.model.interval_width = self.level[i] * 0.01
forecast_df = self.model.predict(future)

# add intervals
forecast_dict[f"LB_{self.level[i]}"] = forecast_df[
"yhat_lower"
].to_numpy()
forecast_dict[f"UB_{self.level[i]}"] = forecast_df[
"yhat_upper"
].to_numpy()

return forecast_dict

def description(self):
return self.model
# # prophet model
# class FBProphet(ForecastModel):
# name = "facebook-prophet"
#
# method = "facebook-prophet"
#
# def fit(self, y):
# # rename two column as `date` and `y` per prophet requirement
# self.y = y.reset_index().rename(columns={"date": "ds", "value": "y"})
#
# self.model = Prophet().fit(self.y)
#
# def _make_future(self):
# """make future dataframe for prediction"""
# return self.model.make_future_dataframe(periods=self.h).tail(self.h)
#
# def predict(self):
# # make future prediction dataframe
# future = self._make_future()
# return self.model.predict(future)["yhat"].to_numpy()
#
# def predict_withci(self):
# future = self._make_future()
# forecast_dict = {"forecast": self.predict()}
#
# for i in range(len(self.level)):
# self.model.interval_width = self.level[i] * 0.01
# forecast_df = self.model.predict(future)
#
# # add intervals
# forecast_dict[f"LB_{self.level[i]}"] = forecast_df[
# "yhat_lower"
# ].to_numpy()
# forecast_dict[f"UB_{self.level[i]}"] = forecast_df[
# "yhat_upper"
# ].to_numpy()
#
# return forecast_dict
#
# def description(self):
# return self.model


class RCES(RSmoothForecastModel):
Expand Down
2 changes: 1 addition & 1 deletion updater/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ packaging==21.3
pandas==1.4.2
patsy==0.5.2
plotly==5.8.0
prophet==1.1
#prophet==1.1
pycparser==2.21
pyparsing==3.0.9
python-dateutil==2.8.2
Expand Down

0 comments on commit 6949521

Please sign in to comment.