(self, label, select_index, cost=None, example=None)
return self
Add an element to the repository.

        Parameters
        ----------
        select_index: int or tuple
            The selected index in active learning.

        label: object
            Label given by oracle, shape should be the same with the labels in initializing.

        cost: object
            Cost produced by query, given by the oracle.

        example: array
            Feature vector of an instance.
Add an element to the repository.
Add an element to the repository .
def add(self, label, select_index, cost=None, example=None):
        """Add an element to the repository.

        Parameters
        ----------
        select_index: int or tuple
            The selected index in active learning.

        label: object
            Label given by oracle, shape should be the same with the labels in initializing.

        cost: object
            Cost produced by query, given by the oracle.

        example: array
            Feature vector of an instance.
        """
        # check validation
        if select_index in self._indexes:
            warnings.warn("Repeated index is found when adding element to knowledge repository. Skip this item",
                          category=RepeatElementWarning)
            return self
        if self._y.ndim == 1:
            if hasattr(label, '__len__'):
                raise TypeError("The initialized label array only have 1 dimension, "
                                "but received an array like label: %s." % str(label))
            self._y = np.append(self._y, [label])
        else:
            # this operation will check the validity automatically.
            self._y = np.append(self._y, [label], axis=0)
        self._indexes = np.append(self._indexes, select_index)
        self._cost_arr.append(cost)
        self.cost_inall += np.sum(cost) if cost is not None else 0
        if self._instance_flag:
            if example is None:
                raise Exception("This repository has the instance information,"
                                "must provide example parameter when adding entry")
            else:
                self._X = np.append(self._X, [example], axis=0)
        return self
def add ( self , label , select_index , cost = None , example = None ) : # check validation if select_index in self . _indexes : warnings . warn ( "Repeated index is found when adding element to knowledge repository. Skip this item" , category = RepeatElementWarning ) return self if self . _y . ndim == 1 : if hasattr ( label , '__len__' ) : raise TypeError ( "The initialized label array only have 1 dimension, " "but received an array like label: %s." % str ( label ) ) self . _y = np . append ( self . _y , [ label ] ) else : # this operation will check the validity automatically. self . _y = np . append ( self . _y , [ label ] , axis = 0 ) self . _indexes = np . append ( self . _indexes , select_index ) self . _cost_arr . append ( cost ) self . cost_inall += np . sum ( cost ) if cost is not None else 0 if self . _instance_flag : if example is None : raise Exception ( "This repository has the instance information," "must provide example parameter when adding entry" ) else : self . _X = np . append ( self . _X , [ example ] , axis = 0 ) return self