(self, label_index, unlabel_index, cost=None, oracle=None, budget=40, models=None, base_model=None)
return multilabel_index
Selects a batch of instance-label pairs with most information and least cost.

        Parameters
        ----------
        label_index: {list, np.ndarray, 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: {list, np.ndarray, 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.

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

        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)

        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 a batch of instance-label pairs with most information and least cost.
Selects a batch of instance - label pairs with most information and least cost .
def select(self, label_index, unlabel_index, cost=None, oracle=None, budget=40, models=None, base_model=None):
        """ Selects a batch of instance-label pairs with most information and least cost.

        Parameters
        ----------
        label_index: {list, np.ndarray, 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: {list, np.ndarray, 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.

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

        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)

        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.      
        """
        label_index = self._check_multi_label_ind(label_index)
        unlabel_index = self._check_multi_label_ind(unlabel_index)
        n_classes = self.y.shape[1]

        if models is None:
            models = self.train_models(label_index, base_model)

        if cost is not None:
            cost = np.asarray(cost).flatten()
            assert(len(cost) == self.y.shape[1])

        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
        
        Infor = self.cal_Informativeness(label_index, unlabel_index, 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 = Infor[:, j]
            sort_index = np.argsort(j_info)
            sort_index = sort_index[::-1]
            sort_index = sort_index[0: budget]
            useless_index = np.where(Infor[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, Infor[k][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:]

        max_value, select_result = select_Knapsack_01(infor_value, corresponding_cost, budget)
        # max_value, select_result = select_POSS(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 , cost = None , oracle = None , budget = 40 , models = None , base_model = None ) : label_index = self . _check_multi_label_ind ( label_index ) unlabel_index = self . _check_multi_label_ind ( unlabel_index ) n_classes = self . y . shape [ 1 ] if models is None : models = self . train_models ( label_index , base_model ) if cost is not None : cost = np . asarray ( cost ) . flatten ( ) assert ( len ( cost ) == self . y . shape [ 1 ] ) 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 Infor = self . cal_Informativeness ( label_index , unlabel_index , 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 = Infor [ : , j ] sort_index = np . argsort ( j_info ) sort_index = sort_index [ : : - 1 ] sort_index = sort_index [ 0 : budget ] useless_index = np . where ( Infor [ 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 , Infor [ k ] [ 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 : ] max_value , select_result = select_Knapsack_01 ( infor_value , corresponding_cost , budget ) # max_value, select_result = select_POSS(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