Last active
December 15, 2015 16:19
-
-
Save Akramz/f71bd92700e85e8257e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import numpy as np | |
| import zipfile | |
| import matplotlib.pyplot as pl | |
| import seaborn as sns | |
| from sys import exit | |
| mapdata = np.loadtxt("../data/sf_map_copyright_openstreetmap_contributors.txt") | |
| asp = mapdata.shape[0] * 1.0 / mapdata.shape[1] | |
| lon_lat_box = (-122.5247, -122.3366, 37.699, 37.8299) | |
| clipsize = [[-122.5247, -122.3366],[ 37.699, 37.8299]] | |
| train = pd.read_csv('../data/train.csv', sep=',') | |
| train['Xok'] = train[train.X<-121].X | |
| train['Yok'] = train[train.Y<40].Y | |
| train = train.dropna() # drop any row w missing values | |
| g= sns.FacetGrid(train, col="Category", col_wrap=2, size=4, aspect=1/asp) | |
| for ax in g.axes: | |
| ax.imshow(mapdata, cmap=pl.get_cmap('gray'), | |
| extent=lon_lat_box, | |
| aspect=asp) | |
| g.map(sns.kdeplot, "Xok", "Yok", clip=clipsize, cmap="Blues_d") | |
| pl.savefig('map_categories.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment