

Introduction¶
Coronavirus sickness (COVID-19) is an irresistible infection brought about by another infection.
What is Corona virus and How Novel Corona Virus Precautionary measures will change your life?
A novel corona virus is a new corona virus that has not been previously identified. The virus causing novel corona virus disease 2019 (COVID-19), is not the same as the novel corona viruse that commonly circulate among humans and cause mild illness, like the common cold.
A novel corona virus is a new corona virus that has not been previously identified. The virus causing novel corona virus disease 2019 (COVID-19), is not the same as the novel corona viruses that commonly circulate among humans and cause mild illness, like the common cold.
There are several guidelines Prepared by WHO for Taking Precautionary measures from Novel Corona virus
COVID-19? What is this and Why Novel Corona Virus Precautionary measures will change your life?
Novel corona virus is the last detected corona virus lately . New infections and illnesses weren’t apparent before the episode began in Wuhan, China in December 2001. Covid-19 is currently an epidemic (pandemic) affecting many countries across the country (or across the continent).
On February 11, 2020 the World Health Organization announced an official name for the malady that is causing the 2019 novel corona virus flare-up, first recognized in Wuhan China. The new name of this infection is crown infection malady 2019, condensed as COVID-19. In COVID-19, ‘CO’ means ‘crown,’ ‘VI’ for ‘infection,’ and ‘D’ for sickness. Earlier, this malady was alluded to as “2019 novel crown infection” or “2019-nCoV”
There are numerous sorts of human corona viruse including some that ordinarily cause mellow upper-respiratory tract diseases. COVID-19 is another infection, brought about by a novel (or new) novel corona virus infection that has not recently been seen in humans therefore it is recommended to take Precautionary measures.
The infection causes respiratory ailment (like this season’s flu virus) with manifestations, for example, a hack, fever, and in progressively extreme cases, trouble relaxing. You can secure yourself by washing your hands as often as possible, abstaining from contacting your face, and maintaining a strategic distance from close contact (1 meter or 3 feet) with individuals who are unwell.
Problem Statement¶
This Virus has spread all through the world, which caused a significant misfortune in human life and financial everyday practice. Besides, The Virus has affected in excess of 7 lacs individuals all through the world with recuperation pace of 2% and 34000+ Deaths all through the world. The Major Countries Such as China , Itlay , US , Germany and so on have huge measure of paitents who are affected with Covid19.
As, this Virus has caused pandamic debacle all through the world. India has least number of cases on the planet till now as India has played it safe to forestall this pandamic.
We will try to figure out The most effected states in India with more population and least number number of center.With the Most effected states we will find most effected citites in that paticular states.
As of Now we have least number of cases compared to rest of the countries. But talking about the stats we have mass number of population and very limited amount of reasources.Taking the worst case Senrio we need to expand the resources with limited number of doctors who will be treating the paitents.
Goal¶
Lets Assume, we have 800 beds accessible in the fundamental center.In Case if beds are completly full we need a seclusion place yet alloting an isloation community would help paitents however we have 10 principle specialists who are treating critcal just as expected paitents.
Imagine a scenario where we discover the closest medical clinics or a seclusion community inside 1.5 to 3 km of range to such an extent that in time of crisis or for normal exam they can without much of a stretch travel inside 3 km range to numerous focuses.
1.This Will assist with decreasing the quantity of passings and help paitents to fix quick.
2.By breaking down versertile paitents, there would be more possibilty for their examination group to handily discover arrangement and get ready immunization.
What We will Do¶
With information driven technique
1.We will Optimize the and find conceivable isloation habitats which are closest to our test place in the event that we unexpectedly have ascend in symotmatic paitents. We can designate them to that place through which an indvdiual specialists can assume responsibility for the paitents by utilizing Foursqure API.
2.By Using Machine Learning we will amass the basic paitents and typical paitents closest to the test place inside 1.5 km of range.
import requests
from bs4 import BeautifulSoup
import csv
import json
import xml
import pandas as pd
import numpy as np
!conda install -c conda-forge folium=0.5.0 --yes
import folium
from folium import plugins
import json
from pprint import pprint
!conda install -c conda-forge geopy --yes
from geopy.geocoders import Nominatim # module to convert an address into latitude and longitude values
# libraries for displaying images
from IPython.display import Image
from IPython.core.display import HTML
# Matplotlib and associated plotting modules
import matplotlib.cm as cm
import matplotlib.colors as colors
import matplotlib.pyplot as plt
%matplotlib inline
# import k-means from clustering stage
from sklearn.cluster import KMeans
import pandas as pd # library for data analsysis
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
import json # library to handle JSON files
import requests # library to handle requests
from pandas.io.json import json_normalize # tranform JSON file into a pandas dataframe
Working with Test Center Data Set¶
url= 'https://docs.google.com/spreadsheets/d/1vvhdhxNPlEqIZxfQiSGmYCnNf6WB37vhXo3P5W08CQE/edit?usp=sharing'
data = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vTowbPbWhuIRQgVzJR0mVcFv4nG59m5JAOcSCGbaTOm3LO9g0ORIJgxAiqDPBk6Y71e2nTukwj2spsG/pub?output=csv'
import pandas as pd
file = pd.read_csv(data,sep=",") # use sep="," for coma separation.
file.describe()
file = file.drop(file.index[0])
file.head()
file.info()
Ploting Test Center Using Geolocator and Folium¶
address = 'India'
geolocator = Nominatim(user_agent="my_app")
location = geolocator.geocode(address)
latitude = location.latitude
longitude = location.longitude
print('The geograpical coordinate are {}, {}.'.format(latitude, longitude))
map_test_center = folium.Map(location=[latitude, longitude], zoom_start=4)
# add markers to map
for lat, lng, label in zip(file['Latitude'], file['Longitude'], file['TestCenter']):
label = folium.Popup(label, parse_html=True)
folium.CircleMarker(
[lat, lng],
radius=5,
popup=label,
color='orange',
fill=True,
fill_color='yellow',
fill_opacity=0.7,
parse_html=False).add_to(map_test_center)
map_test_center.save("map_test_center.png")
map_test_center
Finding out which state has most population Population¶
url_list = requests.get('https://en.wikipedia.org/wiki/List_of_states_and_union_territories_of_India_by_population#List').text
soup = BeautifulSoup(url_list, 'lxml')
wiki_extract = soup.find("table", class_ = 'wikitable sortable')
wiki_table_rows = wiki_extract.find_all('tr')
information = []
for row in wiki_table_rows:
info = row.text.split('\n')[1:-1]
information.append(info)
state_df = pd.DataFrame(information[0:])
state_df = state_df.drop(state_df.columns[[0, 17, 18]], axis=1)
state_df.columns = state_df.iloc[0]
state_df = state_df.reindex(state_df.index.drop(0)).reset_index(drop=True)
state_df.columns.name = None
state_df.head(10)
UP, Maharastra and Bihar are the three states with most population.
Finding Out Which State is highly Infected¶
covid_case = requests.get("https://www.mohfw.gov.in").text
soup = BeautifulSoup(covid_case, 'lxml')
wiki_covid = soup.find("div", id = 'cases')
covid_table_rows = wiki_covid.find_all('tr')
covid_information = []
for row in covid_table_rows:
info = row.text.split('\n')
covid_information.append(info)
covid_information
covid_df = pd.DataFrame(covid_information)
covid_df = covid_df.drop(covid_df.columns[[0, 7, 8,9,10]], axis=1)
covid_df.columns = covid_df.iloc[0]
covid_df = covid_df.reindex(covid_df.index.drop(0)).reset_index(drop=True)
covid_df.columns.name = None
covid_df = covid_df.drop(covid_df.index[27])
covid_df['Total Confirmed cases *'] = covid_df['Total Confirmed cases *'].astype(int)
covid_df.head(10)
import matplotlib.pyplot as plt
%matplotlib inline
plt.style.use('ggplot')
my_colors = 'rgbkymc'
covid_df2 = covid_df[['Name of State / UT', 'Total Confirmed cases *']].sort_values(by = 'Total Confirmed cases *', ascending = True)
index = covid_df2.set_index("Name of State / UT", inplace = True)
bar = covid_df2.plot(kind='bar',figsize=(20, 10) ,color=my_colors, legend = None)
bar
plt.yticks(fontsize = 14)
plt.xticks(index, fontsize=15, rotation=90)
plt.xlabel("States", fontsize = 20)
plt.ylabel("Cases", fontsize = 20)
plt.title("State wise Total Confirmed cases", fontsize=25)
bar.spines['top'].set_visible(False)
bar.spines['right'].set_visible(False)
bar.spines['bottom'].set_linewidth(0.5)
bar.spines['left'].set_visible(True)
plt.show()
plt.savefig('covid_read.png')
Kerala and Maharashtra are two states which are highly effected with 190+ Cases. But We will choose Maharashtra because,
Maharastra has secound highest Population in the country
It has only two test Centers
Finding Out which city is most infected¶
mh_data = requests.get('https://en.wikipedia.org/wiki/2020_coronavirus_pandemic_in_Maharashtra#Statistics').text
soup = BeautifulSoup(mh_data, 'lxml')
wiki_mh = soup.find("table", class_ = 'wikitable')
mh_table_rows = wiki_mh.find_all('tr')
mh_information = []
for row in mh_table_rows:
info = row.text.split('\n')
mh_information.append(info)
mh_information
mh_df = pd.DataFrame(mh_information[0:])
mh_df.columns = mh_df.iloc[0]
mh_df = mh_df.reindex(mh_df.index.drop(0)).reset_index(drop=True)
mh_df.columns.name = None
mh_df.head(10)
As We know, Maharastra has second highest population and second highest Infected State in the Country with least number of Test Center. We will Pick up Mumbai(As we know Mumbai is very densly populated with highest number 0f cases) and we will try to impliment solutions.
Accessing Four Square API¶
CLIENT_ID ='C1BB50HNQVJUNJBXQ2PDTEFSOX1SGJGLIEEJPYFFXADJH313' # portion hidden from view' # your Foursquare ID
CLIENT_SECRET = '30QKDGXPGJOCSKRETYN4G1CFQHVGZXBWNHSU3DSUTZ5QPAHL'# portion hidden from view' # your Foursquare Secret
VERSION = '20180604'
LIMIT = 50
radius = 2000
categoryId = "4bf58dd8d48988d196941735"
print('Your credentails:')
print('CLIENT_ID: ' + CLIENT_ID)
print('CLIENT_SECRET:' + CLIENT_SECRET)
Getting Near by Hospltals within 2.5 km of range¶
mum_lat = 18.98546
mum_long = 72.83132
url = 'https://api.foursquare.com/v2/venues/search?&client_id={}&client_secret={}&v={}&categoryId={}&ll={},{}&radius={}&limit={}'.format(
CLIENT_ID,
CLIENT_SECRET,
VERSION,
categoryId,
mum_lat,
mum_long,
radius,
LIMIT)
url
venues_list=[]
results = requests.get(url).json()["response"]['venues']
venues_list.append([(
v['name'],
v['location']['lat'],
v['location']['lng'],
v['location']['distance']) for v in results])
nearby_venues = pd.DataFrame([venues for venue_list in venues_list for venues in venue_list])
nearby_venues.columns = ['Near by Hospitals',
'Latitude',
'Longitude','Distance']
nearby_venues = nearby_venues.dropna()
nearby_venues = nearby_venues.reset_index(drop=True)
nearby_venues.head()
print('There are {} hospitals within 2.5 km of range.'.format(len(nearby_venues['Near by Hospitals'])))
nearby_venues = nearby_venues.sort_values(by ='Distance' , ascending=True)
nearby_venues = nearby_venues.reset_index(drop=True)
nearby_venues.head(10)
nearby_venues['Distance'].mean()
nearest_distance = np.array(nearby_venues['Distance']>=1489)
mild_distance = np.array(nearby_venues['Distance']<= 1489)
print('Nearest within 1.5 km to center:' ,nearest_distance.sum())
print('Nearest between 1.5 to 2.5 km center:' ,mild_distance.sum())
Using K means algorithum to group nearby places¶
kclusters = 3
nearby_venues_clustering = nearby_venues.drop('Near by Hospitals', 1)
# run k-means clustering
kmeans = KMeans(n_clusters=kclusters, random_state=1).fit(nearby_venues_clustering)
# check cluster labels generated for each row in the dataframe
print(kmeans.labels_)
print(len(kmeans.labels_))
nearby_venues_merge = nearby_venues
nearby_venues['Cluster'] = kmeans.labels_
nearby_venues.head()
Plotting Map¶
map_clusters = folium.Map(location=[mum_lat, mum_long], zoom_start=14)
x = np.arange(kclusters)
ys = [i+x+(i*x)**2 for i in range(kclusters)]
colors_array = cm.rainbow(np.linspace(0, 1, len(ys)))
rainbow = [colors.rgb2hex(i) for i in colors_array]
markers_colors = []
for lat, lon, poi, cluster in zip(nearby_venues['Latitude'], nearby_venues['Longitude'], nearby_venues['Near by Hospitals'],kmeans.labels_):
label = folium.Popup(str(poi), parse_html=True)
folium.CircleMarker(
[lat, lon],
radius=5,
popup=label,
color=rainbow[cluster-1],
fill=True,
fill_color=rainbow[cluster-1],
fill_opacity=0.5).add_to(map_clusters)
map_clusters.save("map_clusters.png")
map_clusters
Conclusion¶
We Found out 22 Hostpitals in the scope of 2.5 km.
Right off the bat, We sucessfully Optimized the nearby area using Clustering Algorithum.
For Cluster 0 we can say that these hosptials are close to the middle . So we can distribute that beds for critcal paitent.
Similary, For Cluster 1,2 we can designate gentle and typical symtom paitents.
Notwithstanding accomplish more accuary we can likewise use government schools, universities and shut zone places, for example, hotels, multi-corp. Structures for all the cities.