2012-02-29 3 views
0

PHP에서 Google Prediction API를 사용하고 있습니다.PHP를 사용하여 Google Prediction API의 데이터를 학습하는 중에 오류가 발생했습니다.

OAuth 2.0을 사용하여 인증이 성공적으로 완료되었습니다. 클라우드의 CSV 파일에 내 데이터가 있습니다. Training 클래스에서 setDataLocation 메서드를 사용하여 위치를 지정했습니다. 나는 더 이상 진행 드릴 수 없습니다

if ($client->getAccessToken()) { 
    $data = array(); 
    $buzzy = new Training(); 
    $predictionService = new apiPredictionService($client); 
    $trainedmodels = $predictionService->trainedmodels; 
    $buzzzy = new TrainedmodelsServiceResource(); 
    $me = $buzzy->setStorageDataLocation('my_data.csv'); 
    $mee = $buzzy->getStorageDataLocation(); 
    // $ma = $buzzy->getTrainingStatus(); 
    $setid_in = $buzzy->setId($buzzy->getStorageDataLocation()); 
    $setid_out = $buzzy->getId(); 
    echo $setid_out; 
    //print_r($predictionService); 
    //$insert_1 = $buzzzy->insert($buzzy,array()); 

    // This is line 81 in my code: 
    $insert2=$trainedmodels->insert($predictionService,array()); 
} 

: 이것은 내 코드는

Fatal error: Uncaught exception 'apiException' with message 'Unknown function: ->->insert()' in C:\xampp\htdocs\google-api-php-client\src\service\apiServiceResource.php:81 Stack trace: #0 C:\xampp\htdocs\google-api-php-client\src\contrib\apiPredictionService.php(60): apiServiceResource->__call('insert', Array) #1 C:\xampp\htdocs\google-api-php-client\examples\analytics\new2.php(51): TrainedmodelsServiceResource->insert(Object(apiPredictionService), Array) #2 {main} thrown in C:\xampp\htdocs\google-api-php-client\src\service\apiServiceResource.php on line 81

입니다 :하지만 교육/데이터를 삽입하는 동안 다음 오류가 발생했습니다. 나는 훈련을하고 예측 기능을 호출 할 계획이다.

답변

1

방금 ​​PHP를 사용하여 예측을하기 위해 테스트 프로그램을 작성하여이 작업을 수행 할 수있었습니다.

$id = "your-model-id-goes-here"; 
    $predictionText = "This is a test"; 
    $predictionData = new InputInput(); 
    $predictionData->setCsvInstance(array($predictionText)); 
    // My model takes a single feature but if your model needs more than one 
    // feature, simply include more values in the csvInstance array, like this... 
    // $predictionData->setCsvInstance(array($data1, $data2, ..., $dataN)); 
    $input = new Input(); 
    $input->setInput($predictionData); 
    print_r($predictionService->trainedmodels->predict($id, $input)); 

이 예측 요청에서 포맷되지 않은 JSON 응답을 표시 같은 : 다음은 마법 순서입니다

Array ([kind] => prediction#output [id] => languages [selfLink] =>  
https://www.googleapis.com/prediction/v1.4/trainedmodels/languages/predict 
[outputLabel] => French [outputMulti] => Array ([0] => Array ([label] => 
English [score] => 0.333297) [1] => Array ([label] => French [score] => 
0.339412) [2] => Array ([label] => Spanish [score] => 0.327291))) 
관련 문제