Package: dato-predictive-service-client
The purpose of the Dato Predictive Service Python Client library is to allow
Python applications to easily query Dato Predictive Services.InstallationTo install Dato Predictive Service Python Client, simply:sudopipinstalldato-predictive-service-clientor from source:sudopythonsetup.pyinstallRequirementsDato Predictive Service, launched by GraphLab-Create >= 1.4 installationUsageCreate ClientTo use the Dato Predictive Service Python Client, first you need to obtain the
following information from a running Dato Predictive Service:Predictive Service CNAME or DNS name (endpoint)API key from the Predictive ServiceOnce you have obtained the above information, simply create a new PredictiveServiceClient:fromdato.deployimportPredictiveServiceClient;client=PredictiveServiceClient(endpoint=<endpoint>,api_key=<api_key>,should_verify_certificate=<True-or-False>)To enable SSL certificate verification for this Predictive Service,
set theshould_verify_certificatetotrue. However, if your Predictive Service
is launched with a self-signed certificate or without certificate, please
setshould_verify_certificatetofalse.The PredictiveServiceClient can also be created by using a Predictive Serviceclient configuration file.client=PredictiveServiceClient(config_file=<path_to_file>)QueryTo query a model that is deployed on the Predictive Service, you will need:model namemethod to query (recommend, predict, query, etc.)data used to query against the modelFor example, the code below demonstrates how to query a recommender model, namedrec, for recommendations for user`Jacob Smith`:data={'users':['Jacob Smith']}result=client.query('rec',method='recommend',data=data)NotesDifferent models could support different query methods (recommend, predict, query, etc.)
and different syntax and format fordata. You will need to know the
supported methods and query data format before querying the model.Set timeoutTo change the request timeout when querying the Predictive Service, use the following:# set timeout to 5 seconds.client.set_query_timeout(timeout=5)The default timeout is 10 seconds.ResultsThe output to thequery()function is a dictionary of the query result.If query is successful, the query result contains:model responseuuid for this queryversion of the modelmodel_response=result['response']uuid=result['uuid']version=result['version']model_responsecontains the actual model output from your query.Send feedbackOnce you get the query result, you can submit feedback data corresponding to this query
back to the Predictive Service. This feedback data can be used for evaluating your
current model and training future models.To submit feedback data corresponding to a particular query, you will need the UUID
of the query. The UUID can be easily obtained from the query result.uuid=result['uuid']For the feedback data, you can use any attributes or value pairs that you like.Example:feedback_data=dict()feedback_data['num_of_clicks']=3feedback_data['searched_terms']='test'Now we can send this feedback data to the Predictive
Service to associate this feedback with a particular query.client.feedback(uuid,feedback_data);More InfoFor more information about the Dato Predictive Service, please read
theAPI docsanduserguide.LicenseThe Dato Predictive Service Python Client is provided under the 3-clause BSDlicense.