Commit 41cd4ebb authored by Bogdan's avatar Bogdan

5Layers demand plot visualisations

parent 0f0e6995
###add modules folder to interpreter path
import sys
import os
import requests
import numpy as np
import matplotlib.pyplot as plt
modules_path = '../../../modules/'
if os.path.exists(modules_path):
sys.path.insert(1, modules_path)
######SECURITY#############
# import connecion
# from security import swagger_util
......@@ -26,20 +31,150 @@ repo = Repository()
def deleteWHOOLEData():
print("test")
repo.delete_all_similarity_data()
def processData():
fetchy.fetch_nodes_from_semantic_linking()
clustering.run_clustering_for_Paper_case()
similCalc.run_similarity_calc_for_Paper_case()
def mainViz():
# small set
# r = requests.get('https://drive.google.com/uc?export=download&id=1iaiFhwiadViXojYIvK1qkV2Mrf26IXme', timeout=15)
# print("Downloaded JSON")
# inputSimListOfDict = json.loads(r.content)
# big set
print("Opening JSON")
with open('resultSimilarityDictN86400C3388.json') as json_file:
inputSimListOfDict = json.load(json_file)
#procesing data
print("Opened JSON")
demandLayerListOfDict = []
for simDict in inputSimListOfDict:
if simDict['cluster_layer']=='Demand_Layer':
demandLayerListOfDict.append(simDict)
# {
# "cluster1_label": 3,
# "cluster2_label": 5,
# "cluster_layer": "Demand_Layer",
# "similarityValues": {
# "Solar_Production_Layer": 0.0,
# "Energy_Consumption_Layer": 0.0,
# "Heating_Consumption_Layer": 0.0,
# "Price_Layer": 46340.950540531645,
# "Position_Layer": 0.0
# },
# "runId": "5f886e7e35b70a1704c728e6",
# "use_case": "paper"
# },
print("Starting DistribDicts")
distributionSolar= dict()
distributionEnergy = dict()
distributionHeating = dict()
distributionPrice = dict()
distributionPosition = dict()
for entry in demandLayerListOfDict:
similVal = entry['similarityValues']
if checkKey(distributionSolar,similVal['Solar_Production_Layer']):
distributionSolar[similVal['Solar_Production_Layer']] +=1
else:
if(similVal['Solar_Production_Layer']< 45000):
distributionSolar[similVal['Solar_Production_Layer']] = 1
if checkKey(distributionEnergy,similVal['Energy_Consumption_Layer']):
distributionEnergy[similVal['Energy_Consumption_Layer']] +=1
else:
if(similVal['Energy_Consumption_Layer']< 45000):
distributionEnergy[similVal['Energy_Consumption_Layer']] = 1
if checkKey(distributionHeating,similVal['Heating_Consumption_Layer']):
distributionHeating[similVal['Heating_Consumption_Layer']] +=1
else:
if(similVal['Heating_Consumption_Layer']< 45000):
distributionHeating[similVal['Heating_Consumption_Layer']] = 1
if checkKey(distributionPrice,similVal['Price_Layer']):
distributionPrice[similVal['Price_Layer']] +=1
else:
if(similVal['Price_Layer']< 45000):
distributionPrice[similVal['Price_Layer']] = 1
if checkKey(distributionPosition,similVal['Position_Layer']):
distributionPosition[similVal['Position_Layer']] +=1
else:
if(similVal['Position_Layer']< 45000):
distributionPosition[similVal['Position_Layer']] = 1
print("\nFinishedListDistrib\n")
#TRY TO PLOT
fig, axs = plt.subplots(1,5, sharex = True)
fig.suptitle('Choose A title??? ')
fig.text(0.5, 0.04, 'Euclidean Distance', ha='center', va='center')
list1 = sorted(distributionSolar.items())
x2,y2 = zip(*list1)
axs[0].bar(x2,y2,color='purple',label="Solar", width=0.2)
axs[0].legend()
axs[0].set_title('Solar')
axs[0].set(ylabel='Nr. of Similarity connections between two Clusters')
list1 = sorted(distributionEnergy.items())
x,y = zip(*list1)
axs[1].bar(x, y, color='blue',label="Energy", width=0.2)
axs[1].legend()
list1 = sorted(distributionHeating.items())
x3,y3 = zip(*list1)
axs[2].bar(x3,y3,color='red',label="Heating", width=0.2)
axs[2].legend()
list1 = sorted(distributionPrice.items())
x4,y4 = zip(*list1)
axs[3].bar(x4,y4,color='green',label="Price", width=0.2)
axs[3].legend()
list1 = sorted(distributionPosition.items())
x5,y5 = zip(*list1)
axs[4].bar(x5,y5,color='grey',label="Location", width=0.2)
axs[4].legend()
plt.show()
print("FIN")
print("\n")
fetchy.fetch_nodes_from_semantic_linking()
clustering.run_clustering_for_Paper_case()
similCalc.run_similarity_calc_for_Paper_case() #TODO FIX
#inputData.getClusterDataFromMongo("Paper",None,None)
#inputData.getSimilarityDataFromMongo(cluster_layer: str= None, batchSize: int=1000, run_id: str=None)
#similarityArrFromMongo = getSimilarityDataFromMongo("Paper")
deleteWHOOLEData()
def checkKey(dict, key):
if key in dict.keys():
#print("Present, ", end =" ")
#print(str(key)+ " : " + str(dict[key] ))
return True
else:
#print("Not present")
return False
#deleteWHOOLEData()
#processData()
mainViz()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment