Fixed training app and inference test with new model

master
EHP 6 years ago
parent 0a83ba5af0
commit b200ed833d
  1. 6
      inference/src/test/java/cz/aprar/bonitoo/inference/CacheInferenceTest.java
  2. 2
      inference/src/test/resources/model/encoder.json
  3. BIN
      inference/src/test/resources/model/xgboost-model.bin
  4. 13
      src/train_model.py

@ -50,7 +50,7 @@ public class CacheInferenceTest {
39766.0, 39766.0,
Boolean.TRUE, Boolean.TRUE,
39766.0 39766.0
), TTL.D2}, ), TTL.D3},
{new FlightData( {new FlightData(
"fly-me-to", "fly-me-to",
"PYTON", "PYTON",
@ -84,7 +84,7 @@ public class CacheInferenceTest {
5971.77978, 5971.77978,
Boolean.TRUE, Boolean.TRUE,
15971.77978 15971.77978
), TTL.D2}, ), TTL.D3},
{new FlightData( {new FlightData(
"fly-me-to", "fly-me-to",
"HH", "HH",
@ -101,7 +101,7 @@ public class CacheInferenceTest {
17723.0, 17723.0,
Boolean.TRUE, Boolean.TRUE,
17723.0 17723.0
), TTL.D14}, ), TTL.D2},
{new FlightData( {new FlightData(
"unknown", "unknown",
"unknown", "unknown",

File diff suppressed because one or more lines are too long

@ -95,11 +95,11 @@ def expected_value(row, price_pos_abs=200, price_neg_abs=100, price_pos_perc=0.0
expcachetime = incachetime expcachetime = incachetime
if equal_price(inprice, outprice): if equal_price(inprice, outprice):
if pd.isnull(incachetime): if pd.isnull(incachetime):
return 3 return 4
modifier = 1 modifier = 1
if pd.isnull(incachetime): if pd.isnull(incachetime):
return 1 return 2
if expcachetime <= np.timedelta64(12,'h'): if expcachetime <= np.timedelta64(12,'h'):
return 1 + modifier return 1 + modifier
@ -116,18 +116,21 @@ def expected_value(row, price_pos_abs=200, price_neg_abs=100, price_pos_perc=0.0
return min(7, 7 + modifier) return min(7, 7 + modifier)
def fromisoformat(s):
return dt.datetime.strptime(s, '%Y-%m-%dT%H:%M:%S')
def compute_duration(row): def compute_duration(row):
indeparture, outdeparture = row['flight.inboundSegments.departure'], row['flight.outboundSegments.departure'] indeparture, outdeparture = row['flight.inboundSegments.departure'], row['flight.outboundSegments.departure']
if pd.isna(indeparture): if pd.isna(indeparture):
return 0 return 0
else: else:
indt = dt.datetime.fromisoformat(indeparture.split('|')[0]) indt = fromisoformat(indeparture.split('|')[0])
outdt = dt.datetime.fromisoformat(outdeparture.split('|')[0]) outdt = fromisoformat(outdeparture.split('|')[0])
return (indt - outdt).days return (indt - outdt).days
def compute_prebooking(row): def compute_prebooking(row):
tstamp, outdeparture = row['timestamp'], row['flight.outboundSegments.departure'] tstamp, outdeparture = row['timestamp'], row['flight.outboundSegments.departure']
outdt = dt.datetime.fromisoformat(outdeparture.split('|')[0]) outdt = fromisoformat(outdeparture.split('|')[0])
return (outdt - tstamp).days return (outdt - tstamp).days
def preprocess_data(df): def preprocess_data(df):

Loading…
Cancel
Save