ymlin105 commited on
Commit
92ff78b
·
1 Parent(s): 750b1a7

fix: add model parameter compatibility fix for XGBoost

Browse files
Files changed (2) hide show
  1. models/rossmann_production_model.pkl +2 -2
  2. src/app.py +13 -0
models/rossmann_production_model.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:59d3bda897c6d9678abfce7bd5b631183319efbdf275113d83463ad3d52f706e
3
- size 53873380
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef53a58e49cabce81d0a9478aeb902c161f128aa0fb6f3de5ac9a9e8be87ea97
3
+ size 53871230
src/app.py CHANGED
@@ -49,6 +49,19 @@ def startup_event():
49
  try:
50
  with open(model_path, "rb") as f:
51
  pipeline.model = pickle.load(f)
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  logger.info(f"Model loaded successfully. Type: {type(pipeline.model)}")
53
  except Exception as e:
54
  logger.error(f"Failed to load model: {e}")
 
49
  try:
50
  with open(model_path, "rb") as f:
51
  pipeline.model = pickle.load(f)
52
+
53
+ # Fix for version compatibility - remove gpu_id
54
+ try:
55
+ if hasattr(pipeline.model, "gpu_id"):
56
+ pipeline.model = pipeline.model.set_params(gpu_id=None)
57
+ if hasattr(pipeline.model, "device"):
58
+ pipeline.model = pipeline.model.set_params(device="cpu")
59
+ # Force using hist tree method
60
+ pipeline.model = pipeline.model.set_params(tree_method="hist")
61
+ logger.info("Model parameters fixed for compatibility")
62
+ except Exception as e:
63
+ logger.warning(f"Could not fix model params: {e}")
64
+
65
  logger.info(f"Model loaded successfully. Type: {type(pipeline.model)}")
66
  except Exception as e:
67
  logger.error(f"Failed to load model: {e}")