Ortsvergleich eingefügt

refactor-to-mono
mmaurostoffel 2024-10-21 23:56:10 +02:00
parent c7d58c2b23
commit f7b62f4e4c
4 changed files with 78 additions and 0 deletions

View File

@ -4,6 +4,17 @@ from datetime import datetime, timedelta
import numpy as np
def getPropertyDataFromDB():
db = MySQLdb.connect(host="localhost",user="root",passwd="admin",db="consultancy")
cur = db.cursor()
cur.execute("SELECT id, seed_id, check_data "
"FROM properties ")
propData = cur.fetchall()
db.close()
return propData
def getDataFromDB(propId):
'''
Function to get data from MySQL database filter with the given propId
@ -147,6 +158,7 @@ def getAccuracy(df, baseLine, compLine):
def getMeanAccuracy(accList):
'''
Get the mean Accuracy of the entire timedelay of one property
:param accList: List of accuracy Values of a comparison
:return: Average of the accuracy values while ignoring the '-1' values
'''
@ -155,3 +167,6 @@ def getMeanAccuracy(accList):
row = [x for x in row if x != -1]
out.append(np.average(row))
return out

58
accuracyPerLocation.py Normal file
View File

@ -0,0 +1,58 @@
import Data_Analysis as DA
import pandas as pd
accuracy = pd.read_csv(f'results/accMeanDf.csv')
propData = DA.getPropertyDataFromDB()
propData = pd.DataFrame(propData, columns =['property_id', 'region', 'geoLocation'])
propData = propData.drop(columns=['geoLocation'])
#print(propData)
merge = pd.merge(propData, accuracy, on="property_id")
#print(merge)
#1 = Heidiland, 2 = Davos, 3 = Engadin 4 = St.Moritz
heidiAcc = merge[merge['region'] == 1]
davosAcc = merge[merge['region'] == 2]
EngadAcc = merge[merge['region'] == 3]
StMorAcc = merge[merge['region'] == 4]
heidiMean = heidiAcc.mean(axis=0)
davosMean = davosAcc.mean(axis=0)
EngadMean = EngadAcc.mean(axis=0)
StMorMean = StMorAcc.mean(axis=0)
heidiSDev = heidiAcc.std(axis=0)
davosSDev = davosAcc.std(axis=0)
EngadSDev = EngadAcc.std(axis=0)
StMorSDev = StMorAcc.std(axis=0)
accuracyOverview = pd.DataFrame()
accuracyOverview.insert(0, "St. Moritz StdDev", StMorSDev, True)
accuracyOverview.insert(0, "St. Moritz Mean", StMorMean, True)
accuracyOverview.insert(0, "Engadin StdDev", EngadSDev, True)
accuracyOverview.insert(0, "Engadin Mean", EngadMean, True)
accuracyOverview.insert(0, "Davos StdDev", davosSDev, True)
accuracyOverview.insert(0, "Davos Mean", davosMean, True)
accuracyOverview.insert(0, "Heidi StdDev", heidiSDev, True)
accuracyOverview.insert(0, "Heidi Mean", heidiMean, True)
accuracyOverview.drop(index=accuracyOverview.index[0], axis=0, inplace=True)
accuracyOverview.drop(index=accuracyOverview.index[0], axis=0, inplace=True)
accuracyOverview.to_csv('results/accuracyOverview.csv', index=False)
#delete unused DF's
del merge, accuracy, propData
del heidiAcc, davosAcc, EngadAcc, StMorAcc
del heidiMean, davosMean, EngadMean, StMorMean
del heidiSDev, davosSDev, EngadSDev, StMorSDev
print(accuracyOverview)

View File

@ -0,0 +1,5 @@
Heidi Mean,Heidi StdDev,Davos Mean,Davos StdDev,Engadin Mean,Engadin StdDev,St. Moritz Mean,St. Moritz StdDev
0.8205301612054612,0.03521328245140846,0.8399836284786809,0.048358617863451414,0.8584327389672194,0.05319145459441233,0.8405512800767019,0.05180554811101561
0.8066005018861457,0.06818803676300687,0.830601813557425,0.04949425409715446,0.8484564978404832,0.05396669349535696,0.8289395302705753,0.05637417919934374
0.7368379473832369,0.06546064555588836,0.7598050837068276,0.06886580034893092,0.7667137312752639,0.06523018886732877,0.7565382226489596,0.06984023355676583
0.6590943554763651,0.09741268862524224,0.6767196066764449,0.09656146924686429,0.670509578923442,0.07935806376665934,0.6633952429541463,0.08233444282881987
1 Heidi Mean Heidi StdDev Davos Mean Davos StdDev Engadin Mean Engadin StdDev St. Moritz Mean St. Moritz StdDev
2 0.8205301612054612 0.03521328245140846 0.8399836284786809 0.048358617863451414 0.8584327389672194 0.05319145459441233 0.8405512800767019 0.05180554811101561
3 0.8066005018861457 0.06818803676300687 0.830601813557425 0.04949425409715446 0.8484564978404832 0.05396669349535696 0.8289395302705753 0.05637417919934374
4 0.7368379473832369 0.06546064555588836 0.7598050837068276 0.06886580034893092 0.7667137312752639 0.06523018886732877 0.7565382226489596 0.06984023355676583
5 0.6590943554763651 0.09741268862524224 0.6767196066764449 0.09656146924686429 0.670509578923442 0.07935806376665934 0.6633952429541463 0.08233444282881987