Hiya! I deployed a customed trained model on google cloud and im currently trying to run it on python. When I deployed the model it said I could "use a simple Python script to get predictions from your active endpoint." Here are the instructions I followed:
I changed the values of the instances to the following (this is the format when doing a JSON request so i believe it should work properly):
did everything required but I kept getting the error :
google.api_core.exceptions.FailedPrecondition: 400 "Prediction failed: Exception during sklearn prediction: Expected 2D array, got 1D array instead:\narray=[{'instances': [[False, 1, 0, 0, 1, 0, 2, 2018, 1, 16, 0, 0, 0, 1, 1, 1, 3], [True, 1, 0, 0, 2, 0, 0, 2018, 1, 13, 0, 13, 0, 2, 1, 1, 3]]}].\nReshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample."
any clues on how i can fix this?
Hi @nicarcenas,
Welcome and thank you for reaching out to our community.
I understand that you are having challenges deploying your custom trained model. The error message suggests that there has been a discrepancy with your array input, receiving only 1D instead of a 2D input.
As the message says,
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample
, by doing so, you can change the elements or dimensions of your array input.
Another option for you is to explore preprocessing your data with ColumnTransformer as stated in this StackOverflow answer.
Hope this helps.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |