(self, examples)
return self.query_by_index(q_id)
Query function, query information giving an instance.

        Note that, this function only available if initializes with
        data matrix.

        In multi-label setting, a query index is a tuple.
        A single index should only have 1 element (feature_vector, ) to query all _labels or
        2 elements (feature_vector, [label_indexes]) to query specific _labels.
        A list of index can be provided.

        Parameters
        ----------
        examples: array_like
            [n_samples, n_features]

        Returns
        -------
        labels: list
            supervised information of queried instance.

        cost: list
            Corresponding cost produced by query.
Query function, query information giving an instance.
Query function query information giving an instance .
def query_by_example(self, examples):
        """Query function, query information giving an instance.

        Note that, this function only available if initializes with
        data matrix.

        In multi-label setting, a query index is a tuple.
        A single index should only have 1 element (feature_vector, ) to query all _labels or
        2 elements (feature_vector, [label_indexes]) to query specific _labels.
        A list of index can be provided.

        Parameters
        ----------
        examples: array_like
            [n_samples, n_features]

        Returns
        -------
        labels: list
            supervised information of queried instance.

        cost: list
            Corresponding cost produced by query.
        """
        if not self._instance_flag:
            raise Exception("This oracle do not have the instance information, query_by_example is not supported.")
        # check validity of the given examples
        if not isinstance(examples, (list, np.ndarray)):
            examples = [examples]

        q_id = []
        for k in examples:
            # k is a tuple with 2 elements
            k_len = len(k)
            if k_len != 1 and k_len != 2:
                raise ValueError(
                    "A single index should only have 1 element (feature_vector, ) to query all _labels or"
                    "2 elements (feature_vector, [label_indexes]) to query specific _labels. But found %d in %s" %
                    (len(k), str(k)))
            example_fea = tuple(k[0])

            # fetch data
            if example_fea in self._exa2ind.keys():
                if k_len == 1:
                    q_id.append((example_fea,))
                else:
                    q_id.append((example_fea, k[1]))
            else:
                self._do_missing(example_fea, 'instance pool')
        return self.query_by_index(q_id)
def query_by_example ( self , examples ) : if not self . _instance_flag : raise Exception ( "This oracle do not have the instance information, query_by_example is not supported." ) # check validity of the given examples if not isinstance ( examples , ( list , np . ndarray ) ) : examples = [ examples ] q_id = [ ] for k in examples : # k is a tuple with 2 elements k_len = len ( k ) if k_len != 1 and k_len != 2 : raise ValueError ( "A single index should only have 1 element (feature_vector, ) to query all _labels or" "2 elements (feature_vector, [label_indexes]) to query specific _labels. But found %d in %s" % ( len ( k ) , str ( k ) ) ) example_fea = tuple ( k [ 0 ] ) # fetch data if example_fea in self . _exa2ind . keys ( ) : if k_len == 1 : q_id . append ( ( example_fea , ) ) else : q_id . append ( ( example_fea , k [ 1 ] ) ) else : self . _do_missing ( example_fea , 'instance pool' ) return self . query_by_index ( q_id )