Spaces:
Sleeping
Sleeping
nastasiasnk
commited on
Commit
•
a07c0ed
1
Parent(s):
cba8adc
Update app.py
Browse files
app.py
CHANGED
@@ -34,10 +34,7 @@ def test(input_json):
|
|
34 |
|
35 |
decay_factors = np.exp(-alpha * DistanceMatrix) * (DistanceMatrix <= threshold)
|
36 |
subdomainsAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=destinationWeights.columns)
|
37 |
-
|
38 |
-
subdomainsAccessibility.columns = [int(col) for col in subdomainsAccessibility.columns]
|
39 |
-
subdomainsAccessibility = subdomainsAccessibility.sort_index(axis=1)
|
40 |
-
|
41 |
for col in destinationWeights.columns:
|
42 |
subdomainsAccessibility[col] = (decay_factors * destinationWeights[col].values).sum(axis=1)
|
43 |
|
@@ -46,15 +43,19 @@ def test(input_json):
|
|
46 |
return subdomainsAccessibility
|
47 |
|
48 |
subdomainsAccessibility = computeAccessibility(df_matrix,df_weights,alpha,threshold)
|
49 |
-
|
|
|
|
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
54 |
|
|
|
55 |
# Prepare the output
|
56 |
output = {
|
57 |
-
"
|
58 |
}
|
59 |
|
60 |
return json.dumps(output)
|
|
|
34 |
|
35 |
decay_factors = np.exp(-alpha * DistanceMatrix) * (DistanceMatrix <= threshold)
|
36 |
subdomainsAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=destinationWeights.columns)
|
37 |
+
|
|
|
|
|
|
|
38 |
for col in destinationWeights.columns:
|
39 |
subdomainsAccessibility[col] = (decay_factors * destinationWeights[col].values).sum(axis=1)
|
40 |
|
|
|
43 |
return subdomainsAccessibility
|
44 |
|
45 |
subdomainsAccessibility = computeAccessibility(df_matrix,df_weights,alpha,threshold)
|
46 |
+
#subdomainsAccessibility.columns = [int(col) for col in subdomainsAccessibility.columns]
|
47 |
+
#subdomainsAccessibility_sorted = subdomainsAccessibility.sort_index(axis=1)
|
48 |
+
subdomainsAccessibility_dictionary = subdomainsAccessibility.to_dict('index')
|
49 |
|
50 |
+
subdomainsAccessibility_dictionary = {outer_key: dict(sorted(inner_dict.items(), key=lambda x: int(x[0])))
|
51 |
+
for outer_key, inner_dict in subdomainsAccessibility_dictionary.items()}
|
52 |
+
# subdomainsAccessibility.columns = [int(col) for col in subdomainsAccessibility.columns]
|
53 |
+
# subdomainsAccessibility = subdomainsAccessibility.sort_index(axis=1)
|
54 |
|
55 |
+
|
56 |
# Prepare the output
|
57 |
output = {
|
58 |
+
"subdomainsAccessibility_dictionary": subdomainsAccessibility_dictionary
|
59 |
}
|
60 |
|
61 |
return json.dumps(output)
|