Esempio n. 1
0
    def predict(self, data, cloud=None, batch=False, api_key=None, version=None, **kwargs):
        """
        This is the prediction endpoint. This will be the primary interaction point for all predictive
        analysis.

        Inputs
        data - String: The text example being provided to the API. As a general rule, the data should be as
          similar to the examples given to the train function (above) as possible. Because language
          in different domains is used very differently the accuracy will generally drop as the
          difference between this text and the training text increases. Base64 encoded image data, image urls, and
          text content are all valid.
        domain (optional) - String: This is an identifier that helps determine the appropriate techniques for indico
          to use behind the scenes to train your model.  One of {"standard", "topics"}.
        collection (optional) - String: This is an identifier for the particular model to use for prediction. The
          response format for the given label will match the format of the training examples
        api_key (optional) - String: Your API key, required only if the key has not been declared
          elsewhere. This allows the API to recognize a request as yours and automatically route it
          to the appropriate destination.
        cloud (optional) - String: Your private cloud domain, required only if the key has not been declared
          elsewhere. This allows the API to recognize a request as yours and automatically route it
          to the appropriate destination.

        Example usage:

        .. code-block:: python

          >>> text = "I am Sam. Sam I am."
          >>> prediction = indicoio.predict(text)
          .75
        """
        batch = detect_batch(data)
        kwargs['collection'] = self.collection
        data = image_preprocess(data, batch=batch)
        url_params = {"batch": batch, "api_key": api_key, "version": version}
        return api_handler(data, cloud=cloud, api="custom", url_params=url_params, private=True, **kwargs)
Esempio n. 2
0
    def remove_example(self, data, cloud=None, batch=False, api_key=None, version=None, **kwargs):
        """
        This is an API made to remove a single instance of training data. This is useful in cases where a
        single instance of content has been modified, but the remaining examples remain valid. For
        example, if a piece of content has been retagged.

        Inputs
        data - String: The exact text you wish to remove from the given collection. If the string
          provided does not match a known piece of text then this will fail. Again, this is required if
          an id is not provided, and vice-versa.
        collection - String: the collection from which you wish to remove the specified text.
        api_key (optional) - String: Your API key, required only if the key has not been declared
          elsewhere. This allows the API to recognize a request as yours and automatically route it
          to the appropriate destination.
        cloud (optional) - String: Your private cloud domain, required only if the key has not been declared
          elsewhere. This allows the API to recognize a request as yours and automatically route it
          to the appropriate destination.

        Example usage:

        .. code-block:: python

          >>> indicoio.remove_example(text="I am Sam. Sam I am.", lablel="popularity_predictor")

        """
        kwargs['collection'] = self.collection
        batch = detect_batch(data)
        data = image_preprocess(data, batch=batch)
        url_params = {"batch": batch, "api_key": api_key, "version": version, 'method': 'remove_example'}
        return api_handler(data, cloud=cloud, api="custom", url_params=url_params, private=True, **kwargs)
Esempio n. 3
0
    def predict(self,
                data,
                cloud=None,
                batch=False,
                api_key=None,
                version=None,
                **kwargs):
        """
        This is the prediction endpoint. This will be the primary interaction point for all predictive
        analysis.

        Inputs
        data - String: The text example being provided to the API. As a general rule, the data should be as
          similar to the examples given to the train function (above) as possible. Because language
          in different domains is used very differently the accuracy will generally drop as the
          difference between this text and the training text increases. Base64 encoded image data, image urls, and
          text content are all valid.
        domain (optional) - String: This is an identifier that helps determine the appropriate techniques for indico
          to use behind the scenes to train your model.  One of {"standard", "topics"}.
        api_key (optional) - String: Your API key, required only if the key has not been declared
          elsewhere. This allows the API to recognize a request as yours and automatically route it
          to the appropriate destination.
        cloud (optional) - String: Your private cloud domain, required only if the key has not been declared
          elsewhere. This allows the API to recognize a request as yours and automatically route it
          to the appropriate destination.
        """
        batch = detect_batch(data)
        data = image_preprocess(data, batch=batch)
        url_params = {"batch": batch, "api_key": api_key, "version": version}
        return self._api_handler(data,
                                 cloud=cloud,
                                 api="custom",
                                 url_params=url_params,
                                 **kwargs)
Esempio n. 4
0
    def remove_example(self,
                       data,
                       cloud=None,
                       batch=False,
                       api_key=None,
                       version=None,
                       **kwargs):
        """
        This is an API made to remove a single instance of training data. This is useful in cases where a
        single instance of content has been modified, but the remaining examples remain valid. For
        example, if a piece of content has been retagged.

        Inputs
        data - String: The exact text you wish to remove from the given collection. If the string
          provided does not match a known piece of text then this will fail. Again, this is required if
          an id is not provided, and vice-versa.
        collection - String: the collection from which you wish to remove the specified text.
        api_key (optional) - String: Your API key, required only if the key has not been declared
          elsewhere. This allows the API to recognize a request as yours and automatically route it
          to the appropriate destination.
        cloud (optional) - String: Your private cloud domain, required only if the key has not been declared
          elsewhere. This allows the API to recognize a request as yours and automatically route it
          to the appropriate destination.

        Example usage:

        .. code-block:: python

          >>> indicoio.remove_example(text="I am Sam. Sam I am.", lablel="popularity_predictor")

        """
        kwargs['collection'] = self.collection
        batch = detect_batch(data)
        data = image_preprocess(data, batch=batch)
        url_params = {
            "batch": batch,
            "api_key": api_key,
            "version": version,
            'method': 'remove_example'
        }
        return api_handler(data,
                           cloud=cloud,
                           api="custom",
                           url_params=url_params,
                           private=True,
                           **kwargs)