File size: 603 Bytes
d488241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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]])