Skip to content
Snippets Groups Projects
Commit ee4b9b21 authored by yager2's avatar yager2
Browse files

Replace Visualizations.py to include correlation_check() function. I'm not...

Replace Visualizations.py to include correlation_check() function.  I'm not happy with it, but it at least gives a thumbs up/down check.
parent c6e6b494
No related branches found
No related tags found
No related merge requests found
......@@ -148,4 +148,23 @@ def map_links(link_list=None, link_file=None, out_file='Map'):
geo_df = gpd.GeoDataFrame(df, crs=crs, geometry='geom')
geo_df.to_file(out_file)
return None
\ No newline at end of file
return None
def correlation_check(W1, W2, threshold):
assert W1.shape == W2.shape
assert threshold <= 1 and threshold>= -1, "Unreasonable threshold. Must be between -1 and 1"
Ro = np.corrcoef(W1.T,W2.T)[len(W1.T):,:len(W2.T)]
Ro_geq_threshold = Ro > threshold
if np.sum(Ro_geq_threshold, axis=0).min() > 0 and np.sum(Ro_geq_threshold, axis=1).min() > 0:
print('Possible Permutation! ith column of W1 can be mapped to jth column of W2 appears as j is in possible_maps[i]')
possible_maps=[np.where(column >0) for column in Ro_geq_threshold.T]
return Ro, possible_maps
else:
print('No Good Permutation. Try reducing threshold.')
possible_maps = list()
return Ro, possible_maps
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment