Spaces:
Sleeping
Sleeping
nastasiasnk
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -111,6 +111,29 @@ def test(input_json):
|
|
111 |
LivabilitySubdomainsWeights_dictionary = LivabilitySubdomainsWeights.to_dict('index')
|
112 |
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
def computeAccessibility (DistanceMatrix,weightsNames, destinationWeights=None,alpha = 0.0038, threshold = 600):
|
116 |
|
@@ -152,7 +175,13 @@ def test(input_json):
|
|
152 |
# remap accessibility to livability points
|
153 |
|
154 |
for key, values in SubdomainAttributeDict.items():
|
155 |
-
if key
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
domain = [str(item) for item in SubdomainAttributeDict[key]['domain']]
|
157 |
threshold = float(SubdomainAttributeDict[key]['thresholds'])
|
158 |
max_livability = float(SubdomainAttributeDict[key]['max_points'])
|
@@ -165,7 +194,7 @@ def test(input_json):
|
|
165 |
for item in domain:
|
166 |
livability.loc[subdomainsAccessibility[key] >= threshold, item] += max_livability
|
167 |
livability.loc[subdomainsAccessibility[key] < threshold, item] += livability_score
|
168 |
-
|
169 |
|
170 |
return livability
|
171 |
|
|
|
111 |
LivabilitySubdomainsWeights_dictionary = LivabilitySubdomainsWeights.to_dict('index')
|
112 |
|
113 |
|
114 |
+
|
115 |
+
|
116 |
+
def FindWorkplaces (DistanceMatrix,SubdomainAttributeDict,destinationWeights,UniqueSubdomainsList ):
|
117 |
+
|
118 |
+
df_LivabilitySubdomainsWorkplaces = pd.DataFrame(0, index=DistanceMatrix.index, columns=['jobs'])
|
119 |
+
|
120 |
+
for domain in UniqueSubdomainsList:
|
121 |
+
for key, value_list in SubdomainAttributeDict.items():
|
122 |
+
sqm_per_empl = float(SubdomainAttributeDict[domain][0])
|
123 |
+
if key in destinationWeights.columns and key == domain:
|
124 |
+
if sqm_per_empl > 0:
|
125 |
+
df_LivabilitySubdomainsWorkplaces['jobs'] += (round(destinationWeights[key] / sqm_per_empl,2)).fillna(0)
|
126 |
+
else:
|
127 |
+
df_LivabilitySubdomainsWorkplaces['jobs'] += 0
|
128 |
+
|
129 |
+
return df_LivabilitySubdomainsWorkplaces
|
130 |
+
|
131 |
+
|
132 |
+
WorkplacesNumber = FindWorkplaces(df_matrix,attributeMapperDict,LivabilitySubdomainsWeights,subdomainsUnique)
|
133 |
+
|
134 |
+
LivabilitySubdomainsWeights =pd.concat([df_LivabilitySubdomainsArea, df_LivabilitySubdomainsWorkplaces], axis=1)
|
135 |
+
|
136 |
+
|
137 |
|
138 |
def computeAccessibility (DistanceMatrix,weightsNames, destinationWeights=None,alpha = 0.0038, threshold = 600):
|
139 |
|
|
|
175 |
# remap accessibility to livability points
|
176 |
|
177 |
for key, values in SubdomainAttributeDict.items():
|
178 |
+
if key == 'commercial':
|
179 |
+
threshold = float(SubdomainAttributeDict['commercial'][1])
|
180 |
+
max_livability = float(SubdomainAttributeDict['commercial'][2])
|
181 |
+
livability_score = remap(subdomainsAccessibility['jobs'], 0, threshold, 0, max_livability)
|
182 |
+
livability.loc[subdomainsAccessibility['jobs'] >= threshold, 'Workplaces'] = max_livability
|
183 |
+
livability.loc[subdomainsAccessibility['jobs'] < threshold, 'Workplaces'] = livability_score
|
184 |
+
elif key in subdomainsAccessibility.columns:
|
185 |
domain = [str(item) for item in SubdomainAttributeDict[key]['domain']]
|
186 |
threshold = float(SubdomainAttributeDict[key]['thresholds'])
|
187 |
max_livability = float(SubdomainAttributeDict[key]['max_points'])
|
|
|
194 |
for item in domain:
|
195 |
livability.loc[subdomainsAccessibility[key] >= threshold, item] += max_livability
|
196 |
livability.loc[subdomainsAccessibility[key] < threshold, item] += livability_score
|
197 |
+
|
198 |
|
199 |
return livability
|
200 |
|