Skip to content

Commit 6cc353a

Browse files
committed
Change the prediction radius also to 500
This ensures that we can match trips properly (for fix, see e-mission/e-mission-docs#656 (comment))
1 parent e38c1b4 commit 6cc353a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

emission/analysis/modelling/tour_model_first_only/load_predict.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import emission.analysis.modelling.tour_model.similarity as similarity
99
import emission.analysis.modelling.tour_model.data_preprocessing as preprocess
1010

11+
RADIUS=500
1112

1213
def loadModelStage(filename):
1314
import jsonpickle.ext.numpy as jsonpickle_numpy
@@ -62,7 +63,6 @@ def find_bin(trip, bin_locations, radius):
6263
return sel_fl
6364

6465
def predict_labels(trip):
65-
radius = 100
6666
user = trip['user_id']
6767
logging.debug(f"At stage: extracting features")
6868
trip_feat = preprocess.extract_features([trip])[0]
@@ -90,7 +90,7 @@ def predict_labels(trip):
9090

9191

9292
logging.debug(f"At stage: first round prediction")
93-
pred_bin = find_bin(trip, bin_locations, radius)
93+
pred_bin = find_bin(trip, bin_locations, RADIUS)
9494
logging.debug(f"At stage: matched with bin {pred_bin}")
9595

9696
if pred_bin == -1:
@@ -108,9 +108,8 @@ def predict_labels(trip):
108108

109109
# case 1: the new trip matches a bin from the 1st round and a cluster from the 2nd round
110110
user = all_users[0]
111-
radius = 100
112111
trips = preprocess.read_data(user)
113-
filter_trips = preprocess.filter_data(trips, radius)
112+
filter_trips = preprocess.filter_data(trips, RADIUS)
114113
new_trip = filter_trips[4]
115114
# result is [{'labels': {'mode_confirm': 'shared_ride', 'purpose_confirm': 'church', 'replaced_mode': 'drove_alone'},
116115
# 'p': 0.9333333333333333}, {'labels': {'mode_confirm': 'shared_ride', 'purpose_confirm': 'entertainment',
@@ -130,7 +129,6 @@ def predict_labels(trip):
130129

131130
# case3: the new trip is novel trip(doesn't fall in any 1st round bins)
132131
user = all_users[0]
133-
radius = 100
134132
trips = preprocess.read_data(user)
135133
filter_trips = preprocess.filter_data(trips, radius)
136134
new_trip = filter_trips[0]

0 commit comments

Comments
 (0)