forked from abouslima/DPS-Challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinference.py
More file actions
22 lines (16 loc) · 786 Bytes
/
inference.py
File metadata and controls
22 lines (16 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import numpy as np
from statsmodels.tsa.statespace.sarimax import SARIMAXResults
class DPSModel():
def __init__(self):
self.Alkohol_model = SARIMAXResults.load('./models/Alkoholunfälle_model.pkl')
self.Flucht_model = SARIMAXResults.load('./models/Fluchtunfälle_model.pkl')
self.Verkehrs_model = SARIMAXResults.load('./models/Verkehrsunfälle_model.pkl')
def run(self, n_steps):
models = [self.Alkohol_model, self.Flucht_model, self.Verkehrs_model]
output_value = []
for model in models:
forecast = model.get_forecast(steps=n_steps)
mean_forecast = forecast.predicted_mean
output_value.append(mean_forecast[-1])
final_value = np.sum(output_value)
return int(final_value)