(self, label_index, unlabel_index, oracle=None, cost=None, budget=40, basemodel=None, models=None)
return multilabel_index
Selects the most uncertrainty instance-label pairs under the 
        constraints of meeting the budget conditions.
        
        Parameters
        ----------
        label_index: MultiLabelIndexCollection
            The indexes of labeled samples. It should be a 1d array of indexes (column major, start from 0) or
            MultiLabelIndexCollection or a list of tuples with 2 elements, in which,
            the 1st element is the index of instance and the 2nd element is the index of labels.

        unlabel_index: MultiLabelIndexCollection
            The indexes of unlabeled samples. It should be a 1d array of indexes (column major, start from 0) or
            MultiLabelIndexCollection or a list of tuples with 2 elements, in which,
            the 1st element is the index of instance and the 2nd element is the index of labels.

        oracle: Oracle,(default=None)
            Oracle indicate the cost for each label.
            Oracle in active learning whose role is to label the given query.And it can also give the cost of 
            each corresponding label.The Oracle includes the label and cost information at least.
            Oracle(labels=labels, cost=cost)

        cost: np.array, (default=None), shape [1, n_classes] or [n_classes]
            the cost of querying each class.if not provide,it will all be 1. 

        budget: int, optional (default=40)
            The budget of the select cost.If cost for eatch labels is 1,will degenerate into the batch_size.

        models: object, optional (default=None)
            Current classification model, should have the 'predict_proba' method for probabilistic output.
            If not provided,it will build the model based the base_model.
        
        base_model: object, optional(default=None)
            The classification model for eatch label,if the models is not provided.It will build a classifi
            -cation model for the multilabel taks.If not provided, SVM with default parameters implemented
             by sklearn will be used.

        Returns
        -------
        selected_ins_lab_pair: list
            A list of tuples that contains the indexes of selected instance-label pairs.
Selects the most uncertrainty instance-label pairs under the 
        constraints of meeting the budget conditions.
        
        Parameters
        ----------
        label_index: MultiLabelIndexCollection
            The indexes of labeled samples. It should be a 1d array of indexes (column major, start from 0) or
            MultiLabelIndexCollection or a list of tuples with 2 elements, in which,
            the 1st element is the index of instance and the 2nd element is the index of labels.
Selects the most uncertrainty instance - label pairs under the constraints of meeting the budget conditions . Parameters ---------- label_index : MultiLabelIndexCollection The indexes of labeled samples . It should be a 1d array of indexes ( column major start from 0 ) or MultiLabelIndexCollection or a list of tuples with 2 elements in which the 1st element is the index of instance and the 2nd element is the index of labels .
def select(self, label_index, unlabel_index, oracle=None, cost=None, budget=40, basemodel=None, models=None):
        """Selects the most uncertrainty instance-label pairs under the 
        constraints of meeting the budget conditions.
        
        Parameters
        ----------
        label_index: MultiLabelIndexCollection
            The indexes of labeled samples. It should be a 1d array of indexes (column major, start from 0) or
            MultiLabelIndexCollection or a list of tuples with 2 elements, in which,
            the 1st element is the index of instance and the 2nd element is the index of labels.

        unlabel_index: MultiLabelIndexCollection
            The indexes of unlabeled samples. It should be a 1d array of indexes (column major, start from 0) or
            MultiLabelIndexCollection or a list of tuples with 2 elements, in which,
            the 1st element is the index of instance and the 2nd element is the index of labels.

        oracle: Oracle,(default=None)
            Oracle indicate the cost for each label.
            Oracle in active learning whose role is to label the given query.And it can also give the cost of 
            each corresponding label.The Oracle includes the label and cost information at least.
            Oracle(labels=labels, cost=cost)

        cost: np.array, (default=None), shape [1, n_classes] or [n_classes]
            the cost of querying each class.if not provide,it will all be 1. 

        budget: int, optional (default=40)
            The budget of the select cost.If cost for eatch labels is 1,will degenerate into the batch_size.

        models: object, optional (default=None)
            Current classification model, should have the 'predict_proba' method for probabilistic output.
            If not provided,it will build the model based the base_model.
        
        base_model: object, optional(default=None)
            The classification model for eatch label,if the models is not provided.It will build a classifi
            -cation model for the multilabel taks.If not provided, SVM with default parameters implemented
             by sklearn will be used.

        Returns
        -------
        selected_ins_lab_pair: list
            A list of tuples that contains the indexes of selected instance-label pairs. 
        """
        unlabel_index = self._check_multi_label_ind(unlabel_index)
        n_classes = unlabel_index._label_size
        if cost is not None:
            cost = np.asarray(cost).flatten()
            assert(len(cost) == n_classes)

        if oracle is None and cost is None:
            cost = [1]*n_classes

        if oracle:
            _, costs = oracle.query_by_index(range(self.n_classes))
        else:
            costs = cost
        if models is None:
            models = self.train_models(label_index, basemodel)


        unlabel_index = self._check_multi_label_ind(unlabel_index)
        target = unlabel_index.get_matrix_mask((self.n_samples, self.n_classes), sparse=False)
        uncertainty = self.cal_uncertainty(target, models)
        instance_pair = np.array([0, 0])
        infor_value=np.array([0])
        corresponding_cost = np.array([0],dtype=int)

        # sort the infor in descent way,in the meanwhile record instance label pair
        for j in np.arange(self.n_classes):
            j_info = uncertainty[:, j]
            sort_index = np.argsort(j_info)
            sort_index = sort_index[::-1]
            sort_index = sort_index[0: budget]
            useless_index = np.where(uncertainty[sort_index][j] == -np.infty)
            sort_index = sort_index[: budget - len(useless_index)]  
            j_instance_pair = np.column_stack((sort_index, np.ones(len(sort_index), dtype=int) * j))
            for k in sort_index:
                infor_value = np.r_[infor_value, uncertainty[k][j]]
            # infor_value = np.r_[infor_value, uncertainty[sort_index][j]]
            corresponding_cost = np.r_[corresponding_cost, np.ones(len(sort_index),dtype=int) * costs[j]]
            instance_pair = np.vstack((instance_pair, j_instance_pair))
        
        instance_pair = instance_pair[1:,]
        infor_value = infor_value[1:]
        corresponding_cost = corresponding_cost[1:]

        _ , select_result = select_Knapsack_01(infor_value, corresponding_cost, budget)
        multilabel_index = [tuple(i) for i in list(instance_pair[np.where(select_result!=0)[0]])]
        # return MultiLabelIndexCollection(multilabel_index, label_size=self.n_classes)
        return multilabel_index
def select ( self , label_index , unlabel_index , oracle = None , cost = None , budget = 40 , basemodel = None , models = None ) : unlabel_index = self . _check_multi_label_ind ( unlabel_index ) n_classes = unlabel_index . _label_size if cost is not None : cost = np . asarray ( cost ) . flatten ( ) assert ( len ( cost ) == n_classes ) if oracle is None and cost is None : cost = [ 1 ] * n_classes if oracle : _ , costs = oracle . query_by_index ( range ( self . n_classes ) ) else : costs = cost if models is None : models = self . train_models ( label_index , basemodel ) unlabel_index = self . _check_multi_label_ind ( unlabel_index ) target = unlabel_index . get_matrix_mask ( ( self . n_samples , self . n_classes ) , sparse = False ) uncertainty = self . cal_uncertainty ( target , models ) instance_pair = np . array ( [ 0 , 0 ] ) infor_value = np . array ( [ 0 ] ) corresponding_cost = np . array ( [ 0 ] , dtype = int ) # sort the infor in descent way,in the meanwhile record instance label pair for j in np . arange ( self . n_classes ) : j_info = uncertainty [ : , j ] sort_index = np . argsort ( j_info ) sort_index = sort_index [ : : - 1 ] sort_index = sort_index [ 0 : budget ] useless_index = np . where ( uncertainty [ sort_index ] [ j ] == - np . infty ) sort_index = sort_index [ : budget - len ( useless_index ) ] j_instance_pair = np . column_stack ( ( sort_index , np . ones ( len ( sort_index ) , dtype = int ) * j ) ) for k in sort_index : infor_value = np . r_ [ infor_value , uncertainty [ k ] [ j ] ] # infor_value = np.r_[infor_value, uncertainty[sort_index][j]] corresponding_cost = np . r_ [ corresponding_cost , np . ones ( len ( sort_index ) , dtype = int ) * costs [ j ] ] instance_pair = np . vstack ( ( instance_pair , j_instance_pair ) ) instance_pair = instance_pair [ 1 : , ] infor_value = infor_value [ 1 : ] corresponding_cost = corresponding_cost [ 1 : ] _ , select_result = select_Knapsack_01 ( infor_value , corresponding_cost , budget ) multilabel_index = [ tuple ( i ) for i in list ( instance_pair [ np . where ( select_result != 0 ) [ 0 ] ] ) ] # return MultiLabelIndexCollection(multilabel_index, label_size=self.n_classes) return multilabel_index