0
votes

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:

  1. The model from SchemaGen in Kubeflow
  2. The header from the data.csv I used for training and the row I extracted from it in which I want to test
  3. 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: enter image description here

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:\n\tstatus = StatusCode.INVALID_ARGUMENT\n\tdetails = \"Could not parse example input, value: 'Taxi Affiliation Services'\n\t [[{{node ParseExample/ParseExampleV2}}]]\"\n\tdebug_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}\"\n>"

}

1
Did you try to add a simple quote in the double quote? Like this "'27.05'"guillaume blaquiere
What GCP tutorial did you follow? Also did you change anything when you followed the tutorial? Just so your issue can be easily reproduced.Ricco D
Guillaume I tried formating using the single in double qoute for all the numeric values and also tried adding a 0 to the field instead of leaving it empty. but still get an error.Damisco
@RiccoD I'm using this tutorial for the kubeflow pipeline and notebook: tensorflow.org/tfx/tutorials/tfx/cloud-ai-platform-pipelines and this was the documentation I reviewed when setting up my model: tensorflow.org/tfx/tutorials/tfx/cloud-ai-platform-pipelinesDamisco
of note with that tutorial, gcp generates a sample notebook that is in line with the tutorial. If one steps through the notebook updating the specific places it tells you too it should be reproduced. It may be billable though!Damisco

1 Answers

0
votes

Please give a try with the below format :-

{"instances":["\\”Taxi Affiliation Services\\”, , , , ,27.05,\\”Cash\\”, ,60,41.836150155,-87.648787952,0,12.6,1380,3,2,10,1380593700"]}

You can check this link for CSV data with each row encoded as a string value:- https://cloud.google.com/ai-platform/prediction/docs/reference/rest/v1/projects/predict#request-body-details