Spaces:
Runtime error
Runtime error
Commit
·
f8ed147
1
Parent(s):
8766483
pricefix
Browse files
app.py
CHANGED
@@ -278,8 +278,6 @@ def autoPred(df):
|
|
278 |
res = res[:-20]
|
279 |
|
280 |
# Get the mean of the agencies
|
281 |
-
|
282 |
-
|
283 |
agencyToResult = {agency:result for agency, result in zip(topAgencies, agencyResults)}
|
284 |
for agency, result in agencyToResult.items():
|
285 |
print(agency, str(result))
|
@@ -287,25 +285,19 @@ def autoPred(df):
|
|
287 |
# Get the top and bottom 3 agencies with the highest results
|
288 |
sortedAgencies = sorted(agencyToResult.items(), key=lambda x: x[1])
|
289 |
meanPrice = sum(agencyResults) / len(agencyResults)
|
290 |
-
|
291 |
-
top3 = sortedAgencies[-3:]
|
292 |
top3.reverse()
|
293 |
-
bottom3 = sortedAgencies[:3]
|
294 |
|
295 |
-
agencyString = parseAgencyResult(top3,
|
296 |
|
297 |
return res, agencyString
|
298 |
|
299 |
-
def parseAgencyResult(top3,
|
300 |
toReturn = '\nTo get the most money for your apartment, you should sell it with the help of one of these agencies:\n'
|
301 |
-
toReturn += 'Top
|
302 |
for agency, result in top3:
|
303 |
diff = result - meanPrice
|
304 |
toReturn += f'{agency}: {parsePrice(result)} ({parsePrice(diff)} above mean)\n'
|
305 |
-
toReturn += 'And these are the worst agencies to use\n'
|
306 |
-
for agency, result in bottom3:
|
307 |
-
diff = result - meanPrice
|
308 |
-
toReturn += f'{agency}: {parsePrice(result)}\n'
|
309 |
|
310 |
return toReturn
|
311 |
|
|
|
278 |
res = res[:-20]
|
279 |
|
280 |
# Get the mean of the agencies
|
|
|
|
|
281 |
agencyToResult = {agency:result for agency, result in zip(topAgencies, agencyResults)}
|
282 |
for agency, result in agencyToResult.items():
|
283 |
print(agency, str(result))
|
|
|
285 |
# Get the top and bottom 3 agencies with the highest results
|
286 |
sortedAgencies = sorted(agencyToResult.items(), key=lambda x: x[1])
|
287 |
meanPrice = sum(agencyResults) / len(agencyResults)
|
288 |
+
top3 = sortedAgencies[-5:]
|
|
|
289 |
top3.reverse()
|
|
|
290 |
|
291 |
+
agencyString = parseAgencyResult(top3, meanPrice)
|
292 |
|
293 |
return res, agencyString
|
294 |
|
295 |
+
def parseAgencyResult(top3, meanPrice):
|
296 |
toReturn = '\nTo get the most money for your apartment, you should sell it with the help of one of these agencies:\n'
|
297 |
+
toReturn += 'Top 5:\n'
|
298 |
for agency, result in top3:
|
299 |
diff = result - meanPrice
|
300 |
toReturn += f'{agency}: {parsePrice(result)} ({parsePrice(diff)} above mean)\n'
|
|
|
|
|
|
|
|
|
301 |
|
302 |
return toReturn
|
303 |
|