How to access Google Prediction API with Python? -


i have practice project given me advisor asks me write python script access model trained prediction api using api explorer. have 2 questions regarding this,

  1. the guidelines specify should not check in credentials in python script , not sure means, leads question...

  2. when follow documentation call "predict" method of "trainedmodels" (to predict language of text using trained model)

    from apiclient import discovery  service = discovery.build('prediction','v1.6') x = service.trainedmodels().predict(project='my first project',       id='my_project_id',       body={"input":{"csvinstance":['bonjour!']}}) 

this return value

    <googleapiclient.http.httprequest object @ 0x1031996d0> 

because not aware of meant "not checking in credentials", unclear how proceed in resolving problem.

thank in advance.

there @ least ways achieve that:

here's snippet showing how access credentials within python:

http = appassertioncredentials('https://www.googleapis.com/auth/prediction https://www.googleapis.com/auth/devstorage.read_only').authorize(httplib2.http()) service = build('prediction', 'v1.6', http=http) 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -