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_bigger.py (1357B)


      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 = 10     # 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(21):
     18     time_tgtcls.append(time_tgtcls[-1] + time_tgtcls[-2])
     19 
     20 dim_embeddings = [
     21     ('origin_call', data.origin_call_size, 15),
     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 = [5000]
     33 
     34 # Destination prediction part
     35 dim_hidden_dest = [1000]
     36 dim_output_dest = dest_tgtcls.shape[0]
     37 
     38 # Time prediction part
     39 dim_hidden_time = [500]
     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.01)
     46 mlp_weights_init = IsotropicGaussian(0.1)
     47 mlp_biases_init = Constant(0.01)
     48 
     49 # use adadelta, so no learning_rate or momentum
     50 batch_size = 200
     51 
     52 max_splits = 100