(self, label_index, unlabel_index, batch_size=1, **kwargs)
return list(batch)
Select indexes from the unlabel_index for querying.

        Parameters
        ----------
        label_index: {list, np.ndarray, IndexCollection}
            The indexes of labeled samples.

        unlabel_index: {list, np.ndarray, IndexCollection}
            The indexes of unlabeled samples.

        batch_size: int, optional (default=1)
            Selection batch size.

        Returns
        -------
        selected_idx: list
            The selected indexes which is a subset of unlabel_index.
Select indexes from the unlabel_index for querying.
Select indexes from the unlabel_index for querying .
def select(self, label_index, unlabel_index, batch_size=1, **kwargs):
        """Select indexes from the unlabel_index for querying.

        Parameters
        ----------
        label_index: {list, np.ndarray, IndexCollection}
            The indexes of labeled samples.

        unlabel_index: {list, np.ndarray, IndexCollection}
            The indexes of unlabeled samples.

        batch_size: int, optional (default=1)
            Selection batch size.

        Returns
        -------
        selected_idx: list
            The selected indexes which is a subset of unlabel_index.
        """
        # If a neighbor has already been sampled, reduce the graph density
        # for its direct neighbors to promote diversity.
        assert (batch_size > 0)
        assert (isinstance(unlabel_index, collections.Iterable))
        assert (isinstance(label_index, collections.Iterable))
        unlabel_index = np.asarray(unlabel_index)
        label_index = np.asarray(label_index)
        if len(unlabel_index) <= batch_size:
            return unlabel_index
        batch = set()

        # build map from value to index
        try:
            label_index_in_train = [self.train_idx.index(i) for i in label_index]
        except:
            label_index_in_train = [np.where(self.train_idx == i)[0][0] for i in label_index]
        # end

        self.graph_density[label_index_in_train] = min(self.graph_density) - 1
        selected_arr = []
        while len(batch) < batch_size:
            selected = np.argmax(self.graph_density)
            selected_arr.append(selected)
            neighbors = (self.connect[selected, :] > 0).nonzero()[1]
            self.graph_density[neighbors] = self.graph_density[neighbors] - self.graph_density[selected]
            assert (self.train_idx[selected] in unlabel_index)
            batch.add(self.train_idx[selected])
            self.graph_density[label_index_in_train] = min(self.graph_density) - 1
            # self.graph_density[list(batch)] = min(self.graph_density) - 1
            self.graph_density[selected_arr] = min(self.graph_density) - 1
        return list(batch)
def select ( self , label_index , unlabel_index , batch_size = 1 , * * kwargs ) : # If a neighbor has already been sampled, reduce the graph density # for its direct neighbors to promote diversity. assert ( batch_size > 0 ) assert ( isinstance ( unlabel_index , collections . Iterable ) ) assert ( isinstance ( label_index , collections . Iterable ) ) unlabel_index = np . asarray ( unlabel_index ) label_index = np . asarray ( label_index ) if len ( unlabel_index ) <= batch_size : return unlabel_index batch = set ( ) # build map from value to index try : label_index_in_train = [ self . train_idx . index ( i ) for i in label_index ] except : label_index_in_train = [ np . where ( self . train_idx == i ) [ 0 ] [ 0 ] for i in label_index ] # end self . graph_density [ label_index_in_train ] = min ( self . graph_density ) - 1 selected_arr = [ ] while len ( batch ) < batch_size : selected = np . argmax ( self . graph_density ) selected_arr . append ( selected ) neighbors = ( self . connect [ selected , : ] > 0 ) . nonzero ( ) [ 1 ] self . graph_density [ neighbors ] = self . graph_density [ neighbors ] - self . graph_density [ selected ] assert ( self . train_idx [ selected ] in unlabel_index ) batch . add ( self . train_idx [ selected ] ) self . graph_density [ label_index_in_train ] = min ( self . graph_density ) - 1 # self.graph_density[list(batch)] = min(self.graph_density) - 1 self . graph_density [ selected_arr ] = min ( self . graph_density ) - 1 return list ( batch )