Skip to content

Commit

Permalink
Tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
fboundy committed Apr 25, 2024
1 parent 7626475 commit 978303c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.venv/
.venv/
*.sqlite3
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Agile Predict v1.0.0

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.
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 (<a href="https://bmrs.elexon.co.uk/">BRMS</a>), National Grid
Electricity Supply Operator (<a href="https://www.nationalgrideso.com/data-portal">NG ESO</a>) and weather data from
<a href="https://open-meteo.com"> open-meteo.com</a>.<p>

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
is accessed and if there has been an hour since the last update. This may sometimes cause slight delays in loading. <p>

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.
Binary file modified db.sqlite3
Binary file not shown.
Binary file modified prices/management/commands/__pycache__/update.cpython-312.pyc
Binary file not shown.
19 changes: 15 additions & 4 deletions prices/management/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from requests.exceptions import HTTPError
from urllib import parse
from datetime import datetime
from sklearn.metrics import mean_squared_error as MSE

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

print(X)
print(y)
model = xg.XGBRegressor(
objective="reg:squarederror",
booster="dart",
# max_depth=0,
gamma=0.3,
eval_metric="rmse",
)

model = xg.XGBRegressor(objective="reg:squarederror", booster="dart", max_depth=0)
model.fit(X, y)
model.fit(X, y, verbose=True)
model_day_ahead = pd.Series(index=y.index, data=model.predict(X))

model_agile = day_ahead_to_agile(model_day_ahead)
rmse = MSE(model_agile, prices["agile"].loc[X.index]) ** 0.5

print(f"RMS Error: {rmse: 0.2f} p/kWh")

cols = X.columns
fc["day_ahead"] = model.predict(fc[cols])
Expand Down
12 changes: 10 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ <h1><a href="{% url 'graph' %}">Agile Predict v{{APP_VERSION_NUMBER}}</a></h1>
<div style="margin-left: 20px";"margin-right: 20px";>
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
is accessed and if there has been an hour since the last update. This may sometimes cause slight delays in loading. <p>
</div>
</body>
</div>
<h2 style="margin-left: 20px";"margin-right: 20px">API Access</h2>
<div style="margin-left: 20px";"margin-right: 20px";>
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>
</div>
<h2 style="margin-left: 20px";"margin-right: 20px">Development</h2>
<div style="margin-left: 20px";"margin-right: 20px";>
Contributions to the project are welcome through <a href="https://github.com/fboundy/agile_predict">GitHub</a>
</div>
</body>
</html>

0 comments on commit 978303c

Please sign in to comment.