(self, label, index, example=None, cost=None)
Adding entry to the oracle.

        Add new entry to the oracle for future querying where index is the queried elements,
        label is the returned data. Index should not be in the oracle. Example and cost should
        accord with the initializing (If exists in initializing, then must be provided.)

        Parameters
        ----------
        label:  array-like
            Label matrix.

        index: int
            Index of examples, should not in the oracle.

        example: array-like, optional (default=None)
            Array of examples.

        cost: array_like, optional (default=None)
            Cost of each queried instance.
Adding entry to the oracle.
Adding entry to the oracle .
def _add_one_entry(self, label, index, example=None, cost=None):
        """Adding entry to the oracle.

        Add new entry to the oracle for future querying where index is the queried elements,
        label is the returned data. Index should not be in the oracle. Example and cost should
        accord with the initializing (If exists in initializing, then must be provided.)

        Parameters
        ----------
        label:  array-like
            Label matrix.

        index: int
            Index of examples, should not in the oracle.

        example: array-like, optional (default=None)
            Array of examples.

        cost: array_like, optional (default=None)
            Cost of each queried instance.
        """
        if index in self._ind2all.keys():
            warnings.warn("The entry for adding has already exist in the oracle. Skip.")
            return

        if len(label) != self._label_shape[1]:
            raise ValueError(
                "Different dimension of labels found when adding entries: %s is expected but received: %s" %
                (str(self._label_shape[1]), str(len(label))))
        if self._instance_flag:
            if example is None:
                raise Exception("This oracle has the instance information,"
                                "must provide example parameter when adding entry")
            example = tuple(example)
            self._exa2ind[example] = index
        if self._cost_flag:
            if cost is None:
                if self._fine_grained_cost == False:
                    cost = copy.copy(self._label_cost)
                else:
                    raise Exception("This oracle has a fine-grained cost matrix, "
                                    "the cost of a new entry must be provided.")
            if len(cost) != self._label_shape[1]:
                raise ValueError(
                    "Different dimension of cost found when adding entries: %s is expected but received: %s" %
                    (str(self._label_shape[1]), str(len(cost))))
            self._ind2all[index] = (np.array(label), cost)
        else:
            self._ind2all[index] = np.array(label)
def _add_one_entry ( self , label , index , example = None , cost = None ) : if index in self . _ind2all . keys ( ) : warnings . warn ( "The entry for adding has already exist in the oracle. Skip." ) return if len ( label ) != self . _label_shape [ 1 ] : raise ValueError ( "Different dimension of labels found when adding entries: %s is expected but received: %s" % ( str ( self . _label_shape [ 1 ] ) , str ( len ( label ) ) ) ) if self . _instance_flag : if example is None : raise Exception ( "This oracle has the instance information," "must provide example parameter when adding entry" ) example = tuple ( example ) self . _exa2ind [ example ] = index if self . _cost_flag : if cost is None : if self . _fine_grained_cost == False : cost = copy . copy ( self . _label_cost ) else : raise Exception ( "This oracle has a fine-grained cost matrix, " "the cost of a new entry must be provided." ) if len ( cost ) != self . _label_shape [ 1 ] : raise ValueError ( "Different dimension of cost found when adding entries: %s is expected but received: %s" % ( str ( self . _label_shape [ 1 ] ) , str ( len ( cost ) ) ) ) self . _ind2all [ index ] = ( np . array ( label ) , cost ) else : self . _ind2all [ index ] = np . array ( label )