I have trained the model in bigquery (BOOSTED_TREE_CLASSIFIER) and also tested it on test data, their model worked well and gave 98% accuracy and predicted the result, but when I imported the model in the model registry and created the endpoint, I faced this error while testing it in endpoint.
Hi @andy_08,
Welcome to Google Cloud Community!
The error โPrediction failed: Could not initialize DMatrix from inputsโ suggests that your prediction is sending a one-dimensional NumPy array to the model, while the model expects a two-dimensional array. This is a common issue when transitioning from training/testing to real-time predictions.
Here's a breakdown of the problem and possible way to fix it:
The problem:
You may try this workaround:
You may need to reshape your input JSON into a 2D array, even if it includes only a single sample.
In addition, after making these changes, re-test the prediction endpoint with the updated JSON.
You may refer to the following documentation, which can help you understand the overall workflow of deploying models:
I hope the above information is helpful.
I ran into a similar problem recently. I found out that this issue is caused when the prediction schema is either not defined or ill-defined at the time of deployment. I was able to fix this by exporting the model directly to Vertex AI during the training phase by adding the MODEL_REGISTRY, VERTEX_AI_MODEL_ID, and VERTEX_AI_MODEL_VERSION_ALIASES parameters in the CREATE MODEL statement. These automatically export the model to the Vertex AI registry and define the schema, which fixes the problem.