Опитвам се да използвам API на Google Prediction, добавих нов модел чрез извикване на API и сега се опитвам да го обуча чрез извиквания за актуализиране на API. успях да го актуализирам, но по някаква причина някои данни липсват, например, когато стартирам trainedmodels.analyze чрез Google API Explorer, виждам, че някои стойности са празни:
{
"kind": "prediction#analyze",
"id": "my_model_id",
"dataDescription": {
"outputFeature": {
"text": [
{
"value": "lost",
"count": "1"
},
{
"value": "won",
"count": "4"
}
]
},
"features": [
{
"index": "0",
"text": {
"count": "5"
}
},
{
"index": "1",
"categorical": {
"count": "5",
"values": [
{
"value": "google",
"count": "3"
},
{
"value": "mobile",
"count": "2"
}
]
}
},
{
"index": "2",
"categorical": {
"count": "5",
"values": [
{
"value": "google",
"count": "2"
},
{
"value": "organic",
"count": "3"
}
]
}
},
{
"index": "3",
"text": {
"count": "5"
}
},
{
"index": "4",
"text": {
"count": "5"
}
},
{
"index": "5",
"text": {
"count": "2"
}
}
]
}
}
Извършвам обаждането чрез клиент на Google PHP така:
private function updateModel($ga_details,$label,$model_name)
{
$csv_instance = [];
$csv_instance[0] = $ga_details['user_type'];
$csv_instance[1] = $ga_details['device_category'];
$csv_instance[2] = $ga_details['source'];
$csv_instance[3] = $ga_details['campaign'];
$csv_instance[4] = $ga_details['medium'];
$csv_instance[5] = $ga_details['ad_group'];
try{
$prediction = new \Google_Service_Prediction($this->client);
$update = new \Google_Service_Prediction_Update();
$update->setCsvInstance($csv_instance);
$update->setOutput($label);
$res = $prediction->trainedmodels->update(config('prediction.PROJECT_ID'),$model_name,$update);
return ($res && $res->id) ? $res->id : false;
}catch (\Google_Service_Exception $e){
return Response::json([
'custom' => 'could not updateModel',
'message' => $e->getMessage(),
'code' => $e->getCode(),
'errors' => $e->getErrors()
]);
}
}
стойностите за $ga_details
са предварително дефинирани от мен (за тестове):
$ga_details = [
"user_type" => "Returning Visitor",
"device_category" => "mobile",
"source" => "google",
"campaign" => "organic",
"medium" => "(not set)",
"ad_group" => "(not set)",
];
някаква идея защо user_type, medium and ad_group
е празен в моя модел? (опитах се да премахна () и да изрежа белите интервали, но не помогна).