taxi

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

joint_mlp_tgtcls_111_cswdtx.py (1344B)


      1 import os
      2 import cPickle
      3 
      4 from blocks.initialization import IsotropicGaussian, Constant
      5 
      6 import data
      7 from model.joint_mlp_tgtcls import Model, Stream
      8 
      9 
     10 n_begin_end_pts = 5     # how many points we consider at the beginning and end of the known trajectory
     11 
     12 with open(os.path.join(data.path, 'arrival-clusters.pkl')) as f:
     13     dest_tgtcls = cPickle.load(f)
     14 
     15 # generate target classes for time prediction as a Fibonacci sequence
     16 time_tgtcls = [1, 2]
     17 for i in range(22):
     18     time_tgtcls.append(time_tgtcls[-1] + time_tgtcls[-2])
     19 
     20 dim_embeddings = [
     21     ('origin_call', data.origin_call_size, 10),
     22     ('origin_stand', data.stands_size, 10),
     23     ('week_of_year', 52, 10),
     24     ('day_of_week', 7, 10),
     25     ('qhour_of_day', 24 * 4, 10),
     26     ('day_type', 3, 10),
     27     ('taxi_id', 448, 10),
     28 ]
     29 
     30 # Common network part
     31 dim_input = n_begin_end_pts * 2 * 2 + sum(x for (_, _, x) in dim_embeddings)
     32 dim_hidden = [500]
     33 
     34 # Destination prediction part
     35 dim_hidden_dest = [100]
     36 dim_output_dest = len(dest_tgtcls)
     37 
     38 # Time prediction part
     39 dim_hidden_time = [100]
     40 dim_output_time = len(time_tgtcls)
     41 
     42 # Cost ratio between distance cost and time cost
     43 time_cost_factor = 4
     44 
     45 embed_weights_init = IsotropicGaussian(0.001)
     46 mlp_weights_init = IsotropicGaussian(0.01)
     47 mlp_biases_init = Constant(0.001)
     48 
     49 learning_rate = 0.0001
     50 momentum = 0.99
     51 batch_size = 200
     52 
     53 max_splits = 100