8
8
import emission .analysis .modelling .tour_model .similarity as similarity
9
9
import emission .analysis .modelling .tour_model .data_preprocessing as preprocess
10
10
11
+ RADIUS = 500
11
12
12
13
def loadModelStage (filename ):
13
14
import jsonpickle .ext .numpy as jsonpickle_numpy
@@ -62,7 +63,6 @@ def find_bin(trip, bin_locations, radius):
62
63
return sel_fl
63
64
64
65
def predict_labels (trip ):
65
- radius = 100
66
66
user = trip ['user_id' ]
67
67
logging .debug (f"At stage: extracting features" )
68
68
trip_feat = preprocess .extract_features ([trip ])[0 ]
@@ -90,7 +90,7 @@ def predict_labels(trip):
90
90
91
91
92
92
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 )
94
94
logging .debug (f"At stage: matched with bin { pred_bin } " )
95
95
96
96
if pred_bin == - 1 :
@@ -108,9 +108,8 @@ def predict_labels(trip):
108
108
109
109
# case 1: the new trip matches a bin from the 1st round and a cluster from the 2nd round
110
110
user = all_users [0 ]
111
- radius = 100
112
111
trips = preprocess .read_data (user )
113
- filter_trips = preprocess .filter_data (trips , radius )
112
+ filter_trips = preprocess .filter_data (trips , RADIUS )
114
113
new_trip = filter_trips [4 ]
115
114
# result is [{'labels': {'mode_confirm': 'shared_ride', 'purpose_confirm': 'church', 'replaced_mode': 'drove_alone'},
116
115
# 'p': 0.9333333333333333}, {'labels': {'mode_confirm': 'shared_ride', 'purpose_confirm': 'entertainment',
@@ -130,7 +129,6 @@ def predict_labels(trip):
130
129
131
130
# case3: the new trip is novel trip(doesn't fall in any 1st round bins)
132
131
user = all_users [0 ]
133
- radius = 100
134
132
trips = preprocess .read_data (user )
135
133
filter_trips = preprocess .filter_data (trips , radius )
136
134
new_trip = filter_trips [0 ]
0 commit comments