(self, label_index, unlabel_index, **kwargs)
return [self._train_idx[query_index]]
Select one instance 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.

        Returns
        -------
        selected_idx: list
            The selected indexes which is a subset of unlabel_index.
Select one instance from the unlabel_index for querying.
Select one instance from the unlabel_index for querying .
def select(self, label_index, unlabel_index, **kwargs):
        """Select one instance 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.

        Returns
        -------
        selected_idx: list
            The selected indexes which is a subset of unlabel_index.
        """
        assert (isinstance(unlabel_index, collections.Iterable))
        assert (isinstance(label_index, collections.Iterable))
        if len(unlabel_index) <= 1:
            return list(unlabel_index)
        unlabel_index = np.asarray(unlabel_index)
        label_index = np.asarray(label_index)

        # build map from value to index
        label_index_in_train = [np.where(self._train_idx == i)[0][0] for i in label_index]
        unlabel_index_in_train = [np.where(self._train_idx == i)[0][0] for i in unlabel_index]
        # end

        L = self.L
        Lindex = list(label_index_in_train)
        Uindex = list(unlabel_index_in_train)
        query_index = -1
        min_eva = np.inf
        # y_labeled = np.array([label for label in self.y if label is not None])
        y_labeled = self.y[Lindex]
        det_Laa = np.linalg.det(L[np.ix_(Uindex, Uindex)])
        # efficient computation of inv(Laa)
        M3 = np.dot(self.K[np.ix_(Uindex, Lindex)],
                    np.linalg.inv(self.lmbda * np.eye(len(Lindex))))
        M2 = np.dot(M3, self.K[np.ix_(Lindex, Uindex)])
        M1 = self.lmbda * np.eye(len(Uindex)) + self.K[np.ix_(Uindex, Uindex)]
        inv_Laa = M1 - M2
        iList = list(range(len(Uindex)))
        if len(iList) == 1:
            return Uindex[0]
        for i, each_index in enumerate(Uindex):
            # go through all unlabeled instances and compute their evaluation
            # values one by one
            Uindex_r = Uindex[:]
            Uindex_r.remove(each_index)
            iList_r = iList[:]
            iList_r.remove(i)
            inv_Luu = inv_Laa[np.ix_(iList_r, iList_r)] - 1 / inv_Laa[i, i] * \
                                                          np.dot(inv_Laa[iList_r, i], inv_Laa[iList_r, i].T)
            tmp = np.dot(
                L[each_index][Lindex] -
                np.dot(
                    np.dot(
                        L[each_index][Uindex_r],
                        inv_Luu
                    ),
                    L[np.ix_(Uindex_r, Lindex)]
                ),
                y_labeled,
            )
            eva = L[each_index][each_index] - \
                  det_Laa / L[each_index][each_index] + 2 * np.abs(tmp)

            if eva < min_eva:
                query_index = each_index
                min_eva = eva
        return [self._train_idx[query_index]]
def select ( self , label_index , unlabel_index , * * kwargs ) : assert ( isinstance ( unlabel_index , collections . Iterable ) ) assert ( isinstance ( label_index , collections . Iterable ) ) if len ( unlabel_index ) <= 1 : return list ( unlabel_index ) unlabel_index = np . asarray ( unlabel_index ) label_index = np . asarray ( label_index ) # build map from value to index label_index_in_train = [ np . where ( self . _train_idx == i ) [ 0 ] [ 0 ] for i in label_index ] unlabel_index_in_train = [ np . where ( self . _train_idx == i ) [ 0 ] [ 0 ] for i in unlabel_index ] # end L = self . L Lindex = list ( label_index_in_train ) Uindex = list ( unlabel_index_in_train ) query_index = - 1 min_eva = np . inf # y_labeled = np.array([label for label in self.y if label is not None]) y_labeled = self . y [ Lindex ] det_Laa = np . linalg . det ( L [ np . ix_ ( Uindex , Uindex ) ] ) # efficient computation of inv(Laa) M3 = np . dot ( self . K [ np . ix_ ( Uindex , Lindex ) ] , np . linalg . inv ( self . lmbda * np . eye ( len ( Lindex ) ) ) ) M2 = np . dot ( M3 , self . K [ np . ix_ ( Lindex , Uindex ) ] ) M1 = self . lmbda * np . eye ( len ( Uindex ) ) + self . K [ np . ix_ ( Uindex , Uindex ) ] inv_Laa = M1 - M2 iList = list ( range ( len ( Uindex ) ) ) if len ( iList ) == 1 : return Uindex [ 0 ] for i , each_index in enumerate ( Uindex ) : # go through all unlabeled instances and compute their evaluation # values one by one Uindex_r = Uindex [ : ] Uindex_r . remove ( each_index ) iList_r = iList [ : ] iList_r . remove ( i ) inv_Luu = inv_Laa [ np . ix_ ( iList_r , iList_r ) ] - 1 / inv_Laa [ i , i ] * np . dot ( inv_Laa [ iList_r , i ] , inv_Laa [ iList_r , i ] . T ) tmp = np . dot ( L [ each_index ] [ Lindex ] - np . dot ( np . dot ( L [ each_index ] [ Uindex_r ] , inv_Luu ) , L [ np . ix_ ( Uindex_r , Lindex ) ] ) , y_labeled , ) eva = L [ each_index ] [ each_index ] - det_Laa / L [ each_index ] [ each_index ] + 2 * np . abs ( tmp ) if eva < min_eva : query_index = each_index min_eva = eva return [ self . _train_idx [ query_index ] ]