File size: 1,889 Bytes
c077dfd
9df1a7b
 
 
b96bd6b
9df1a7b
 
 
 
 
 
 
 
 
 
ab25469
9df1a7b
 
 
 
 
 
 
 
 
 
 
 
 
345161b
1b43e5e
62fe948
ca61a41
345161b
62fe948
c077dfd
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

import pandas as pd
from sklearn.cluster import DBSCAN
import numpy as np
#Salim
import gradio as gr
def Predict(inputName):
    dataFrame = pd.read_json(r"MOCK_DATA.json")
    safe_distance = 0.0020288 # a radial distance of 6 feet in kilometers
    model = DBSCAN(eps=safe_distance, min_samples=2, metric='haversine').fit(dataFrame[['Latitude', 'Longitude']])
    core_samples_mask = np.zeros_like(model.labels_, dtype=bool)
    core_samples_mask[model.core_sample_indices_] = True
    labels = model.labels_
    dataFrame['Cluster'] = model.labels_.tolist()
    inputNameClusters = set()
    
    for i in range(len(dataFrame)):
        if dataFrame['User'][i] == inputName:
            inputNameClusters.add(dataFrame['Cluster'][i])
    infected = set()
    for cluster in inputNameClusters:
        if cluster != -1:
            namesInCluster = dataFrame.loc[dataFrame['Cluster'] == cluster, 'User']
            for i in range(len(namesInCluster)):
                name = namesInCluster.iloc[i]
                if name != inputName:
                    infected.add(name) 
    return infected

app = gr.Interface(fn=Predict, 
                   inputs="text", 
                   outputs="text",
                   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.**",
                   theme="grass",
                   title="Contact Tracing Web App") 
app.launch()