Skip to content

Commit 978303c

Browse files
committed
Tuning
1 parent 7626475 commit 978303c

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.venv/
1+
.venv/
2+
*.sqlite3

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Agile Predict v1.0.0
22

3-
This model forecasts Octopus Agile electricity prices up to 14 days in advance using a Machine Learning model trained on data from the Balancing Mechanism Reporting System (BRMS), National Grid Electricity Supply Operator (NG ESO) and weather data from open-meteo.com.
3+
This model forecasts Octopus Agile electricity prices up to 14 days in advance using a Machine Learning model trained
4+
on data from the Balancing Mechanism Reporting System (<a href="https://bmrs.elexon.co.uk/">BRMS</a>), National Grid
5+
Electricity Supply Operator (<a href="https://www.nationalgrideso.com/data-portal">NG ESO</a>) and weather data from
6+
<a href="https://open-meteo.com"> open-meteo.com</a>.<p>
7+
8+
Because the app is hosted on a <a href= "http://fly.io">fly.io</a> hobby account the database is only updated when the page
9+
is accessed and if there has been an hour since the last update. This may sometimes cause slight delays in loading. <p>
410

5-
Because the app is hosted on a fly.io hobby account the database is only updated when the page is accessed and if there has been an hour since the last update. This may sometimes cause slight delays in loading.

db.sqlite3

0 Bytes
Binary file not shown.
697 Bytes
Binary file not shown.

prices/management/commands/update.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from requests.exceptions import HTTPError
88
from urllib import parse
99
from datetime import datetime
10+
from sklearn.metrics import mean_squared_error as MSE
1011

1112
from django.core.management.base import BaseCommand
1213
from ...models import History, PriceHistory, Forecasts, ForecastData
@@ -459,11 +460,21 @@ def handle(self, *args, **options):
459460
X = hist.iloc[-48 * 28 :]
460461
y = prices["day_ahead"].loc[X.index]
461462

462-
print(X)
463-
print(y)
463+
model = xg.XGBRegressor(
464+
objective="reg:squarederror",
465+
booster="dart",
466+
# max_depth=0,
467+
gamma=0.3,
468+
eval_metric="rmse",
469+
)
464470

465-
model = xg.XGBRegressor(objective="reg:squarederror", booster="dart", max_depth=0)
466-
model.fit(X, y)
471+
model.fit(X, y, verbose=True)
472+
model_day_ahead = pd.Series(index=y.index, data=model.predict(X))
473+
474+
model_agile = day_ahead_to_agile(model_day_ahead)
475+
rmse = MSE(model_agile, prices["agile"].loc[X.index]) ** 0.5
476+
477+
print(f"RMS Error: {rmse: 0.2f} p/kWh")
467478

468479
cols = X.columns
469480
fc["day_ahead"] = model.predict(fc[cols])

templates/base.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ <h1><a href="{% url 'graph' %}">Agile Predict v{{APP_VERSION_NUMBER}}</a></h1>
2828
<div style="margin-left: 20px";"margin-right: 20px";>
2929
Because the app is hosted on a <a href= "http://fly.io">fly.io</a> hobby account the database is only updated when the page
3030
is accessed and if there has been an hour since the last update. This may sometimes cause slight delays in loading. <p>
31-
</div>
32-
</body>
31+
</div>
32+
<h2 style="margin-left: 20px";"margin-right: 20px">API Access</h2>
33+
<div style="margin-left: 20px";"margin-right: 20px";>
34+
RESTful API access to the three most recent price forecasts is available via <a href="http://prices.fly.dev/api">prices.fly.dev/api</a>
35+
</div>
36+
<h2 style="margin-left: 20px";"margin-right: 20px">Development</h2>
37+
<div style="margin-left: 20px";"margin-right: 20px";>
38+
Contributions to the project are welcome through <a href="https://github.com/fboundy/agile_predict">GitHub</a>
39+
</div>
40+
</body>
3341
</html>

0 commit comments

Comments
 (0)