I built and deployed an XGBoost regressor model on vertex AI and I am trying to make some predictions using Vertex AI python SDK. Here's my code:
client = aiplatform.gapic.PredictionServiceClient.from_service_account_json(filename="filename.json",client_options=client_options)
endpoint = client.endpoint_path(project=project, location=location, endpoint=endpoint_id)
response = client.predict(endpoint=endpoint, instances=instances)
predictions = response.predictions
Here is the value of the variable instances :
array([[4.8700000e+00, 3.6505380e+06, 2.0000000e+01, 2.0210000e+03,
4.0000000e+00, 5.3000000e+01, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00,
0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00,
0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00,
0.0000000e+00, 0.0000000e+00, 1.0000000e+00, 0.0000000e+00,
0.0000000e+00],
[3.7100000e+00, 1.2678515e+07, 2.0000000e+01, 2.0210000e+03,
4.0000000e+00, 5.3000000e+01, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00,
0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00,
0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00,
0.0000000e+00, 0.0000000e+00, 1.0000000e+00, 0.0000000e+00,
0.0000000e+00]])
(Here I am trying to make two predictions). When doing this I am getting an error:
Unable to coerce value
I tried to look at the number of features allowed by the model and it is the same as the input here (29). I tried looking into the xgboost code and according to the code the input is correct. So I am guessing it is an issue on vertex AI side. But I don't know how to fix it.