nastasiasnk commited on
Commit
68e8a9a
1 Parent(s): 83cd13d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -33,19 +33,24 @@ def test(input_json):
33
  df_matrix = df_matrix.round(0).astype(int)
34
  df_weights = df_weights.round(0).astype(int)
35
 
36
- def computeAccessibility (DistanceMatrix,destinationWeights,weightsNames, alpha = 0.0038, threshold = 600):
37
 
38
  decay_factors = np.exp(-alpha * DistanceMatrix) * (DistanceMatrix <= threshold)
39
  subdomainsAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=weightsNames) #destinationWeights.columns)
40
-
41
- for col,columnName in zip(destinationWeights.columns, weightsNames):
42
- subdomainsAccessibility[columnName] = (decay_factors * destinationWeights[col].values).sum(axis=1)
43
-
 
 
 
 
 
44
  #subdomainsAccessibility.drop(columns='commercial', inplace=True)
45
 
46
  return subdomainsAccessibility
47
 
48
- subdomainsAccessibility = computeAccessibility(df_matrix,df_weights,weightsNames,alpha,threshold)
49
  #subdomainsAccessibility.columns = [int(col) for col in subdomainsAccessibility.columns]
50
  #subdomainsAccessibility_sorted = subdomainsAccessibility.sort_index(axis=1)
51
  subdomainsAccessibility_dictionary = subdomainsAccessibility.to_dict('index')
 
33
  df_matrix = df_matrix.round(0).astype(int)
34
  df_weights = df_weights.round(0).astype(int)
35
 
36
+ def computeAccessibility (DistanceMatrix,weightsNames, destinationWeights=None,alpha = 0.0038, threshold = 600):
37
 
38
  decay_factors = np.exp(-alpha * DistanceMatrix) * (DistanceMatrix <= threshold)
39
  subdomainsAccessibility = pd.DataFrame(index=DistanceMatrix.index, columns=weightsNames) #destinationWeights.columns)
40
+ # for weighted accessibility (e. g. areas)
41
+ if destinationWeights!=None:
42
+ for col,columnName in zip(destinationWeights.columns, weightsNames):
43
+ subdomainsAccessibility[columnName] = (decay_factors * destinationWeights[col].values).sum(axis=1)
44
+ # for unweighted accessibility (e. g. points of interest)
45
+ else:
46
+ for columnName in weightsNames:
47
+ subdomainsAccessibility[columnName] = (decay_factors * 1).sum(axis=1)
48
+
49
  #subdomainsAccessibility.drop(columns='commercial', inplace=True)
50
 
51
  return subdomainsAccessibility
52
 
53
+ subdomainsAccessibility = computeAccessibility(df_matrix,weightsNames,df_weights,alpha,threshold)
54
  #subdomainsAccessibility.columns = [int(col) for col in subdomainsAccessibility.columns]
55
  #subdomainsAccessibility_sorted = subdomainsAccessibility.sort_index(axis=1)
56
  subdomainsAccessibility_dictionary = subdomainsAccessibility.to_dict('index')