fb / app /services /predictive.py
rastof9's picture
Saving local changes before rebase
d488241
raw
history blame contribute delete
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]])