pythonmachine-learninggoogle-prediction

What parameters ml.projects.predict function have and how to call it?


I trying to use this https://cloud.google.com/ml/reference/rest/v1beta1/projects/predict function. By following this https://cloud.google.com/ml/docs/quickstarts/prediction example I uploaded deployable version of mnist code, created model and version for it. Now I want to get some prediction results from it from python code.

By reading this function description I don't understand how I supposed to run it. I don't see where is it's parameters description and how they should look like.

For example I used this code to create learning task:

credentials = GoogleCredentials.get_application_default()
ml = discovery.build('ml','v1beta1', credentials=credentials)
projectID = 'projects/{}'.format('testml')
jobDict = { 'jobId': 'test_job_3', 'trainingInput': { 'scaleTier': 'BASIC', 'packageUris': [ 'gs://testml-ml/
cloudmldist/1479282298/trainer-0.0.0.tar.gz' ], 'pythonModule': 'trainer.task', 'args': [ '--train_dir=gs://testml-ml/
test_job3_results' ], 'region': 'us-central1' } }
request = ml.projects().jobs().create(parent = projectID, body = jobDict)
response = request.execute()

I were calling jobs.create function with parameters: parent and body. I don't understand from the documentation what parameters is needed for projects.predict function and how to build them. There is written about output format, but input arguments skipped.


Solution

  • Perhaps you're confused because predict takes a wrapper as the argument, that HTTP body you see listed. This is the wrapper, in HTTP request format, containing a list of instances. The format of the instances is determined by the model you built; predict is simply a communication channel. You put that after "?data=" in your prediction request.