Reputation: 352
I'm able to generate local predictions but not online predictions for XGBoost model with gcloud. There is no error message for online prediction, just a null response
Local prediction -
Input json - [40, 1, 0, 20, 3, 2020, 4, 0, 0, 0, 2, 0, 5, 0, 6, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]
gcloud -
gcloud ai-platform local predict --model-dir <model_dir> --json-instances <input_json> --framework xgboost
output -
INFO: Display format: "default table[no-heading](predictions)"
[0.3261602520942688]
When I use the same json for generating online predictions
Online prediction
gcloud -
gcloud ai-platform predict --model $MODEL_NAME --version $VERSION_NAME --json-instances test_json_modified.json
output -
INFO: Display format: "default table[no-heading](predictions)"
[[]]
I've tried using the GUI for generating online predictions but still I'm unable to get anything -
I've tried using different input json format like below but nothing works -
{"instances": [{"values": [[40, 1, 0, 20, 3, 2020, 4, 0, 0, 0, 2, 0, 5, 0, 6, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]], "key": 1}]}
Upvotes: 1
Views: 315
Reputation: 1482
I ran into a similar problem, and @mshearer0 was right in my case-it was a version mismatch. Apparently, it is extremely important to pay close attention to the exact versions you are using to train the model and the runtime version you deploy your model with, because the error messaging is very uninformative (like this example).
To see a list of versions for each runtime, see this link on the GCP documentation.
For me, I had to uninstall then re-install the correct versions matching the runtime version, e.g.
pip uninstall xgboost
pip install xgboost==1.4.0
For runtime version 2.5.
Upvotes: 0
Reputation: 11
You may have a different version of xgboost in your training vs Gcp prediction environment
Upvotes: 1