Skip to content

Commit d59ac0a

Browse files
committed
docs: added ml notes
1 parent 42db7bf commit d59ac0a

33 files changed

+6351
-56
lines changed

DataAnalysis/Visualization/Intro/CT.html

Lines changed: 1311 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
3+
# https://www.youtube.com/watch?v=xPk7S-Eb4J4
4+
5+
# imports
6+
import pandas as pd
7+
import folium
8+
9+
# this makes it so that you see all the columns in a pd.show()
10+
pd.set_option('display.max_columns', None)
11+
12+
# load the data
13+
# https://github.com/practicalaifab/folium/blob/codespace-practicalaifab-probable-space-umbrella-r4476xv556q356qr/data/hospitals.csv
14+
# https://raw.githubusercontent.com/practicalaifab/folium/codespace-practicalaifab-probable-space-umbrella-r4476xv556q356qr/data/hospitals.csv
15+
df = pd.read_csv("https://raw.githubusercontent.com/practicalaifab/folium/codespace-practicalaifab-probable-space-umbrella-r4476xv556q356qr/data/hospitals.csv")
16+
17+
# get list of hoospitals
18+
19+
# filter for only MA hospitals
20+
ma = df[df['STATE'] == 'MA']
21+
ma = ma[['NAME', 'LATITUDE', 'LONGITUDE']]
22+
23+
# display
24+
# map.head()
25+
26+
27+
# get the mean lat/lon for the map crteation
28+
lat_mean = ma['LATITUDE'].mean()
29+
lon_mean = ma['LONGITUDE'].mean()
30+
31+
# create folium map
32+
map = folium.Map(location=[lat_mean, lon_mean], zoom_start=15)
33+
34+
# need to creat list of hospitals to put them on the map
35+
list_hosp = ma.values.tolist()
36+
37+
# loop over list
38+
for index in list_hosp:
39+
# add to map
40+
map.add_child(folium.Marker(location=[index[1], index[2]], popup=index[0], icon=folium.Icon(color='green')))
41+
42+
43+
# save map as html file
44+
map.save("ma.html")
45+
46+
47+
# df.show()
48+
49+
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
3+
# https://www.youtube.com/watch?v=xPk7S-Eb4J4
4+
5+
# imports
6+
import pandas as pd
7+
import folium
8+
9+
# this makes it so that you see all the columns in a pd.show()
10+
pd.set_option('display.max_columns', None)
11+
12+
# load the data
13+
# https://github.com/practicalaifab/folium/blob/codespace-practicalaifab-probable-space-umbrella-r4476xv556q356qr/data/hospitals.csv
14+
# https://raw.githubusercontent.com/practicalaifab/folium/codespace-practicalaifab-probable-space-umbrella-r4476xv556q356qr/data/hospitals.csv
15+
df = pd.read_csv("https://raw.githubusercontent.com/practicalaifab/folium/codespace-practicalaifab-probable-space-umbrella-r4476xv556q356qr/data/hospitals.csv")
16+
17+
18+
# function
19+
def choose_state(data, state_option):
20+
state = data[data['STATE'] == state_option]
21+
state = state[['NAME', 'LATITUDE', 'LONGITUDE']]
22+
23+
# return
24+
return state
25+
26+
def plot_state(data):
27+
# get lon/lat
28+
lat_mean = data['LATITUDE'].mean()
29+
lon_mean = data['LONGITUDE'].mean()
30+
31+
# get the map
32+
map = folium.Map(location=[lat_mean, lon_mean], zoom_start=15)
33+
34+
# populate the map
35+
list_hosp = data.values.tolist()
36+
for index in list_hosp:
37+
# add to map
38+
map.add_child(folium.Marker(location=[index[1], index[2]], popup=index[0], icon=folium.Icon(color='green')))
39+
40+
# return
41+
return map
42+
43+
if __name__ == "__main__":
44+
state = 'CT'
45+
# get the state data
46+
df_state = choose_state(df, state)
47+
48+
print(df_state.info())
49+
50+
# get the map
51+
map = plot_state(df_state)
52+
53+
# save map as html file
54+
map.save("{}.html".format(state))
55+
56+
57+
58+
# # get list of hoospitals
59+
60+
# # filter for only MA hospitals
61+
# ma = df[df['STATE'] == 'MA']
62+
# ma = ma[['NAME', 'LATITUDE', 'LONGITUDE']]
63+
64+
# # display
65+
# # map.head()
66+
67+
68+
# # get the mean lat/lon for the map crteation
69+
# lat_mean = ma['LATITUDE'].mean()
70+
# lon_mean = ma['LONGITUDE'].mean()
71+
72+
# # create folium map
73+
# map = folium.Map(location=[lat_mean, lon_mean], zoom_start=15)
74+
75+
# # need to creat list of hospitals to put them on the map
76+
# list_hosp = ma.values.tolist()
77+
78+
# # loop over list
79+
# for index in list_hosp:
80+
# # add to map
81+
# map.add_child(folium.Marker(location=[index[1], index[2]], popup=index[0], icon=folium.Icon(color='green')))
82+
83+
84+
# # save map as html file
85+
# map.save("ma.html")
86+
87+
88+
# df.show()
89+
90+

0 commit comments

Comments
 (0)