Функция Google Prediction v 1.6 trainingmodels.update добавляет несколько пустых значений.

я пытаюсь использовать Google Prediction API, я добавил новую модель через вызов API, и теперь я пытаюсь обучить ее с помощью вызовов обновления API. мне удалось обновить его, но по какой-то причине некоторые данные отсутствуют, например, когда я запускаю trainingmodels.analyze через проводник Google API, я вижу, что некоторые значения пусты:

{
 "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"
    }
   }
  ]
 }
}

Я делаю вызов через PHP-клиент Google следующим образом:

 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 пусто в моей модели? (я пытался снять () и убрать пробелы, но это не помогло).


person benjah    schedule 06.12.2015    source источник


Ответы (1)


Решено!

Забавно, я всегда отвечаю сам себе, но если я могу кому-то помочь, почему бы и нет? :) Я исправил эту проблему с кодированием значений, которые я передаю, используя метод PHP urlencode().

person benjah    schedule 08.12.2015