taxi

Winning entry to the Kaggle taxi competition
git clone https://esimon.eu/repos/taxi.git
Log | Files | Refs | README

maps_old.py (832B)


      1 import matplotlib.pyplot as plt
      2 import numpy
      3 import cPickle
      4 import scipy
      5 
      6 print "Loading data..."
      7 with open("../train_normal.pkl") as f: normal = cPickle.load(f)
      8 
      9 print "Extracting x and y"
     10 xes = [c[0] for l in normal for c in l[-1]]
     11 yes = [c[1] for l in normal for c in l[-1]]
     12 
     13 xrg = [-8.75, -8.55]
     14 yrg = [41.05, 41.25]
     15 
     16 print "Doing 1d histogram"
     17 #plt.clf(); plt.hist(xes, bins=1000, range=xrg); plt.savefig("xhist.pdf")
     18 #plt.clf(); plt.hist(yes, bins=1000, range=yrg); plt.savefig("yhist.pdf")
     19 
     20 print "Doing 2d histogram"
     21 #plt.clf(); plt.hist2d(xes, yes, bins=500, range=[xrg, yrg]); plt.savefig("xymap.pdf")
     22 
     23 hist, xx, yy = numpy.histogram2d(xes, yes, bins=2000, range=[xrg, yrg])
     24 
     25 import ipdb; ipdb.set_trace()
     26 
     27 plt.clf(); plt.imshow(numpy.log(hist)); plt.savefig("xyhmap.pdf")
     28 
     29 scipy.misc.imsave("xymap.png", numpy.log(hist))