Reading/understanding Clarifai 查询结果

Reading/understanding Clarifai query results

我在 reading/understanding Clarifai 的 API 查询结果中遇到问题。下面是我通过 php 进行的 curl 查询。一切似乎都有效,但我得到的结果(参见下面的示例)与在他们的网站上测试时的结果不一致。在网站模型预测值范围从 0.0 到 1.0(越接近 1.0 越真实)。然而,通过 API,我得到了诸如 9.800707E-13 之类的值。 API中使用的范围是多少?

//initiate curl
$ch = curl_init();

//set up curl options
curl_setopt($ch, CURLOPT_URL, 'https://api.clarifai.com/v2/models/my-model/versions/25cd8d254f9542a2a0473d07c2e02ccf/outputs');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"inputs\": [{\"data\": {\"image\": {\"url\": \"https://live.staticflickr.com/4017/4273847676_9920e12771_b.jpg\"}}}]}");

//set up headers array
$headers = array();
$headers[] = 'Authorization: Key dba0e6dc60414f52af51742cd655cab5';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

//execute curl, check for error and close
$result = curl_exec($ch);
if (curl_errno($ch)) echo 'Error:' . curl_error($ch);
curl_close($ch);

//decode json to an array
$result = json_decode($result, true);
    
//to test
echo "<pre>"; print_r($result); echo "</pre>";

以下是 json 结果返回的概念测试:

                [data] => Array
                    (
                        [concepts] => Array
                            (
                                [0] => Array
                                    (
                                        [id] => Plastic-Straw
                                        [name] => Plastic-Straw
                                        [value] => 0.9999347
                                        [app_id] => 8c51e25474ce4d11a2eb4b390c80203a
                                    )

                                [1] => Array
                                    (
                                        [id] => Straw
                                        [name] => Straw
                                        [value] => 9.800707E-13
                                        [app_id] => 8c51e25474ce4d11a2eb4b390c80203a
                                    )

                            )

                    )

编辑:下面是未格式化的 JSON 输出。

{"status":{"code":10000,"description":"Ok","req_id":"e6a9b93a24854921a1b694bedb0d882a"},"outputs":[{"id":"542ad9f40d704cd19e0b964ab1c34737","status":{"code":10000,"description":"Ok"},"created_at":"2021-01-25T19:43:55.966102577Z","model":{"id":"last-straw-model","name":"Last Straw Model","created_at":"2021-01-06T14:24:36.329385Z","app_id":"8c51e25474ce4d11a2eb4b390c80203a","output_info":{"output_config":{"concepts_mutually_exclusive":false,"closed_environment":true,"max_concepts":0,"min_value":0},"message":"Show output_info with: GET /models/{model_id}/output_info","type":"concept","type_ext":"concept"},"model_version":{"id":"25cd8d254f9542a8a0473d07c2e02bbf","created_at":"2021-01-08T13:34:29.630929Z","status":{"code":21100,"description":"Model is trained and ready"},"total_input_count":77,"completed_at":"2021-01-08T13:34:31.506648Z"},"input_info":{},"train_info":{},"model_type_id":"embedding-classifier"},"input":{"id":"f24405b5483d429381f9e6aeb54d7941","data":{"image":{"url":"https://live.staticflickr.com/4017/4273847676_9920e12771_b.jpg"}}},"data":{"concepts":[{"id":"Plastic-Straw","name":"Plastic-Straw","value":0.9999347,"app_id":"8c51e25474ce4d11a2eb4b390c80203a"},{"id":"Straw","name":"Straw","value":9.800707e-13,"app_id":"8c51e25474ce4d11a2eb4b390c80203a"}]}}]}

e 被附加到数字的末尾以抽象出它们非常大的值。 9.800707E-13只是用来避免写0.0000000098等...

它用于非常大的正值或负值(e13 或 e-13、e5、e-10 等...)

在预测的上下文中,这意味着概率接近于零。