Views
No views yet
output/ensemble_20250906_124755.station_id (int index), route_id (int index), direction_id (0/1)hour_sin, hour_cos, minute_sin, minute_cos, day_sin, day_cosscheduled_timestamp (float seconds since epoch; normalized in-model)track_prediction_ensemble_model_0_final.keras … track_prediction_ensemble_model_5_final.keras — individual ensemble memberstrack_prediction_ensemble_model_*_best.keras — best checkpoints during training (may match final)training_report.md — training configuration and metrics*_vocab.json. See “Preprocessing & Vocab” below.station_id and route_id, and raw direction_id 0/1. In training, indices are produced by lookup tables built from the dataset vocabularies. To reproduce inference exactly, you must use the same vocabularies (station/route/track) that were present at training time or ensure consistent mapping.imt_ml.dataset.create_feature_engineering_fn) defines the exact feature mapping. If you need the vocab files, re-run a training or export step to generate them for your data snapshot, or save the vocab mapping alongside the model.training_report.md:1import numpy as np
2import keras
3
4# Load ensemble members
5paths = [
6 "track_prediction_ensemble_model_0_final.keras",
7 "track_prediction_ensemble_model_1_final.keras",
8 "track_prediction_ensemble_model_2_final.keras",
9 "track_prediction_ensemble_model_3_final.keras",
10 "track_prediction_ensemble_model_4_final.keras",
11 "track_prediction_ensemble_model_5_final.keras",
12]
13models = [keras.models.load_model(p, compile=False) for p in paths]
14
15# Prepare one example (batch size 1) — values shown are placeholders.
16# You must convert raw strings to indices using the same vocab mapping used in training.
17features = {
18 "station_id": np.array([12], dtype=np.int64), # int index
19 "route_id": np.array([3], dtype=np.int64), # int index
20 "direction_id": np.array([1], dtype=np.int64), # 0 or 1
21 "hour_sin": np.array([0.707], dtype=np.float32),
22 "hour_cos": np.array([0.707], dtype=np.float32),
23 "minute_sin": np.array([0.0], dtype=np.float32),
24 "minute_cos": np.array([1.0], dtype=np.float32),
25 "day_sin": np.array([0.433], dtype=np.float32),
26 "day_cos": np.array([0.901], dtype=np.float32),
27 "scheduled_timestamp": np.array([1.7260e9], dtype=np.float32),
28}
29
30# Predict per model and average probabilities
31probs = [m.predict(features, verbose=0) for m in models]
32avg_prob = np.mean(probs, axis=0) # shape: (batch, num_tracks)
33pred_class = int(np.argmax(avg_prob, axis=-1)[0])
34print({"predicted_track_index": pred_class, "probabilities": avg_prob[0].tolist()})pred_class back to its track label string by indexing into that track_vocab list.station_id, route_id, direction_idtrack_number (13 classes)ensemble