This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_infected_names(input_name): | |
epsilon = 0.0018288 # a radial distance of 6 feet in kilometers | |
model = DBSCAN(eps=epsilon, min_samples=2, metric='haversine').fit(df[['latitude', 'longitude']]) | |
df['cluster'] = model.labels_.tolist() | |
input_name_clusters = [] | |
for i in range(len(df)): | |
if df['id'][i] == input_name: | |
if df['cluster'][i] in input_name_clusters: | |
pass | |
else: | |
input_name_clusters.append(df['cluster'][i]) | |
infected_names = [] | |
for cluster in input_name_clusters: | |
if cluster != -1: | |
ids_in_cluster = df.loc[df['cluster'] == cluster, 'id'] | |
for i in range(len(ids_in_cluster)): | |
member_id = ids_in_cluster.iloc[i] | |
if (member_id not in infected_names) and (member_id != input_name): | |
infected_names.append(member_id) | |
else: | |
pass | |
return infected_names |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment