在使用 AI Platform 组件时,我正在学习 GCP 上预制的教程。简而言之,它涉及使用 Kubeflow 和 Tensorflow Extended 来构建和部署一个完整的 ML 模型,以预测谁将成为 Chicago Taxi 数据集的大倾销者。一切都进展顺利,甚至可以部署并命中我的模型的预测端点,但是,我似乎无法正确获取请求正文或找到关于如何知道请求正文应该是什么样子的良好文档。下面我有:
- Kubeflow 中来自 SchemaGen 的模型
- 我用于训练的 data.csv 中的标题以及我从中提取的要测试的行
- 我在邮递员中使用的 curl 是错误的。
值得注意的是,该错误谈到了预期的浮点数并获取了一个字符串,但模型说它应该是一个浮点数。我想知道是否有人可以帮助我确定数据类型,requestBody 的排序,以便我可以成功地进行预测。提前致谢!
csv 标题和数据行的副本: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 ,2,3,1380593700,41.836150155,-87.648787952,,,12.6,,,现金,出租车加盟服务,1380,,0,0
卷曲:
curl --location --request POST 'https://ml.googleapis.com/v1/projects/<<project-name-here/models/tfxmodel:predict'
--header '授权:Bearer <<TOKEN HERE'
- -header 'Accept: application/json'
--header 'Content-Type: application/json'
--data-raw '{"instances":["Taxi Affiliation Services","","","","" ,"27.05","现金","",60,41.836150155,-87.648787952,0,12.6,1380,3,2,10,1380593700]}'
响应:{“错误”:“预测失败:错误处理输入:预期的字符串,得到 27.05 类型的 'float' 代替。”}
值得注意的是,如果我开始将所有浮点数和整数转换为字符串,它最终会给我一个无效的 requestbody 错误,这并不让我感到惊讶。
对于一些评论:如果我将单个 qoutes 添加到 double 中,并将空值更新为零:
请求正文:
{"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'"]}
回应:
{
"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>"
}