quarree100 / qScope_frontend

Code for the projection of Q-Scope/CityScope@QUARREE100
0 stars 0 forks source link

Kategorisieren der Gebäude #37

Closed dunland closed 2 years ago

dunland commented 2 years ago

Um die Gebäudedaten durch einen Proxy zu schützen, können wir die ausgewählten Gebäude mit ähnlichen (also ähnliche Verbrauchsdaten!) verbinden, diese Gruppe dann mitteln und ein generisches Durchschnittsgebäude erzeugen. Das klappt so weit ganz gut.

Ich habe für jedes Gebäude einmal alle anderen ermittelt, deren Wärmeverbrauch und Stromverbrauch innerhalb der Standardabweichung des gesamten Datensatzes sind.

Dabei ist folgendes heraus gekommen:

Gesamtanzahl Gebäude: 164 Clustergrößen im Mittel: 14.35 Clustergrößen, Standardabweichung: 11.11 kleinstes Cluster: 0 25% 4 50% 12 75% 23 max 36

Ein Problem haben wir mit sehr kleinen Clustern, da sich deren Daten nicht durch ihre "Peergroup" verschleiern lassen. Da müsste ich nochmal schauen, woran das eigentlich liegt. (ggf. haben diese Gebäude keinen hinterlegten Energieverbrauch o.ä.) Eine Kategorisierung nach Energieverbrauch könnte auch abhilfe schaffen...

building 6.07 is linked to 4 other buildings with similar specs
building 3.05 is linked to 4 other buildings with similar specs
building 7.05 is linked to 32 other buildings with similar specs
building 4.08 is linked to 22 other buildings with similar specs
building 3.12 is linked to 34 other buildings with similar specs
building 6.06 is linked to 2 other buildings with similar specs
building 6.01 is linked to 32 other buildings with similar specs
building 3.10 is linked to 5 other buildings with similar specs
building 4.31 is linked to 4 other buildings with similar specs
building 4.19 is linked to 31 other buildings with similar specs
building 2.16 is linked to 30 other buildings with similar specs
building 2.06 is linked to 21 other buildings with similar specs
building 4.01 is linked to 6 other buildings with similar specs
building 2.08 is linked to 9 other buildings with similar specs
building 4.12 is linked to 18 other buildings with similar specs
building 6.08 is linked to 21 other buildings with similar specs
building 2.04 is linked to 32 other buildings with similar specs
building 4.24 is linked to 36 other buildings with similar specs
building 2.14 is linked to 17 other buildings with similar specs
building 2.02 is linked to 32 other buildings with similar specs
building 2.20 is linked to 35 other buildings with similar specs
building 2.10 is linked to 21 other buildings with similar specs
building 2.12 is linked to 5 other buildings with similar specs
building 3.09 is linked to 7 other buildings with similar specs
building 6.02 is linked to 27 other buildings with similar specs
building 6.04b is linked to 0 other buildings with similar specs
building 6.04 is linked to 30 other buildings with similar specs
building 4.14 is linked to 4 other buildings with similar specs
building 2.18 is linked to 34 other buildings with similar specs
building 3.07 is linked to 14 other buildings with similar specs
building 7.03 is linked to 1 other buildings with similar specs
building 5.14b is linked to 0 other buildings with similar specs
building 5.04 is linked to 3 other buildings with similar specs
building 5.02b is linked to 0 other buildings with similar specs
building 5.08 is linked to 22 other buildings with similar specs
building 5.02 is linked to 6 other buildings with similar specs
building 5.01 is linked to 4 other buildings with similar specs
building 5.14 is linked to 1 other buildings with similar specs
building 5.03b is linked to 0 other buildings with similar specs
building 5.10 is linked to 15 other buildings with similar specs
building 5.16b is linked to 0 other buildings with similar specs
building 5.10b is linked to 0 other buildings with similar specs
building 5.12 is linked to 13 other buildings with similar specs
building 5.15 is linked to 25 other buildings with similar specs
building 5.15b is linked to 0 other buildings with similar specs
building 5.09 is linked to 1 other buildings with similar specs
building 5.05 is linked to 23 other buildings with similar specs
building 5.13 is linked to 1 other buildings with similar specs
building 5.07 is linked to 1 other buildings with similar specs
building 5.11 is linked to 29 other buildings with similar specs
building 5.03 is linked to 17 other buildings with similar specs
building 5.16 is linked to 36 other buildings with similar specs
building 5.17 is linked to 1 other buildings with similar specs
building 5.06 is linked to 26 other buildings with similar specs
building 1.08 is linked to 22 other buildings with similar specs
building 1.05 is linked to 4 other buildings with similar specs
building 7.46 is linked to 5 other buildings with similar specs
building 7.16 is linked to 25 other buildings with similar specs
building 6.10 is linked to 16 other buildings with similar specs
building 7.08 is linked to 7 other buildings with similar specs
building 7.49 is linked to 10 other buildings with similar specs
building 1.10 is linked to 4 other buildings with similar specs
building 1.04 is linked to 4 other buildings with similar specs
building 7.11 is linked to 32 other buildings with similar specs
building 7.64 is linked to 4 other buildings with similar specs
building 3.04 is linked to 3 other buildings with similar specs
building 7.17 is linked to 4 other buildings with similar specs
building 7.18 is linked to 11 other buildings with similar specs
building 1.01b is linked to 0 other buildings with similar specs
building 1.11 is linked to 12 other buildings with similar specs
building 7.47 is linked to 5 other buildings with similar specs
building 1.13 is linked to 8 other buildings with similar specs
building 7.22 is linked to 2 other buildings with similar specs
building 1.07 is linked to 12 other buildings with similar specs
building 7.39 is linked to 10 other buildings with similar specs
building 7.63 is linked to 28 other buildings with similar specs
building 7.35 is linked to 22 other buildings with similar specs
building 7.27 is linked to 8 other buildings with similar specs
building 6.09 is linked to 30 other buildings with similar specs
building 7.10 is linked to 22 other buildings with similar specs
building 7.32 is linked to 22 other buildings with similar specs
building 4.23 is linked to 1 other buildings with similar specs
building 7.48 is linked to 25 other buildings with similar specs
building 3.03 is linked to 1 other buildings with similar specs
building 1.12 is linked to 23 other buildings with similar specs
building 7.40 is linked to 18 other buildings with similar specs
building 1.01 is linked to 12 other buildings with similar specs
building 7.65 is linked to 10 other buildings with similar specs
building 7.34 is linked to 10 other buildings with similar specs
building 7.31 is linked to 22 other buildings with similar specs
building 1.09 is linked to 32 other buildings with similar specs
building 7.20 is linked to 1 other buildings with similar specs
building 7.13 is linked to 3 other buildings with similar specs
building 7.38 is linked to 5 other buildings with similar specs
building 7.28 is linked to 30 other buildings with similar specs
building 1.06 is linked to 2 other buildings with similar specs
building 7.15 is linked to 12 other buildings with similar specs
building 7.09 is linked to 5 other buildings with similar specs
building 7.24 is linked to 13 other buildings with similar specs
building 7.12 is linked to 13 other buildings with similar specs
building 7.45 is linked to 28 other buildings with similar specs
building 7.36 is linked to 7 other buildings with similar specs
building 7.07 is linked to 9 other buildings with similar specs
building 7.23 is linked to 4 other buildings with similar specs
building 7.41 is linked to 25 other buildings with similar specs
building 7.44 is linked to 3 other buildings with similar specs
building 3.01 is linked to 4 other buildings with similar specs
building 7.14 is linked to 2 other buildings with similar specs
building 7.21 is linked to 25 other buildings with similar specs
building 7.33 is linked to 32 other buildings with similar specs
building 7.29 is linked to 11 other buildings with similar specs
building 7.30 is linked to 22 other buildings with similar specs
building 7.25 is linked to 0 other buildings with similar specs
building 7.06 is linked to 9 other buildings with similar specs
building 7.43 is linked to 8 other buildings with similar specs
building 7.26 is linked to 6 other buildings with similar specs
building 1.03 is linked to 31 other buildings with similar specs
building 7.50 is linked to 10 other buildings with similar specs
building 7.54 is linked to 32 other buildings with similar specs
building 7.59 is linked to 15 other buildings with similar specs
building 7.56 is linked to 34 other buildings with similar specs
building 7.58 is linked to 8 other buildings with similar specs
building 7.57 is linked to 24 other buildings with similar specs
building 7.55 is linked to 29 other buildings with similar specs
building 7.53 is linked to 28 other buildings with similar specs
building 7.52 is linked to 11 other buildings with similar specs
building 6.03 is linked to 29 other buildings with similar specs
building 1.02 is linked to 18 other buildings with similar specs
building 7.05b is linked to 0 other buildings with similar specs
building 3.08 is linked to 7 other buildings with similar specs
building 3.06 is linked to 28 other buildings with similar specs
building 2.01 is linked to 20 other buildings with similar specs
building 2.15 is linked to 8 other buildings with similar specs
building 2.07 is linked to 2 other buildings with similar specs
building 2.17 is linked to 17 other buildings with similar specs
building 2.09 is linked to 3 other buildings with similar specs
building 2.19 is linked to 30 other buildings with similar specs
building 2.11 is linked to 1 other buildings with similar specs
building 2.21 is linked to 19 other buildings with similar specs
building 2.03 is linked to 5 other buildings with similar specs
building 2.13 is linked to 22 other buildings with similar specs
building 2.05 is linked to 21 other buildings with similar specs
building 4.17 is linked to 24 other buildings with similar specs
building 4.06 is linked to 3 other buildings with similar specs
building 4.18 is linked to 31 other buildings with similar specs
building 4.07 is linked to 4 other buildings with similar specs
building 4.20 is linked to 18 other buildings with similar specs
building 4.09 is linked to 12 other buildings with similar specs
building 4.21 is linked to 30 other buildings with similar specs
building 4.10 is linked to 16 other buildings with similar specs
building 4.13 is linked to 24 other buildings with similar specs
building 4.22 is linked to 21 other buildings with similar specs
building 4.11 is linked to 2 other buildings with similar specs
building 4.25 is linked to 22 other buildings with similar specs
building 4.26 is linked to 12 other buildings with similar specs
building 4.27 is linked to 20 other buildings with similar specs
building 4.28 is linked to 14 other buildings with similar specs
building 4.29 is linked to 5 other buildings with similar specs
building 4.30 is linked to 22 other buildings with similar specs
building 4.03 is linked to 1 other buildings with similar specs
building 4.15 is linked to 29 other buildings with similar specs
building 4.16 is linked to 21 other buildings with similar specs
building 4.05 is linked to 2 other buildings with similar specs
building 7.37 is linked to 10 other buildings with similar specs
lwinkeler commented 2 years ago

Aus unserem Gespräch mit David Sauss können wir zumindest auch nochmal die Nachricht mitbringen, dass unser Ansatz sehr gut ist und es ausreicht, wenn wir eine kleine Verschleierung mit ähnlichen Gebäuden vornehmen. Solange wir nicht die exakten Daten aus der Liste nehmen, ist alles gut.

Aus dem Grund würde ich übrigens auch keine extra Kategorisierung vornehmen, da es uns meines Verständnisses nach,

  1. wieder weiter vom Bezug der Teilnehmer:innen zum ausgewählten Gebäude bringt und außerdem
  2. auch wenn sie nur minimal ist, eine Art Wertung mit rein bringt, da zu sehen ist, welche Gebäude besonders gut/schlecht abschneiden.

Die sehr kleinen Cluster sind natürlich tatsächlich problematisch. Dazu zwei Punkte:

dunland commented 2 years ago

buildings are clustered as follows:

def make_clusters(group_selection):
    '''make groups of the selected buildings. group by standard deviation of energy consumption'''
    cluster_list = []
    for idx in range(len(group_selection.index)):
        interval = 0.5  # standard deviation
        cluster = pandas.DataFrame()
        while len(cluster) < 2:  # make sure no building is alone
            cluster = session.buildings_df.loc[(
                    (session.buildings_df['energy_source'] == session.buildings_df.loc[
                        session.buildings_df.index[idx], 'energy_source'])
                    &
                    (session.buildings_df['spec_heat_consumption'] >= session.buildings_df.loc[session.buildings_df.index[idx],
                    'spec_heat_consumption'] - session.buildings_df['spec_heat_consumption'].std() * interval)
                    &
                    (session.buildings_df['spec_heat_consumption'] <= session.buildings_df.loc[session.buildings_df.index[idx],
                    'spec_heat_consumption'] + session.buildings_df['spec_heat_consumption'].std() * interval)
                    &
                    (session.buildings_df['spec_power_consumption'] >= session.buildings_df.loc[session.buildings_df.index[idx],
                    'spec_power_consumption'] - session.buildings_df['spec_power_consumption'].std() * interval)
                    &
                    (session.buildings_df['spec_power_consumption'] <= session.buildings_df.loc[session.buildings_df.index[idx],
                    'spec_power_consumption'] + session.buildings_df['spec_power_consumption'].std() * interval)
                )]
            interval += 0.1  # increase range, try again if necessary

        cluster_list.append(cluster)
        session.print_verbose(
            "building {0} is in a group of to {1} buildings with similar specs:".format(group_selection.index[idx], len(cluster)))
        # session.print_verbose(cluster[['spec_heat_consumption', 'spec_power_consumption']].describe())

    return cluster_list

buildings_cluster = api.make_clusters(buildings_df)
# update building with average data:
for j in range(len(buildings_df)):
    buildings_df.at[buildings_df.index[j], 'avg_spec_heat_consumption'] = buildings_cluster[j]['spec_heat_consumption'].mean()
    buildings_df.at[buildings_df.index[j], 'avg_spec_power_consumption'] = buildings_cluster[j]['spec_power_consumption'].mean()
    buildings_df.at[buildings_df.index[j], 'cluster_size'] = int(len(buildings_cluster[j]))