Pickle files are version-sensitive. Loading with a different xgboost version will crash or give wrong predictions.
Usage (direct)
import pickle
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
repo_id="hossamaladdin/feasbillty_check_travel",
filename="feasibility_model.pkl"
)
encoder_path = hf_hub_download(
repo_id="hossamaladdin/feasbillty_check_travel",
filename="label_encoder.pkl"
)
with open(model_path, "rb") as f:
model = pickle.load(f)
with open(encoder_path, "rb") as f:
le = pickle.load(f)
features = [[5, 2, 1000.0, 180.0, 1800.0, 0.556, 3, 1, 0]]
pred = model.predict(features)
print(le.inverse_transform(pred))
Recommended Usage (with bridge layer)
Do not call the model directly with raw NER output. Use entity_handler.py to convert NER entities to numeric features first.
from backend.entity_handler import entity_to_features, get_diagnostic_tags, explain_feasibility
entities = {
"LOCATION": "Paris",
"DURATION": "5 days",
"BUDGET": "1000 dollars",
"GROUP_SIZE": "2 people",
"TRAVEL_TYPE": "romantic",
"DATE": "in July"
}
features = entity_to_features(entities)
pred = model.predict([list(features.values())])
label = le.inverse_transform(pred)[0]
tags = get_diagnostic_tags(features)
explanation = explain_feasibility(label, tags)
Performance
Test Accuracy : 82.47% Weighted F1 : 81.90% Macro F1 : 79.17%
| Class | Precision | Recall | F1 | Support |
|---|---|---|---|---|
| feasible | 0.76 | 0.97 | 0.85 | 293 |
| partial | 0.96 | 0.76 | 0.85 | 197 |
| infeasible | 0.85 | 0.56 | 0.67 | 109 |
Known limitation: infeasible recall = 56%. Model tends to classify borderline infeasible trips as partial. This is an acceptable failure mode — user still receives a warning.