taxi

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

destmaps.py (957B)


      1 import matplotlib.pyplot as plt
      2 import numpy
      3 import cPickle
      4 import scipy.misc
      5 
      6 print "Loading data..."
      7 with open("train.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 xes = [l[-1][-1][0] for l in normal if len(l[-1]) > 0]
     13 yes = [l[-1][-1][1] for l in normal if len(l[-1]) > 0]
     14 
     15 xrg = [-8.80, -8.50]
     16 yrg = [41.00, 41.30]
     17 
     18 #print "Doing 1d x histogram"
     19 #plt.clf(); plt.hist(xes, bins=2000, range=xrg); plt.savefig("xhist_dest.pdf")
     20 #print "Doing 1d y histogram"
     21 #plt.clf(); plt.hist(yes, bins=2000, range=yrg); plt.savefig("yhist_dest.pdf")
     22 
     23 print "Doing 2d histogram"
     24 hist, xx, yy = numpy.histogram2d(xes, yes, bins=4000, range=[xrg, yrg])
     25 
     26 # import ipdb; ipdb.set_trace()
     27 
     28 print "Imshow"
     29 plt.clf(); plt.imshow(numpy.log(hist)); plt.savefig("xyhmap_dest_x.png", dpi=600)
     30 
     31 print "Imsave"
     32 scipy.misc.imsave("xymap_dest_2_x.png", numpy.log(hist + 1))