def get_deepnet(self, deepnet, query_string='', shared_username=None, shared_api_key=None): """Retrieves a deepnet. The model parameter should be a string containing the deepnet id or the dict returned by create_deepnet. As a deepnet is an evolving object that is processed until it reaches the FINISHED or FAULTY state, the function will return a dict that encloses the deepnet values and state info available at the time it is called. If this is a shared deepnet, the username and sharing api key must also be provided. """ check_resource_type(deepnet, DEEPNET_PATH, message="A deepnet id is needed.") deepnet_id = get_deepnet_id(deepnet) if deepnet_id: return self._get("%s%s" % (self.url, deepnet_id), query_string=query_string, shared_username=shared_username, shared_api_key=shared_api_key)
def delete_deepnet(self, deepnet): """Deletes a deepnet. """ check_resource_type(deepnet, DEEPNET_PATH, message="A deepnet id is needed.") deepnet_id = get_deepnet_id(deepnet) if deepnet_id: return self._delete("%s%s" % (self.url, deepnet_id))
def delete_deepnet(self, deepnet): """Deletes a deepnet. """ check_resource_type(deepnet, DEEPNET_PATH, message="A deepnet id is needed.") deepnet_id = get_deepnet_id(deepnet) if deepnet_id: return self._delete("%s%s" % (self.url, deepnet_id))
def update_deepnet(self, deepnet, changes): """Updates a deepnet. """ check_resource_type(deepnet, DEEPNET_PATH, message="A deepnet id is needed.") deepnet_id = get_deepnet_id(deepnet) if deepnet_id: body = json.dumps(changes) return self._update("%s%s" % (self.url, deepnet_id), body)
def update_deepnet(self, deepnet, changes): """Updates a deepnet. """ check_resource_type(deepnet, DEEPNET_PATH, message="A deepnet id is needed.") deepnet_id = get_deepnet_id(deepnet) if deepnet_id: body = json.dumps(changes) return self._update( "%s%s" % (self.url, deepnet_id), body)
def get_deepnet(self, deepnet, query_string='', shared_username=None, shared_api_key=None): """Retrieves a deepnet. The model parameter should be a string containing the deepnet id or the dict returned by create_deepnet. As a deepnet is an evolving object that is processed until it reaches the FINISHED or FAULTY state, the function will return a dict that encloses the deepnet values and state info available at the time it is called. If this is a shared deepnet, the username and sharing api key must also be provided. """ check_resource_type(deepnet, DEEPNET_PATH, message="A deepnet id is needed.") deepnet_id = get_deepnet_id(deepnet) if deepnet_id: return self._get("%s%s" % (self.url, deepnet_id), query_string=query_string, shared_username=shared_username, shared_api_key=shared_api_key)
def create_prediction(self, model, input_data=None, args=None, wait_time=3, retries=10): """Creates a new prediction. The model parameter can be: - a simple tree model - a simple logistic regression model - an ensemble - a deepnet Note that the old `by_name` argument has been deprecated. """ deepnet_id = None logistic_regression_id = None ensemble_id = None model_id = None resource_type = get_resource_type(model) if resource_type == ENSEMBLE_PATH: ensemble_id = get_ensemble_id(model) if ensemble_id is not None: check_resource(ensemble_id, query_string=TINY_RESOURCE, wait_time=wait_time, retries=retries, raise_on_error=True, api=self) elif resource_type == MODEL_PATH: model_id = get_model_id(model) check_resource(model_id, query_string=TINY_RESOURCE, wait_time=wait_time, retries=retries, raise_on_error=True, api=self) elif resource_type == LOGISTIC_REGRESSION_PATH: logistic_regression_id = get_logistic_regression_id(model) check_resource(logistic_regression_id, query_string=TINY_RESOURCE, wait_time=wait_time, retries=retries, raise_on_error=True, api=self) elif resource_type == DEEPNET_PATH: deepnet_id = get_deepnet_id(model) check_resource(deepnet_id, query_string=TINY_RESOURCE, wait_time=wait_time, retries=retries, raise_on_error=True, api=self) else: raise Exception("A model or ensemble id is needed to create a" " prediction. %s found." % resource_type) if input_data is None: input_data = {} create_args = {} if args is not None: create_args.update(args) create_args.update({"input_data": input_data}) if model_id is not None: create_args.update({"model": model_id}) elif ensemble_id is not None: create_args.update({"ensemble": ensemble_id}) elif logistic_regression_id is not None: create_args.update({"logisticregression": logistic_regression_id}) elif deepnet_id is not None: create_args.update({"deepnet": deepnet_id}) body = json.dumps(create_args) return self._create(self.prediction_url, body, verify=self.verify_prediction)