1
+ import math
2
+ import pickle
3
+ import pandas as pd
4
+ import numpy as np
5
+ import settings
6
+
7
+ def scoreFleetDecisionTree (Speed_sensor , Vibration , Engine_Load , Coolant_Temp , Intake_Pressure , Engine_RPM , Speed_OBD , Intake_Air , Flow_Rate , Throttle_Pos , Voltage , Ambient , Accel , Engine_Oil_Temp , Speed_GPS , GPS_Longitude , GPS_Latitude , GPS_Bearing , GPS_Altitude , Turbo_Boost , Trip_Distance , Litres_Per_km , Accel_Ssor_Total , CO2 , Trip_Time , CO_emission , HC_emission , PM_emission , NOx_emission , CO2_emission , Fuel_level , Oil_life , Vibration_alert , VibrationAlert_Total , Vibration_Recent , Turbo_alert , Emission_alert , Fog_control , Engine_control ):
8
+ "Output: EM_EVENTPROBABILITY, EM_CLASSIFICATION"
9
+
10
+ try :
11
+ _thisModelFit
12
+ except NameError :
13
+ with open (settings .pickle_path + 'FleetDecisionTree.pickle' , 'rb' ) as _pFile :
14
+ _thisModelFit = pickle .load (_pFile )
15
+
16
+ try :
17
+ if math .isnan (Speed_sensor ):
18
+ Speed_sensor = 75.06777416636571
19
+ except TypeError :
20
+ Speed_sensor = 75.06777416636571
21
+
22
+ try :
23
+ if math .isnan (Vibration ):
24
+ Vibration = 246.95994479089921
25
+ except TypeError :
26
+ Vibration = 246.95994479089921
27
+
28
+ try :
29
+ if math .isnan (Engine_Load ):
30
+ Engine_Load = 36.06875427988444
31
+ except TypeError :
32
+ Engine_Load = 36.06875427988444
33
+
34
+ try :
35
+ if math .isnan (Coolant_Temp ):
36
+ Coolant_Temp = 87.7360057782593
37
+ except TypeError :
38
+ Coolant_Temp = 87.7360057782593
39
+
40
+ try :
41
+ if math .isnan (Intake_Pressure ):
42
+ Intake_Pressure = 119.41133983387505
43
+ except TypeError :
44
+ Intake_Pressure = 119.41133983387505
45
+
46
+ try :
47
+ if math .isnan (Engine_RPM ):
48
+ Engine_RPM = 1263.593956903816
49
+ except TypeError :
50
+ Engine_RPM = 1263.593956903816
51
+
52
+ try :
53
+ if math .isnan (Speed_OBD ):
54
+ Speed_OBD = 75.06777416636571
55
+ except TypeError :
56
+ Speed_OBD = 75.06777416636571
57
+
58
+ try :
59
+ if math .isnan (Intake_Air ):
60
+ Intake_Air = 10.664138678223186
61
+ except TypeError :
62
+ Intake_Air = 10.664138678223186
63
+
64
+ try :
65
+ if math .isnan (Flow_Rate ):
66
+ Flow_Rate = 23.769685807150594
67
+ except TypeError :
68
+ Flow_Rate = 23.769685807150594
69
+
70
+ try :
71
+ if math .isnan (Throttle_Pos ):
72
+ Throttle_Pos = 75.25847583170821
73
+ except TypeError :
74
+ Throttle_Pos = 75.25847583170821
75
+
76
+ try :
77
+ if math .isnan (Voltage ):
78
+ Voltage = 14.171672083784758
79
+ except TypeError :
80
+ Voltage = 14.171672083784758
81
+
82
+ try :
83
+ if math .isnan (Ambient ):
84
+ Ambient = 7.309738774527507
85
+ except TypeError :
86
+ Ambient = 7.309738774527507
87
+
88
+ try :
89
+ if math .isnan (Accel ):
90
+ Accel = 22.004593668231607
91
+ except TypeError :
92
+ Accel = 22.004593668231607
93
+
94
+ try :
95
+ if math .isnan (Engine_Oil_Temp ):
96
+ Engine_Oil_Temp = 84.52690501986277
97
+ except TypeError :
98
+ Engine_Oil_Temp = 84.52690501986277
99
+
100
+ try :
101
+ if math .isnan (Speed_GPS ):
102
+ Speed_GPS = 77.28586848607259
103
+ except TypeError :
104
+ Speed_GPS = 77.28586848607259
105
+
106
+ try :
107
+ if math .isnan (GPS_Longitude ):
108
+ GPS_Longitude = 8.569920139091247
109
+ except TypeError :
110
+ GPS_Longitude = 8.569920139091247
111
+
112
+ try :
113
+ if math .isnan (GPS_Latitude ):
114
+ GPS_Latitude = 48.54705087261828
115
+ except TypeError :
116
+ GPS_Latitude = 48.54705087261828
117
+
118
+ try :
119
+ if math .isnan (GPS_Bearing ):
120
+ GPS_Bearing = 195.5093294811605
121
+ except TypeError :
122
+ GPS_Bearing = 195.5093294811605
123
+
124
+ try :
125
+ if math .isnan (GPS_Altitude ):
126
+ GPS_Altitude = 326.22607439508846
127
+ except TypeError :
128
+ GPS_Altitude = 326.22607439508846
129
+
130
+ try :
131
+ if math .isnan (Turbo_Boost ):
132
+ Turbo_Boost = 3.2505074667148186
133
+ except TypeError :
134
+ Turbo_Boost = 3.2505074667148186
135
+
136
+ try :
137
+ if math .isnan (Trip_Distance ):
138
+ Trip_Distance = 230.49551875887803
139
+ except TypeError :
140
+ Trip_Distance = 230.49551875887803
141
+
142
+ try :
143
+ if math .isnan (Litres_Per_km ):
144
+ Litres_Per_km = 4.316090813719474
145
+ except TypeError :
146
+ Litres_Per_km = 4.316090813719474
147
+
148
+ try :
149
+ if math .isnan (Accel_Ssor_Total ):
150
+ Accel_Ssor_Total = - 0.0031587095220898037
151
+ except TypeError :
152
+ Accel_Ssor_Total = - 0.0031587095220898037
153
+
154
+ try :
155
+ if math .isnan (CO2 ):
156
+ CO2 = 93.42142250399041
157
+ except TypeError :
158
+ CO2 = 93.42142250399041
159
+
160
+ try :
161
+ if math .isnan (Trip_Time ):
162
+ Trip_Time = 7512.937041049717
163
+ except TypeError :
164
+ Trip_Time = 7512.937041049717
165
+
166
+ try :
167
+ if math .isnan (CO_emission ):
168
+ CO_emission = 0.0
169
+ except TypeError :
170
+ CO_emission = 0.0
171
+
172
+ try :
173
+ if math .isnan (HC_emission ):
174
+ HC_emission = 0.0
175
+ except TypeError :
176
+ HC_emission = 0.0
177
+
178
+ try :
179
+ if math .isnan (PM_emission ):
180
+ PM_emission = 0.0
181
+ except TypeError :
182
+ PM_emission = 0.0
183
+
184
+ try :
185
+ if math .isnan (NOx_emission ):
186
+ NOx_emission = 0.0
187
+ except TypeError :
188
+ NOx_emission = 0.0
189
+
190
+ try :
191
+ if math .isnan (CO2_emission ):
192
+ CO2_emission = 0.0
193
+ except TypeError :
194
+ CO2_emission = 0.0
195
+
196
+ try :
197
+ if math .isnan (Fuel_level ):
198
+ Fuel_level = 0.0
199
+ except TypeError :
200
+ Fuel_level = 0.0
201
+
202
+ try :
203
+ if math .isnan (Oil_life ):
204
+ Oil_life = 0.0
205
+ except TypeError :
206
+ Oil_life = 0.0
207
+
208
+ try :
209
+ if math .isnan (Vibration_alert ):
210
+ Vibration_alert = 1.0
211
+ except TypeError :
212
+ Vibration_alert = 1.0
213
+
214
+ try :
215
+ if math .isnan (VibrationAlert_Total ):
216
+ VibrationAlert_Total = 123.0
217
+ except TypeError :
218
+ VibrationAlert_Total = 123.0
219
+
220
+ try :
221
+ if math .isnan (Vibration_Recent ):
222
+ Vibration_Recent = 12.0
223
+ except TypeError :
224
+ Vibration_Recent = 12.0
225
+
226
+ try :
227
+ if math .isnan (Turbo_alert ):
228
+ Turbo_alert = 1.0
229
+ except TypeError :
230
+ Turbo_alert = 1.0
231
+
232
+ try :
233
+ if math .isnan (Emission_alert ):
234
+ Emission_alert = 1.0
235
+ except TypeError :
236
+ Emission_alert = 1.0
237
+
238
+ try :
239
+ if math .isnan (Fog_control ):
240
+ Fog_control = 1.0
241
+ except TypeError :
242
+ Fog_control = 1.0
243
+
244
+ try :
245
+ if math .isnan (Engine_control ):
246
+ Engine_control = 1.0
247
+ except TypeError :
248
+ Engine_control = 1.0
249
+
250
+ inputArray = pd .DataFrame ([[1.0 , Speed_sensor , Vibration , Engine_Load , Coolant_Temp , Intake_Pressure , Engine_RPM , Speed_OBD , Intake_Air , Flow_Rate , Throttle_Pos , Voltage , Ambient , Accel , Engine_Oil_Temp , Speed_GPS , GPS_Longitude , GPS_Latitude , GPS_Bearing , GPS_Altitude , Turbo_Boost , Trip_Distance , Litres_Per_km , Accel_Ssor_Total , CO2 , Trip_Time , CO_emission , HC_emission , PM_emission , NOx_emission , CO2_emission , Fuel_level , Oil_life , Vibration_alert , VibrationAlert_Total , Vibration_Recent , Turbo_alert , Emission_alert , Fog_control , Engine_control ]],
251
+ columns = ['const' , 'Speed_sensor' , 'Vibration' , 'Engine_Load' , 'Coolant_Temp' , 'Intake_Pressure' , 'Engine_RPM' , 'Speed_OBD' , 'Intake_Air' , 'Flow_Rate' , 'Throttle_Pos' , 'Voltage' , 'Ambient' , 'Accel' , 'Engine_Oil_Temp' , 'Speed_GPS' , 'GPS_Longitude' , 'GPS_Latitude' , 'GPS_Bearing' , 'GPS_Altitude' , 'Turbo_Boost' , 'Trip_Distance' , 'Litres_Per_km' , 'Accel_Ssor_Total' , 'CO2' , 'Trip_Time' , 'CO_emission' , 'HC_emission' , 'PM_emission' , 'NOx_emission' , 'CO2_emission' , 'Fuel_level' , 'Oil_life' , 'Vibration_alert' , 'VibrationAlert_Total' , 'Vibration_Recent' , 'Turbo_alert' , 'Emission_alert' , 'Fog_control' , 'Engine_control' ],
252
+ dtype = float )
253
+
254
+ prediction = _thisModelFit .predict (inputArray )
255
+
256
+ EM_EVENTPROBABILITY = float (prediction )
257
+
258
+ if (EM_EVENTPROBABILITY >= 0.2269170579029734 ):
259
+ EM_CLASSIFICATION = '1'
260
+ else :
261
+ EM_CLASSIFICATION = '0'
262
+
263
+ return (EM_EVENTPROBABILITY , EM_CLASSIFICATION )
0 commit comments