-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProphetModel.py
More file actions
26 lines (19 loc) · 885 Bytes
/
ProphetModel.py
File metadata and controls
26 lines (19 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pandas as pd
import matplotlib.pyplot as plt
from prophet import Prophet
df = pd.read_csv('SensorMLDataset_small.csv')
for column in df.columns[2:]:
variable_name = column
df_prophet = df[['Timestamp', variable_name]].rename(columns={'Timestamp': 'ds', variable_name: 'y'})
model = Prophet()
model.fit(df_prophet)
future = model.make_future_dataframe(periods=48, freq='H')
forecast = model.predict(future)
forecast['ds'] = pd.to_datetime(forecast['ds'])
# Plot predicted vs. actual values
fig1 = model.plot(forecast, xlabel='Timestamp', ylabel=variable_name, figsize=(10, 4))
fig1.canvas.manager.set_window_title(f'Prediction for {variable_name}')
plt.show()
# fig2 = model.plot_components(forecast, figsize=(10, 4))
# fig2.canvas.manager.set_window_title(f'Prediction Components for {variable_name}')
# plt.show()