Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsdukai committed Feb 18, 2024
1 parent d3e13d6 commit 9b26c1b
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 55 deletions.
4 changes: 2 additions & 2 deletions dashboard/dashboard_server/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def set_neighborhoods_value(available_options):
html.Div([
html.Div(
children=[
html.H5(children="Municipality:"),
html.H5(children="Gemeente"),
dcc.Dropdown(
id="municipalities-dropdown",
options=neighborhoods.index.get_level_values(0).unique(),
Expand All @@ -77,7 +77,7 @@ def set_neighborhoods_value(available_options):
),
html.Div(
children=[
html.H5(children="Neighborhood:"),
html.H5(children="Buurt"),
dcc.Dropdown(
id="neighborhoods-dropdown",
value="Bezuidenhout-Midden",
Expand Down
3 changes: 1 addition & 2 deletions report/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ lang: en

format:
html:
code-fold: true
echo: false
pdf: default
ipynb: default

jupyter: python3

Expand Down
25 changes: 24 additions & 1 deletion report/report_nl.qmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
---
title: "Wijklabels"
author: "Balázs Dukai, Ravi Peters"
author:
- name: "Balázs Dukai"
email: "[email protected]"
affiliation:
- name: "3DGI"
url: "https://3dgi.nl"
- name: "Ravi Peters"
email: "[email protected]"
affiliation:
- name: "3DGI"
url: "https://3dgi.nl"
date: last-modified
bibliography: references.bib
license: "CC BY"
copyright:
holder: "3DGI"
year: "2024"
lang: "nl"
---

```{python}
Expand Down Expand Up @@ -250,6 +265,14 @@ Als we onze validatie beperken tot die woningen waar het juiste label wel bestaa

Voor deze subset van de data, is de gemiddelde labelafwijking in de door ons geschatte labels ten opzichte van de @_EP_2023 labels **-0,6**, met een standaardafwijking van **1,6**. Dit is ongeveer twee keer zo laag als de labelafwijking voor de gehele dataset.

### Buurten

Kies een gemeente en een buurt om de geschatte energielabels te bekijken.

```{=html}
<iframe width="780" height="600" src="https://dev.3dgi.xyz/wijklabels/"></iframe>
```

# Conclusies

Gemiddeld liggen de door ons geschatte labels één label onder het echte label, met een standaardafwijking van twee labels.
Expand Down
2 changes: 1 addition & 1 deletion src/wijklabels/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _plot_dist(grouped, t):
plt.axhline(y=0.0, color='#154273', linestyle='-')
plt.grid(visible=True, which="major", axis="y", zorder=0)
plt.title(f"{aggregate_id_column.title()}: {aggregate_id}\nNr. woningen: {len(b)}", fontsize=10)
plt.suptitle("Afwijking van de geschatt labels van de EP-Online labels", fontsize=14)
plt.suptitle("Afwijking van de geschatte labels van de EP-Online labels", fontsize=14)
plt.tight_layout()
plt.savefig(f"{dir_plots}/{aggregate_level}_{filename}_dist{t}.png")
plt.close()
Expand Down
24 changes: 12 additions & 12 deletions src/wijklabels/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,25 +274,25 @@ def _ep_in_dist(df_dist, row):
# Plot NL
log.info(f"Writing plot of the Netherlands to {p}")
plot_comparison(df_with_truth, p, aggregate_level=AggregateUnit.NL)
log.info(f"Writing plots of municipalities to {p}")
plot_comparison(df_with_truth, p, aggregate_level=AggregateUnit.GEMEENTE)
log.info(f"Writing plots of wijken to {p}")
plot_comparison(df_with_truth, p, aggregate_level=AggregateUnit.WIJK)
log.info(f"Writing plots of neighborhoods to {p}")
plot_comparison(df_with_truth, p, aggregate_level=AggregateUnit.BUURT)
# log.info(f"Writing plots of municipalities to {p}")
# plot_comparison(df_with_truth, p, aggregate_level=AggregateUnit.GEMEENTE)
# log.info(f"Writing plots of wijken to {p}")
# plot_comparison(df_with_truth, p, aggregate_level=AggregateUnit.WIJK)
# log.info(f"Writing plots of neighborhoods to {p}")
# plot_comparison(df_with_truth, p, aggregate_level=AggregateUnit.BUURT)

p = PATH_OUTPUT_DIR.joinpath("plots_possible")
p.mkdir(parents=True, exist_ok=True)

# Plot NL
log.info(f"Writing plot of the Netherlands to {p}")
plot_comparison(possible_labels, p, aggregate_level=AggregateUnit.NL)
log.info(f"Writing plots of municipalities to {p}")
plot_comparison(possible_labels, p, aggregate_level=AggregateUnit.GEMEENTE)
log.info(f"Writing plots of wijken to {p}")
plot_comparison(possible_labels, p, aggregate_level=AggregateUnit.WIJK)
log.info(f"Writing plots of neighborhoods to {p}")
plot_comparison(possible_labels, p, aggregate_level=AggregateUnit.BUURT)
# log.info(f"Writing plots of municipalities to {p}")
# plot_comparison(possible_labels, p, aggregate_level=AggregateUnit.GEMEENTE)
# log.info(f"Writing plots of wijken to {p}")
# plot_comparison(possible_labels, p, aggregate_level=AggregateUnit.WIJK)
# log.info(f"Writing plots of neighborhoods to {p}")
# plot_comparison(possible_labels, p, aggregate_level=AggregateUnit.BUURT)


if __name__ == "__main__":
Expand Down
77 changes: 40 additions & 37 deletions tmp/analyse_ep_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pandas as pd
import psycopg
import matplotlib.pyplot as plt
import numpy as np

from wijklabels.load import EPLoader
from wijklabels.woningtype import Bouwperiode, WoningtypePreNTA8800
Expand All @@ -29,6 +30,14 @@

if __name__ == '__main__':
args = parser.parse_args()
# args = parser.parse_args([
# "/data/energylabel-ep-online/v20231101_v2_csv_subset.csv",
# "-d", "postgres",
# "--host", "localhost",
# "-p", "8001",
# "-u", "postgres",
# "--password", "password"
# ])
bouwperiode = True
woningtype = True
coverage = True
Expand Down Expand Up @@ -95,31 +104,29 @@
periods_sorted_pretty
]



fig = plt.figure(figsize=(9, 7))
plt.barh(
y=bag_df_bouwperiode_dist.index,
width=bag_df_bouwperiode_dist.bouwperiode.values * -100,
x = np.arange(len(bag_df_bouwperiode_dist.index))
plt.bar(
x=x,
height=bag_df_bouwperiode_dist.bouwperiode.values * 100,
label="BAG",
zorder=3
zorder=3,
width=0.25
)
plt.barh(
y=ep_online_bouwperiode_dist.index,
width=ep_online_bouwperiode_dist.bouwperiode.values * 100,
plt.bar(
x=x + 0.25,
height=ep_online_bouwperiode_dist.bouwperiode.values * 100,
label="EP-Online",
zorder=3
zorder=3,
width=0.25
)
plt.legend(loc="best")
plt.grid(which="major", axis="x", zorder=0)
plt.xticks(
ticks=range(-50, 60, 10),
labels=[str(i) for i in range(-50, 60, 10)]
)
plt.xticks(
ticks=range(-55, 60, 10),
minor=True,
)
plt.xlabel("Percentage (%) van het hele dataset")
plt.ylabel("Bouwperiode")
plt.ylabel("Percentage (%) van het hele dataset")
plt.xticks(x+0.125, bag_df_bouwperiode_dist.index)
plt.xlabel("Bouwperiode")
plt.suptitle("Spreiding van woningen per bouwperiode", fontsize=14)
plt.savefig("bouwperiode_dist.png")
plt.close()
Expand All @@ -142,31 +149,27 @@
normalize=True
)

fig = plt.figure(figsize=(12, 7))
plt.barh(
y=bag_df_woningtype_dist.index,
width=bag_df_woningtype_dist.woningtype.values * -100,
fig = plt.figure(figsize=(9, 7))
x = np.arange(len(bag_df_woningtype_dist.index))
plt.bar(
x=x,
height=bag_df_woningtype_dist.woningtype.values * 100,
label="BAG",
zorder=3
zorder=3,
width=0.25
)
plt.barh(
y=ep_online_woningtype_dist.index,
width=ep_online_woningtype_dist.woningtype.values * 100,
plt.bar(
x=x+0.25,
height=ep_online_woningtype_dist.woningtype.values * 100,
label="EP-Online",
zorder=3
zorder=3,
width=0.25
)
plt.legend(loc="best")
plt.grid(which="major", axis="x", zorder=0)
plt.xticks(
ticks=range(-60, 70, 10),
labels=[str(i) for i in range(-60, 70, 10)],
)
plt.xticks(
ticks=range(-65, 70, 5),
minor=True,
)
plt.xlabel("Percentage (%) van het hele dataset")
plt.ylabel("woningtype")
plt.ylabel("Percentage (%) van het hele dataset")
plt.xticks(x + 0.125, bag_df_woningtype_dist.index)
plt.xlabel("woningtype")
plt.suptitle("Spreiding van woningen per woningtype", fontsize=14)
plt.savefig("woningtype_dist.png")
plt.close()
Expand Down

0 comments on commit 9b26c1b

Please sign in to comment.