salimcodes/TrialModel
0
1 2import pandas as pd3from sklearn.cluster import DBSCAN4import numpy as np5#Salim6import gradio as gr7def Predict(inputName):8 dataFrame = pd.read_json(r"MOCK_DATA.json")9 safe_distance = 0.0020288 # a radial distance of 6 feet in kilometers10 model = DBSCAN(eps=safe_distance, min_samples=2, metric='haversine').fit(dataFrame[['Latitude', 'Longitude']])11 core_samples_mask = np.zeros_like(model.labels_, dtype=bool)12 core_samples_mask[model.core_sample_indices_] = True13 labels = model.labels_14 dataFrame['Cluster'] = model.labels_.tolist()15 inputNameClusters = set()16 17 for i in range(len(dataFrame)):18 if dataFrame['User'][i] == inputName:19 inputNameClusters.add(dataFrame['Cluster'][i])20 infected = set()21 for cluster in inputNameClusters:22 if cluster != -1:23 namesInCluster = dataFrame.loc[dataFrame['Cluster'] == cluster, 'User']24 for i in range(len(namesInCluster)):25 name = namesInCluster.iloc[i]26 if name != inputName:27 infected.add(name) 28 return infected29 30app = gr.Interface(fn=Predict, 31 inputs="text", 32 outputs="text",33 description = "This app helps you to find out if you have been in contact with someone who has tested positive for COVID-19. As a prototype, it was trained on a dataset of 10 people and their locations. The app takes in their names and outputs the names of people they have been in contact with. The names in this demo are as follows: <br> **`Adeola`, `Amaka`, `Ayoola`, `Bimpe`, `Dolapo`, `Femi`, `Mayokun`, `Segun`, `Seyi`, `Tolu`**. <br> <br> **Disclaimer: This app is for demonstration purposes only and does not provide real contact tracing functionality.**",34 theme="grass",35 title="Contact Tracing Web App") 36app.launch()37 38 39 