Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from oauth2client.client import GoogleCredentials
- from googleapiclient import discovery
- from googleapiclient import errors
- from google.api_core.client_options import ClientOptions
- # Store your full project ID in a variable in the format the API needs.
- project_id = 'projects/{}'.format('imageeditorbackend')
- prefix = "{}-ml".format('us-east1')
- api_endpoint = "https://{}.googleapis.com".format(prefix)
- client_options = ClientOptions(api_endpoint=api_endpoint)
- #service = googleapiclient.discovery.build('ml', 'v1', client_options=client_options)
- # Build a representation of the Cloud ML API.
- ml = discovery.build('ml', 'v1', client_options=client_options)
- project = 'imageeditorbackend'
- model = 'modelo_teste'
- name = 'projects/{}/models/{}'.format(project, model)
- instances = [
- [56, "housemaid", "married", "basic.4y", "no", "no", "no", "telephone", "may", "mon", 261, 1, 999, 0, "nonexistent", 1.1, 93.994, -36.4, 4.857, 5191, "no"]
- ]
- # Create a dictionary with the fields from the request body.
- request_dict = {'name': name,
- 'body':{'instances': instances}
- }
- # Create a request to call projects.models.create.
- request = ml.projects().predict(
- name=name,
- body={'instances': instances}
- )
- # Make the call.
- try:
- response = request.execute()
- print(response)
- except error:
- # Something went wrong, print out some information.
- print('There was an error creating the model. Check the details:')
- print(error)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement