Improve profit for taxi drivers.

Train the Machine Learning Algorithm.

Import libraries, basic setup


In [1]:
import pandas as pd
import numpy as np

import seaborn as sns
sns.set(color_codes=True)

from operator import itemgetter
from datetime import timedelta

import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

import geocoder

import matplotlib

%matplotlib inline

DATA_DIR = "../../taxi-data/"

Import helper functions used to maniuplate and train data.


In [2]:
from helper_functions import *
from pre_process import *
from ml_helper_functions import *

Testing

Read training data


In [5]:
TRAINING_DIR = "../taxi-data/training/"

taxi_distance = pd.read_csv(TRAINING_DIR + "taxi_distance.csv", index_col = 0)
good_positions = pd.read_csv(TRAINING_DIR + "good_positions.csv", index_col=0)
expected_profit = pd.read_csv(TRAINING_DIR + "expected_profit.csv", index_col=0)

expected_profit_for_good_locations = expected_profit[expected_profit.index.isin(good_positions.index)]

Read testing data


In [6]:
TESTING_DIR = "../taxi-data/testing/"

rides = pd.read_csv(TESTING_DIR + "rides.csv", index_col= 0)
rides.loc[:,'pickup_datetime'] = pd.to_datetime(rides.pickup_datetime)
rides.loc[:,'dropoff_datetime'] = pd.to_datetime(rides.dropoff_datetime)
rides['hour'] = rides.pickup_datetime.apply(lambda z: z.hour)

NUM_DAYS_IN_DATA = len(list(set(rides.pickup_datetime.apply(lambda z: z.day).values)))

Simulate random and informed strategy


In [7]:
#Parameters for the simulations

starting_pos = "(-73.88, 40.75)" #Jackson Heights
starting_pos = "(-73.90, 40.92)" #Random pos
starting_pos = "(-73.98, 40.75)" #This is 1700 Broadway, near south central park.
starting_pos = "(-73.99, 40.74)" #times_square
starting_hour = 9
max_trip_length_seconds = 60*60

Profit from random trajectory


In [8]:
hourly_wage_from_random_trajectory = []
random_strategy_paths = []

while len(hourly_wage_from_random_trajectory) < 100:
    print len(hourly_wage_from_random_trajectory),
    try:
        z, path = simulate_naive_trajectory(rides, starting_pos, starting_hour, max_trip_length_seconds)
        hourly_wage_from_random_trajectory.append(z)
        path = [coord_from_string(pt) for pt in path]
        path = [[z[1], z[0]] for z in path]
        random_strategy_paths.append(path)
    except Exception:
        pass
sns.distplot(hourly_wage_from_random_trajectory)
print "\nAverage hourly wage from random strategy = %.3f"%np.mean(hourly_wage_from_random_trajectory)


0 - - - - - Hourly salary: 30.33
1 - - - Hourly salary: 42.42
2 - - - - Hourly salary: 31.00
3 - - - - Hourly salary: 36.35
4 - - - Hourly salary: 40.33
5 - - - Hourly salary: 51.43
6 - - - - - Hourly salary: 31.32
7 - - - - Hourly salary: 31.49
8 - - - - Hourly salary: 39.78
9 - - - Hourly salary: 28.35
10 - - - - Hourly salary: 31.45
11 - - - - - Hourly salary: 37.78
12 - - - Hourly salary: 37.13
13 - - - - Hourly salary: 30.54
14 - - - - - Hourly salary: 35.26
15 - - - - - - Hourly salary: 34.13
16 - - - Hourly salary: 36.83
17 - - - - - - Hourly salary: 37.42
18 - - - - - Hourly salary: 32.84
19 - - - - - Hourly salary: 38.30
20 - - - - Hourly salary: 30.70
21 - - - - Hourly salary: 44.45
22 - - - - - Hourly salary: 26.93
23 - - - - - - Hourly salary: 31.86
24 - - - - Hourly salary: 35.13
25 - - - Hourly salary: 33.61
26 - - - - Hourly salary: 28.91
27 - - - Hourly salary: 32.16
28 - - - - Hourly salary: 45.88
29 - - - Hourly salary: 40.39
30 - - - Hourly salary: 33.60
31 - - - - Hourly salary: 28.17
32 - - - - - Hourly salary: 31.09
33 - - - - - Hourly salary: 30.89
34 - - - - - Hourly salary: 39.36
35 - - Hourly salary: 67.90
36 - - - Hourly salary: 28.86
37 - - - - Hourly salary: 39.85
38 - - - - Hourly salary: 31.06
39 - - - - - - - Hourly salary: 39.93
40 - - - Hourly salary: 29.44
41 - - - - - Hourly salary: 37.56
42 - - - - Hourly salary: 39.12
43 - - Hourly salary: 27.30
44 - - - Hourly salary: 35.16
45 - - - - Hourly salary: 33.20
46 - - - - - Hourly salary: 41.28
47 - - - - - Hourly salary: 32.25
48 - - - - Hourly salary: 30.64
49 - - - - Hourly salary: 34.46
50 - - - - - Hourly salary: 35.87
51 - - - Hourly salary: 32.83
52 - - Hourly salary: 42.21
53 - - - - Hourly salary: 35.13
54 - - - Hourly salary: 39.94
55 - - - Hourly salary: 35.18
56 - - - - Hourly salary: 34.09
57 - - - - - Hourly salary: 31.34
58 - - - Hourly salary: 41.74
59 - - Hourly salary: 44.42
60 - - - - Hourly salary: 36.44
61 - - - - - - Hourly salary: 37.16
62 - - - Hourly salary: 28.64
63 - - - - Hourly salary: 31.71
64 - - - - Hourly salary: 31.04
65 - - - - Hourly salary: 43.46
66 - - - - Hourly salary: 44.87
67 - - - - Hourly salary: 49.40
68 - - - - Hourly salary: 30.42
69 - - - - Hourly salary: 25.19
70 - - - - - Hourly salary: 35.28
71 - - - - Hourly salary: 41.30
72 - - - - Hourly salary: 32.48
73 - - - - Hourly salary: 33.76
74 - - - - Hourly salary: 33.16
75 - - - - - Hourly salary: 36.38
76 - - - - Hourly salary: 31.51
77 - - - Hourly salary: 28.41
78 - - - Hourly salary: 34.63
79 - - - - - - Hourly salary: 35.95
80 - - - - Hourly salary: 33.47
81 - - - - - Hourly salary: 39.12
82 - - - - - Hourly salary: 30.88
83 - - - - - Hourly salary: 31.50
84 - - - - Hourly salary: 33.16
85 - - - - Hourly salary: 26.29
86 - - - Hourly salary: 36.13
87 - - - - Hourly salary: 33.38
88 - - - - - Hourly salary: 32.08
89 - - - - Hourly salary: 33.77
90 - - - Hourly salary: 38.65
91 - - - - Hourly salary: 51.77
92 - - - - Hourly salary: 33.05
93 - - - Hourly salary: 51.30
94 - - - - Hourly salary: 32.48
95 - - - - Hourly salary: 32.27
96 - - - - - Hourly salary: 26.45
97 - - - Hourly salary: 51.98
98 - - - - Hourly salary: 37.25
99 - - - - Hourly salary: 43.72

Average hourly wage from random strategy = 35.783

Profit form informed strategy


In [9]:
print "Simulating informed strategy."

hourly_wage_from_informed_strategy = []
informed_strategy_paths = []

while len(hourly_wage_from_informed_strategy) < 100:
    print len(hourly_wage_from_informed_strategy),
    try:
        z, path = simulate_informed_trajectory(rides, starting_pos, starting_hour, max_trip_length_seconds)
        hourly_wage_from_informed_strategy.append(z)
        path = [coord_from_string(pt) for pt in path]
        path = [[z[1], z[0]] for z in path]
        informed_strategy_paths.append(path)
        
    except Exception:
        pass
    
sns.distplot(hourly_wage_from_informed_strategy)
print "\nAverage hourly wage from informed strategy = %.3f"%np.mean(hourly_wage_from_informed_strategy)


Simulating informed strategy.
0 - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: Delta Departures Rd, East Elmhurst, NY 11371, USA
	Trying better position: 3.00 minutes lost.
- 	expected_profit do_nothing=8.88, move=49.88
	Better Position 
	Swapping: 237-299 E 26th St, New York, NY 10010, USA
	With: 65-45 Yellowstone Blvd, Forest Hills, NY 11375, USA
	Trying better position: 6.00 minutes lost.
- 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 48 Pinehurst Ave, New York, NY 10033, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 41.19
1 - - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 9711-9725 64th Ave, Rego Park, NY 11374, USA
	Trying better position: 4.00 minutes lost.
- - 	expected_profit do_nothing=8.95, move=49.88
	Better Position 
	Swapping: 333 E 43rd St, New York, NY 10017, USA
	With: 90-10 Grand Central Pkwy, East Elmhurst, NY 11369, USA
	Trying better position: 20.00 minutes lost.
Hourly salary: 33.75
2 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 14 Maple St, Brooklyn, NY 11225, USA
	Trying better position: 7.00 minutes lost.
- 	expected_profit do_nothing=10.39, move=49.88
	Better Position 
	Swapping: 1405 Lincoln Pl, Brooklyn, NY 11213, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 16.32 minutes lost.
- Hourly salary: 46.55
3 - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 90-10 Grand Central Pkwy, East Elmhurst, NY 11369, USA
	Trying better position: 18.00 minutes lost.
- 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 100-0-100-98 69th Ave, Forest Hills, NY 11375, USA
	Trying better position: 4.00 minutes lost.
Hourly salary: 38.53
4 - - - Hourly salary: 61.11
5 - - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 21-26-21-28 80th St, East Elmhurst, NY 11370, USA
	Trying better position: 18.00 minutes lost.
- Hourly salary: 33.24
6 - - - - Hourly salary: 30.99
7 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 4.00 minutes lost.
- - Hourly salary: 45.95
8 - 	expected_profit do_nothing=9.86, move=49.88
	Better Position 
	Swapping: 521 W 57th St, New York, NY 10019, USA
	With: 65-45 Yellowstone Blvd, Forest Hills, NY 11375, USA
	Trying better position: 9.00 minutes lost.
- 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 100-0-100-98 69th Ave, Forest Hills, NY 11375, USA
	Trying better position: 4.00 minutes lost.
Hourly salary: 34.67
9 - - - - Hourly salary: 31.01
10 - - - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 18.00 minutes lost.
Hourly salary: 31.53
11 - - - 	expected_profit do_nothing=8.24, move=49.88
	Better Position 
	Swapping: 341 W 45th St, New York, NY 10036, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 8.00 minutes lost.
- Hourly salary: 38.53
12 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 7.00 minutes lost.
- 	expected_profit do_nothing=11.23, move=49.88
	Better Position 
	Swapping: 1720 2nd Ave, New York, NY 10128, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 5.00 minutes lost.
Hourly salary: 51.78
13 - - - - Hourly salary: 36.15
14 - - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 18.00 minutes lost.
- 	expected_profit do_nothing=9.46, move=49.88
	Better Position 
	Swapping: 17 E 84th St, New York, NY 10028, USA
	With: 48 Pinehurst Ave, New York, NY 10033, USA
	Trying better position: 3.00 minutes lost.
Hourly salary: 39.07
15 - - - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 3.00 minutes lost.
Hourly salary: 35.35
16 - - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: Brooklyn Queens Expy & I-278 & Columbia St, Brooklyn, NY 11201, USA
	Trying better position: 4.00 minutes lost.
- Hourly salary: 38.64
17 - 	expected_profit do_nothing=10.02, move=49.88
	Better Position 
	Swapping: 51 Astor Pl, New York, NY 10003, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 12.03 minutes lost.
- 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 21-26-21-28 80th St, East Elmhurst, NY 11370, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 56.74
18 - - - Hourly salary: 31.04
19 - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 18.00 minutes lost.
- 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: Pier 2 Promenade, Brooklyn, NY 11201, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 39.39
20 - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 18.00 minutes lost.
- 	expected_profit do_nothing=12.95, move=49.88
	Better Position 
	Swapping: 95-52 115th St, Jamaica, NY 11419, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 13.00 minutes lost.
Hourly salary: 28.08
21 - - - Hourly salary: 33.43
22 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 4.00 minutes lost.
- 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: Pier 2 Promenade, Brooklyn, NY 11201, USA
	Trying better position: 7.00 minutes lost.
- Hourly salary: 61.48
23 - - - - - Hourly salary: 28.86
24 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: Brooklyn Queens Expy & I-278 & Columbia St, Brooklyn, NY 11201, USA
	Trying better position: 4.00 minutes lost.
- - - 	expected_profit do_nothing=8.95, move=49.88
	Better Position 
	Swapping: 333 E 43rd St, New York, NY 10017, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 20.00 minutes lost.
Hourly salary: 33.49
25 - - 	expected_profit do_nothing=9.46, move=49.88
	Better Position 
	Swapping: 17 E 84th St, New York, NY 10028, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 3.00 minutes lost.
- Hourly salary: 48.54
26 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 14 Maple St, Brooklyn, NY 11225, USA
	Trying better position: 7.00 minutes lost.
- - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: Delta Departures Rd, East Elmhurst, NY 11371, USA
	Trying better position: 18.00 minutes lost.
Hourly salary: 35.59
27 - - 	expected_profit do_nothing=8.95, move=49.88
	Better Position 
	Swapping: 333 E 43rd St, New York, NY 10017, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 20.00 minutes lost.
- Hourly salary: 38.22
28 - - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 4.00 minutes lost.
- Hourly salary: 34.86
29 - - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 18.00 minutes lost.
- Hourly salary: 42.82
30 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 9711-9725 64th Ave, Rego Park, NY 11374, USA
	Trying better position: 4.00 minutes lost.
- - 	expected_profit do_nothing=8.88, move=49.88
	Better Position 
	Swapping: 237-299 E 26th St, New York, NY 10010, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 6.00 minutes lost.
- Hourly salary: 39.87
31 - - - - 	expected_profit do_nothing=11.23, move=49.88
	Better Position 
	Swapping: 2065 1st Avenue, New York, NY 10029, USA
	With: Delta Departures Rd, East Elmhurst, NY 11371, USA
	Trying better position: 7.50 minutes lost.
Hourly salary: 33.40
32 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: Pier 2 Promenade, Brooklyn, NY 11201, USA
	Trying better position: 4.00 minutes lost.
- - - - Hourly salary: 38.79
33 - - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: Delta Departures Rd, East Elmhurst, NY 11371, USA
	Trying better position: 7.00 minutes lost.
- 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: 64 Boerum Pl, Brooklyn, NY 11201, USA
	Trying better position: 3.00 minutes lost.
Hourly salary: 47.54
34 - - 	expected_profit do_nothing=8.95, move=49.88
	Better Position 
	Swapping: 333 E 43rd St, New York, NY 10017, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 20.00 minutes lost.
Hourly salary: 30.00
35 - - - Hourly salary: 31.61
36 - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: 268 10th St, Brooklyn, NY 11215, USA
	Trying better position: 3.00 minutes lost.
- - - Hourly salary: 59.57
37 - - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 7.00 minutes lost.
- 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 18.00 minutes lost.
Hourly salary: 32.09
38 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: Pier 2 Promenade, Brooklyn, NY 11201, USA
	Trying better position: 7.00 minutes lost.
- - - - - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 9711-9725 64th Ave, Rego Park, NY 11374, USA
	Trying better position: 4.00 minutes lost.
Hourly salary: 35.53
39 - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 18.00 minutes lost.
- 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: Delta Departures Rd, East Elmhurst, NY 11371, USA
	Trying better position: 18.00 minutes lost.
Hourly salary: 20.56
40 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 268 10th St, Brooklyn, NY 11215, USA
	Trying better position: 4.00 minutes lost.
- - 	expected_profit do_nothing=9.46, move=49.88
	Better Position 
	Swapping: 17 E 84th St, New York, NY 10028, USA
	With: 48 Pinehurst Ave, New York, NY 10033, USA
	Trying better position: 3.00 minutes lost.
Hourly salary: 47.04
41 - 	expected_profit do_nothing=9.46, move=49.88
	Better Position 
	Swapping: 17 E 84th St, New York, NY 10028, USA
	With: Delta Departures Rd, East Elmhurst, NY 11371, USA
	Trying better position: 3.00 minutes lost.
- 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 38.50
42 - 	expected_profit do_nothing=10.02, move=49.88
	Better Position 
	Swapping: 51 Astor Pl, New York, NY 10003, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 12.03 minutes lost.
- Penalty!
42 - - - - Hourly salary: 30.65
43 - - - Hourly salary: 28.30
44 - - - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 48 Pinehurst Ave, New York, NY 10033, USA
	Trying better position: 7.00 minutes lost.
- Hourly salary: 30.56
45 - - - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 18.00 minutes lost.
- 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 21-26-21-28 80th St, East Elmhurst, NY 11370, USA
	Trying better position: 18.00 minutes lost.
Hourly salary: 35.35
46 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 9711-9725 64th Ave, Rego Park, NY 11374, USA
	Trying better position: 7.00 minutes lost.
- - Hourly salary: 44.65
47 - 	expected_profit do_nothing=10.02, move=49.88
	Better Position 
	Swapping: 51 Astor Pl, New York, NY 10003, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 12.03 minutes lost.
- 	expected_profit do_nothing=7.29, move=49.88
	Better Position 
	Swapping: 79 E 51st St, Brooklyn, NY 11203, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 7.67 minutes lost.
- Hourly salary: 41.06
48 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 601 Bergen St, Brooklyn, NY 11238, USA
	Trying better position: 7.00 minutes lost.
- - - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 18.00 minutes lost.
Hourly salary: 30.89
49 - - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 18.00 minutes lost.
- 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 90-10 Grand Central Pkwy, East Elmhurst, NY 11369, USA
	Trying better position: 18.00 minutes lost.
Hourly salary: 29.15
50 - - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 18.00 minutes lost.
- Hourly salary: 24.41
51 - - - - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 100-0-100-98 69th Ave, Forest Hills, NY 11375, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 34.11
52 - 	expected_profit do_nothing=8.88, move=49.88
	Better Position 
	Swapping: 237-299 E 26th St, New York, NY 10010, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 6.00 minutes lost.
- 	expected_profit do_nothing=8.24, move=49.88
	Better Position 
	Swapping: 341 W 45th St, New York, NY 10036, USA
	With: 14 Maple St, Brooklyn, NY 11225, USA
	Trying better position: 8.00 minutes lost.
Hourly salary: 15.67
53 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 7.00 minutes lost.
- - Hourly salary: 41.43
54 - - - - 	expected_profit do_nothing=8.95, move=49.88
	Better Position 
	Swapping: 333 E 43rd St, New York, NY 10017, USA
	With: Delta Departures Rd, East Elmhurst, NY 11371, USA
	Trying better position: 20.00 minutes lost.
Hourly salary: 47.79
55 - - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 14 Maple St, Brooklyn, NY 11225, USA
	Trying better position: 7.00 minutes lost.
- 	expected_profit do_nothing=10.39, move=49.88
	Better Position 
	Swapping: 1405 Lincoln Pl, Brooklyn, NY 11213, USA
	With: 21-26-21-28 80th St, East Elmhurst, NY 11370, USA
	Trying better position: 16.32 minutes lost.
Hourly salary: 22.23
56 - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 3.00 minutes lost.
- 	expected_profit do_nothing=8.24, move=49.88
	Better Position 
	Swapping: 341 W 45th St, New York, NY 10036, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 8.00 minutes lost.
Hourly salary: 34.07
57 - 	expected_profit do_nothing=9.46, move=49.88
	Better Position 
	Swapping: 17 E 84th St, New York, NY 10028, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 3.00 minutes lost.
- 	expected_profit do_nothing=8.24, move=49.88
	Better Position 
	Swapping: 341 W 45th St, New York, NY 10036, USA
	With: 21-26-21-28 80th St, East Elmhurst, NY 11370, USA
	Trying better position: 8.00 minutes lost.
- Hourly salary: 54.85
58 - 	expected_profit do_nothing=8.24, move=49.88
	Better Position 
	Swapping: 341 W 45th St, New York, NY 10036, USA
	With: 48 Pinehurst Ave, New York, NY 10033, USA
	Trying better position: 8.00 minutes lost.
- - Hourly salary: 41.20
59 - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: 3962 Broadway, New York, NY 10032, USA
	Trying better position: 3.00 minutes lost.
- - - 	expected_profit do_nothing=8.24, move=49.88
	Better Position 
	Swapping: 341 W 45th St, New York, NY 10036, USA
	With: 601 Bergen St, Brooklyn, NY 11238, USA
	Trying better position: 8.00 minutes lost.
Hourly salary: 43.40
60 - - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 3.00 minutes lost.
- Penalty!
60 - - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 3.00 minutes lost.
- Hourly salary: 47.44
61 - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: Delta Departures Rd, East Elmhurst, NY 11371, USA
	Trying better position: 18.00 minutes lost.
- Hourly salary: 33.31
62 - - - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: 65-45 Yellowstone Blvd, Forest Hills, NY 11375, USA
	Trying better position: 3.00 minutes lost.
- Hourly salary: 37.45
63 - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 90-10 Grand Central Pkwy, East Elmhurst, NY 11369, USA
	Trying better position: 18.00 minutes lost.
- 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 14 Maple St, Brooklyn, NY 11225, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 37.81
64 - - - 	expected_profit do_nothing=8.24, move=49.88
	Better Position 
	Swapping: 341 W 45th St, New York, NY 10036, USA
	With: 601 Bergen St, Brooklyn, NY 11238, USA
	Trying better position: 8.00 minutes lost.
- Hourly salary: 30.25
65 - - - 	expected_profit do_nothing=8.88, move=49.88
	Better Position 
	Swapping: 237-299 E 26th St, New York, NY 10010, USA
	With: 14 Maple St, Brooklyn, NY 11225, USA
	Trying better position: 6.00 minutes lost.
- 	expected_profit do_nothing=10.39, move=49.88
	Better Position 
	Swapping: 1405 Lincoln Pl, Brooklyn, NY 11213, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 16.32 minutes lost.
Hourly salary: 31.58
66 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 14 Maple St, Brooklyn, NY 11225, USA
	Trying better position: 7.00 minutes lost.
- 	expected_profit do_nothing=10.39, move=49.88
	Better Position 
	Swapping: 1405 Lincoln Pl, Brooklyn, NY 11213, USA
	With: 90-10 Grand Central Pkwy, East Elmhurst, NY 11369, USA
	Trying better position: 16.32 minutes lost.
- Hourly salary: 42.10
67 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 7.00 minutes lost.
- 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 48 Pinehurst Ave, New York, NY 10033, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 34.85
68 - - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 90-10 Grand Central Pkwy, East Elmhurst, NY 11369, USA
	Trying better position: 4.00 minutes lost.
- 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: Delta Departures Rd, East Elmhurst, NY 11371, USA
	Trying better position: 4.00 minutes lost.
- 	expected_profit do_nothing=8.24, move=49.88
	Better Position 
	Swapping: 341 W 45th St, New York, NY 10036, USA
	With: 100-0-100-98 69th Ave, Forest Hills, NY 11375, USA
	Trying better position: 8.00 minutes lost.
Hourly salary: 40.71
69 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: Delta Departures Rd, East Elmhurst, NY 11371, USA
	Trying better position: 7.00 minutes lost.
- Hourly salary: 44.99
70 - - - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 3.00 minutes lost.
- 	expected_profit do_nothing=5.89, move=49.88
	Better Position 
	Swapping: 3379 Bedford Ave, Brooklyn, NY 11210, USA
	With: Williamsburg Bridge & Havemeyer St & S 5th St, Brooklyn, NY 11211, USA
	Trying better position: 5.40 minutes lost.
- 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 4.00 minutes lost.
Hourly salary: 50.03
71 - - - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 18.00 minutes lost.
Hourly salary: 26.47
72 - - Hourly salary: 30.92
73 - - - Hourly salary: 44.18
74 - 	expected_profit do_nothing=8.88, move=49.88
	Better Position 
	Swapping: 237-299 E 26th St, New York, NY 10010, USA
	With: 48 Pinehurst Ave, New York, NY 10033, USA
	Trying better position: 6.00 minutes lost.
- - - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: 64 Boerum Pl, Brooklyn, NY 11201, USA
	Trying better position: 3.00 minutes lost.
Hourly salary: 38.42
75 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 7.00 minutes lost.
- - 	expected_profit do_nothing=8.95, move=49.88
	Better Position 
	Swapping: 333 E 43rd St, New York, NY 10017, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 20.00 minutes lost.
Hourly salary: 45.24
76 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 48 Pinehurst Ave, New York, NY 10033, USA
	Trying better position: 7.00 minutes lost.
- - Hourly salary: 32.55
77 - 	expected_profit do_nothing=9.86, move=49.88
	Better Position 
	Swapping: 521 W 57th St, New York, NY 10019, USA
	With: 65-45 Yellowstone Blvd, Forest Hills, NY 11375, USA
	Trying better position: 9.00 minutes lost.
- Hourly salary: 40.35
78 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 3962 Broadway, New York, NY 10032, USA
	Trying better position: 4.00 minutes lost.
- - 	expected_profit do_nothing=8.24, move=49.88
	Better Position 
	Swapping: 341 W 45th St, New York, NY 10036, USA
	With: 48 Pinehurst Ave, New York, NY 10033, USA
	Trying better position: 8.00 minutes lost.
- 	expected_profit do_nothing=9.46, move=49.88
	Better Position 
	Swapping: 17 E 84th St, New York, NY 10028, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 3.00 minutes lost.
Hourly salary: 41.02
79 - - - - Hourly salary: 28.57
80 - - - Hourly salary: 65.11
81 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 601 Bergen St, Brooklyn, NY 11238, USA
	Trying better position: 7.00 minutes lost.
- Hourly salary: 32.63
82 - - 	expected_profit do_nothing=9.86, move=49.88
	Better Position 
	Swapping: 521 W 57th St, New York, NY 10019, USA
	With: 65-45 Yellowstone Blvd, Forest Hills, NY 11375, USA
	Trying better position: 9.00 minutes lost.
- 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 3962 Broadway, New York, NY 10032, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 33.24
83 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 601 Bergen St, Brooklyn, NY 11238, USA
	Trying better position: 4.00 minutes lost.
- - 	expected_profit do_nothing=10.39, move=49.88
	Better Position 
	Swapping: 1405 Lincoln Pl, Brooklyn, NY 11213, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 16.32 minutes lost.
Hourly salary: 26.14
84 - 	expected_profit do_nothing=8.95, move=49.88
	Better Position 
	Swapping: 333 E 43rd St, New York, NY 10017, USA
	With: 21-26-21-28 80th St, East Elmhurst, NY 11370, USA
	Trying better position: 20.00 minutes lost.
- Hourly salary: 42.90
85 - - - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 18.00 minutes lost.
Hourly salary: 30.55
86 - - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: Brooklyn Queens Expy & I-278 & Columbia St, Brooklyn, NY 11201, USA
	Trying better position: 4.00 minutes lost.
- Hourly salary: 45.70
87 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 11011 Queens Blvd, Forest Hills, NY 11375, USA
	Trying better position: 4.00 minutes lost.
- - 	expected_profit do_nothing=8.88, move=49.88
	Better Position 
	Swapping: 237-299 E 26th St, New York, NY 10010, USA
	With: 100-0-100-98 69th Ave, Forest Hills, NY 11375, USA
	Trying better position: 6.00 minutes lost.
- 	expected_profit do_nothing=14.17, move=49.88
	Better Position 
	Swapping: 47-0-47-98 58th St, Woodside, NY 11377, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 49.38
88 - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 101-1-101-99 Ditmars Blvd, East Elmhurst, NY 11369, USA
	Trying better position: 7.00 minutes lost.
- - - - Hourly salary: 42.77
89 - - - 	expected_profit do_nothing=8.88, move=49.88
	Better Position 
	Swapping: 237-299 E 26th St, New York, NY 10010, USA
	With: 3962 Broadway, New York, NY 10032, USA
	Trying better position: 6.00 minutes lost.
Hourly salary: 32.89
90 - - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 11011 Queens Blvd, Forest Hills, NY 11375, USA
	Trying better position: 4.00 minutes lost.
Hourly salary: 51.72
91 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 148 Wythe Ave, Brooklyn, NY 11249, USA
	Trying better position: 4.00 minutes lost.
- - - - - Hourly salary: 39.60
92 - - 	expected_profit do_nothing=9.46, move=49.88
	Better Position 
	Swapping: 17 E 84th St, New York, NY 10028, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 3.00 minutes lost.
- Hourly salary: 62.51
93 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 268 10th St, Brooklyn, NY 11215, USA
	Trying better position: 4.00 minutes lost.
- - 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 65-45 Yellowstone Blvd, Forest Hills, NY 11375, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 36.57
94 - - Hourly salary: 70.77
95 - 	expected_profit do_nothing=8.88, move=49.88
	Better Position 
	Swapping: 237-299 E 26th St, New York, NY 10010, USA
	With: 9711-9725 64th Ave, Rego Park, NY 11374, USA
	Trying better position: 6.00 minutes lost.
- - - 	expected_profit do_nothing=10.02, move=49.88
	Better Position 
	Swapping: 51 Astor Pl, New York, NY 10003, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 12.03 minutes lost.
Hourly salary: 36.21
96 - 	expected_profit do_nothing=8.28, move=49.88
	Better Position 
	Swapping: 666 Lexington Ave, New York, NY 10022, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 18.00 minutes lost.
- 	expected_profit do_nothing=7.86, move=49.88
	Better Position 
	Swapping: 35 E 38th St, New York, NY 10016, USA
	With: 90-10 Grand Central Pkwy, East Elmhurst, NY 11369, USA
	Trying better position: 7.00 minutes lost.
Hourly salary: 43.09
97 - - Hourly salary: 64.48
98 - 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: Perimeter Rd, Jamaica, NY 11430, USA
	Trying better position: 3.00 minutes lost.
- 	expected_profit do_nothing=9.26, move=49.88
	Better Position 
	Swapping: 2157 E 21st St, Brooklyn, NY 11229, USA
	With: Pier 2 Promenade, Brooklyn, NY 11201, USA
	Trying better position: 2.42 minutes lost.
- Hourly salary: 54.91
99 - 	expected_profit do_nothing=8.26, move=49.88
	Better Position 
	Swapping: 137 West 33rd Street, New York, NY 10120, USA
	With: 48 Pinehurst Ave, New York, NY 10033, USA
	Trying better position: 4.00 minutes lost.
- - 	expected_profit do_nothing=11.89, move=49.88
	Better Position 
	Swapping: 309 W 230th St, Bronx, NY 10463, USA
	With: 262 N Boundary Rd, Jamaica, NY 11430, USA
	Trying better position: 11.00 minutes lost.
- 	expected_profit do_nothing=8.91, move=49.88
	Better Position 
	Swapping: 223 W 15th St, New York, NY 10011, USA
	With: 268 10th St, Brooklyn, NY 11215, USA
	Trying better position: 3.00 minutes lost.
Hourly salary: 44.67

Average hourly wage from informed strategy = 39.289

Plot a comparison of profit from Naive and Informed Strategies


In [10]:
sns.set(color_codes=True)

plt.rcParams['figure.figsize']=(15,6)
matplotlib.rc('xtick', labelsize=20)
matplotlib.rc('ytick', labelsize=20)

fig, ax = plt.subplots()
sns.set(font_scale=2)
sns.kdeplot(np.array(hourly_wage_from_random_trajectory), ax = ax, label="Naive Strategy")#, bins = np.arange(0,80, 3))
sns.kdeplot(np.array(hourly_wage_from_informed_strategy), ax = ax, label="Informed Strategy")#, bins = np.arange(0,80, 3))
ax.set_xlim([0, 90])
plt.legend(loc='upper right')#,fontsize='xx-large')
ax.set(xlabel='Hourly wage', ylabel='Portion of taxi drivers')
ax.yaxis.label.set_size(30)
ax.xaxis.label.set_size(30)

sns.plt.title('Hourly Wage by Strategy.')


Out[10]:
<matplotlib.text.Text at 0x120bcdf10>

In [ ]: