I'm working off of the tutorial that is premade on GCP when working with the AI Platform component. In short it involves using Kubeflow and Tensorflow Extended to build and deploy a completed ML model for predicting who will be a big tipper off of the Chicago Taxi dataset. Everything has gone well even up to deploying and hitting the predict endpoint of my model however, I can't seem to get the request body correct or find good documentation on how to know what the request body should look. Below I have:
- The model from SchemaGen in Kubeflow
- The header from the data.csv I used for training and the row I extracted from it in which I want to test
- The curl Im using in postman and it's error.
Of note, The error talks about expected a float and getting a string but the model says it should be a float. I'd like to know if anyone can help me determine the datatypes,ordering of the requestBody so I can get a successful prediction back. Thanks in advance!
SchemaGen from Kubeflow:
copy of csv header and data row:
pickup_community_area,fare,trip_start_month,trip_start_hour,trip_start_day,trip_start_timestamp,pickup_latitude,pickup_longitude,dropoff_latitude,dropoff_longitude,trip_miles,pickup_census_tract,dropoff_census_tract,payment_type,company,trip_seconds,dropoff_community_area,tips,big_tipper
60,27.05,10,2,3,1380593700,41.836150155,-87.648787952,,,12.6,,,Cash,Taxi Affiliation Services,1380,,0,0
Curl:
curl --location --request POST 'https://ml.googleapis.com/v1/projects/<<project-name-here/models/tfxmodel:predict'
--header 'Authorization: Bearer <<TOKEN HERE'
--header 'Accept: application/json'
--header 'Content-Type: application/json'
--data-raw '{"instances":["Taxi Affiliation Services","","","","","27.05","Cash","",60,41.836150155,-87.648787952,0,12.6,1380,3,2,10,1380593700]}'
Response:
{"error": "Prediction failed: Error processing input: Expected string, got 27.05 of type 'float' instead."}
Of note if I start converting all the floats and ints to strings it ends up giving me an invalid requestbody error which doesn't suprise me.
To some of the comments: If I add single qoutes into double and also update the empty values to have a zero:
RequestBody:
{"instances":["Taxi Affiliation Services","'0'","'0'","'0'","'0'","'27.05'","Cash","'0'","'60,41.836150155'","'-87.648787952'","'0'","'12.6'","'1380'","'3'","'2'","'10'","'1380593700'"]}
Respose:
{
"error": "Prediction failed: Error during model execution: <_MultiThreadedRendezvous of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Could not parse example input, value: 'Taxi Affiliation Services'
[[{{node ParseExample/ParseExampleV2}}]]"
debug_error_string = "{"created":"@1611579449.396545283","description":"Error received from peer ipv4:127.0.0.1:8081","file":"src/core/lib/surface/call.cc","file_line":1056,"grpc_message":"Could not parse example input, value: 'Taxi Affiliation Services'\n\t [[{{node ParseExample/ParseExampleV2}}]]","grpc_status":3}"
>"
}
question from:
https://stackoverflow.com/questions/65864518/how-do-i-format-the-response-body-of-a-request-to-the-predict-endpoint-of-a-goog