taxi

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

make_reference_output.py (849B)


      1 #!/usr/bin/env python
      2 
      3 import csv
      4 import os
      5 
      6 from fuel.iterator import DataIterator
      7 from fuel.schemes import SequentialExampleScheme
      8 from fuel.streams import DataStream
      9 
     10 from data.hdf5 import TaxiDataset
     11 import data
     12 
     13 dest_outfile = open(os.path.join(data.path, 'test_answer.csv'), 'w')
     14 dest_outcsv = csv.writer(dest_outfile)
     15 dest_outcsv.writerow(["TRIP_ID", "LATITUDE", "LONGITUDE"])
     16 
     17 dataset = TaxiDataset('test', 'tvt.hdf5',
     18                      sources=('trip_id', 'longitude', 'latitude',
     19                               'destination_longitude', 'destination_latitude'))
     20 it = DataIterator(DataStream(dataset), iter(xrange(dataset.num_examples)), as_dict=True)
     21 
     22 for v in it:
     23     # print v
     24     dest_outcsv.writerow([v['trip_id'], v['destination_latitude'],
     25                                         v['destination_longitude']])
     26 
     27 dest_outfile.close()
     28