Spaces:
Sleeping
Sleeping
Commit ·
530da45
1
Parent(s): 85f772d
Delete untitled2.py
Browse files- untitled2.py +0 -43
untitled2.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
| 1 |
-
# -*- coding: utf-8 -*-
|
| 2 |
-
"""Untitled2.ipynb
|
| 3 |
-
|
| 4 |
-
Automatically generated by Colaboratory.
|
| 5 |
-
|
| 6 |
-
Original file is located at
|
| 7 |
-
https://colab.research.google.com/drive/1EU-VIsBUmCvPXWODe7G3MMx3nOyrhLE3
|
| 8 |
-
"""
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
import pandas as pd
|
| 12 |
-
import pygal
|
| 13 |
-
from sklearn.cluster import DBSCAN
|
| 14 |
-
import numpy as np
|
| 15 |
-
|
| 16 |
-
import gradio as gr
|
| 17 |
-
def Predict(inputName):
|
| 18 |
-
dataFrame = pd.read_json(r"MOCK_DATA.json")
|
| 19 |
-
safe_distance = 0.0020288 # a radial distance of 6 feet in kilometers
|
| 20 |
-
model = DBSCAN(eps=safe_distance, min_samples=2, metric='haversine').fit(dataFrame[['Latitude', 'Longitude']])
|
| 21 |
-
core_samples_mask = np.zeros_like(model.labels_, dtype=bool)
|
| 22 |
-
core_samples_mask[model.core_sample_indices_] = True
|
| 23 |
-
labels = model.labels_
|
| 24 |
-
dataFrame['Cluster'] = model.labels_.tolist()
|
| 25 |
-
inputNameClusters = set()
|
| 26 |
-
for i in range(len(dataFrame)):
|
| 27 |
-
if dataFrame['User'][i] == inputName:
|
| 28 |
-
inputNameClusters.add(dataFrame['Cluster'][i])
|
| 29 |
-
infected = set()
|
| 30 |
-
for cluster in inputNameClusters:
|
| 31 |
-
if cluster != -1:
|
| 32 |
-
namesInCluster = dataFrame.loc[dataFrame['Cluster'] == cluster, 'User']
|
| 33 |
-
for i in range(len(namesInCluster)):
|
| 34 |
-
name = namesInCluster.iloc[i]
|
| 35 |
-
if name != inputName:
|
| 36 |
-
infected.add(name)
|
| 37 |
-
return infected
|
| 38 |
-
|
| 39 |
-
gui = gr.Interface(fn=Predict,
|
| 40 |
-
inputs="text",
|
| 41 |
-
outputs="text")
|
| 42 |
-
gui.launch()
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|