Download app/services/predictive.py from rastof9/fb: direct link, hf CLI and curl.
- Browser
- Download file 603 Bytes
-
https://huggingface.co/spaces/rastof9/fb/resolve/main/app/services/predictive.py
- Command line
-
hf download hf://spaces/rastof9/fb/app/services/predictive.py
-
curl -L -o predictive.py https://huggingface.co/spaces/rastof9/fb/resolve/main/app/services/predictive.py
603 Bytes
| from prophet import Prophet | |
| import numpy as np | |
| from sklearn.linear_model import LinearRegression | |
| class AdPredictor: | |
| def forecast_performance(self, historical_data): | |
| model = Prophet() | |
| model.fit(historical_data) | |
| future = model.make_future_dataframe(periods=30) | |
| return model.predict(future) | |
| def simulate_budget(self, current_spend, current_performance, proposed_spend): | |
| X = np.array([current_spend]).reshape(-1, 1) | |
| y = np.array([current_performance]) | |
| model = LinearRegression().fit(X, y) | |
| return model.predict([[proposed_spend]]) |