I have deployed an XGBoost model to GCP and wanted to test predicting single values using the code:
from googleapiclient import discovery
ml = discovery.build('ml', 'v1')
name = 'projects/{}/models/{}/versions/{}'.format(gcp_project_id, model_name, model_version)
prediction = ml.projects().predict(
name=name,
body={'instances': [[10110.0, 5162.0, 13833.0, 1102.0, 211.0]]}
).execute()
print(prediction)
which just gives me no result:
{'predictions': [[]]}
The deployed model appears to have been used and not getting any errors.
I have done this exact same thing before, with an XGBoost model, using all of the same code which worked perfectly, so I have no idea why it worked before but not now!
I have tried creating the model version again, which didn't work.
The saved model works fine if I load using:
bst = xgb.Booster({'nthread':4})
bst.load_model('model.bst')
prediction = bst.predict(xgb.DMatrix(X_test.iloc[0]))
prediction
And gives me a prediction:
array([439.30298], dtype=float32)
So my saved model doesn't seem corrupt or anything.
Any help would be much appreciated as I have no idea what to try next!