(self, label_index, unlabel_index, **kwargs)
return [(idx_ondim % self.X.shape[0], idx_ondim // self.X.shape[0])]
Select a subset from the unlabeled set, return the selected instance and label.

        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.

        Returns
        -------
        selected_ins_lab_pair: list
            A list of tuples that contains the indexes of selected instance-label pairs.
Select a subset from the unlabeled set, return the selected instance and label.
Select a subset from the unlabeled set return the selected instance and label .
def select(self, label_index, unlabel_index, **kwargs):
        """Select a subset from the unlabeled set, return the selected instance and label.

        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.

        Returns
        -------
        selected_ins_lab_pair: list
            A list of tuples that contains the indexes of selected instance-label pairs.
        """

        if len(unlabel_index) <= 1:
            return unlabel_index
        unlabel_index = self._check_multi_label_ind(unlabel_index)
        label_index = self._check_multi_label_ind(label_index)

        L_kr = np.kron(np.eye(self.y.shape[1]), self.L)
        nU = len(unlabel_index)
        # Only use the 2nd element
        # Uidx_col = []
        # Uidx_row = []
        # for uind in unlabel_index_li:
        #     Uidx_col.append(uind[1])
        #     Uidx_row.append((uind[0] + uind[1] * self.X.shape[0]) % self.L.shape[0])
        Uidx = unlabel_index.get_onedim_index(order='F', ins_num=self.X.shape[0])
        Sidx = label_index.get_onedim_index(order='F', ins_num=self.X.shape[0])
        Uidx = np.sort(Uidx)
        Sidx = np.sort(Sidx)
        Ys = [self.y[lind] for lind in label_index]
        # for lind in label_index:
        #     Sidx.append(lind[0])
        #     Ys.append(self.y[lind])
        Ys = np.asarray(Ys)
        Luu = L_kr[np.ix_(Uidx, Uidx)]
        Lsu = L_kr[np.ix_(Sidx, Uidx)]
        LL = np.linalg.pinv(Luu)
        # calculate the evaluation value for each pair in U
        vals = np.zeros(nU)
        YsLsu = Ys.dot(Lsu).T
        for i in range(nU):
            tmpidx = list(range(nU))
            tmpidx.remove(i)
            Lqq = Luu[i, i]
            Lqr = Luu[i, tmpidx]
            tmp0 = Lqq  # +Ys'*Lss*Ys;

            b = -(LL[i, tmpidx])
            invLrr = LL[np.ix_(tmpidx, tmpidx)] - b.T.dot(b) / LL[i, i]
            vt1 = YsLsu[tmpidx]
            vt2 = 2 * YsLsu[i]
            tmp1 = vt1 + Lqr
            tmp1 = vt2 - tmp1.dot(invLrr).dot(tmp1.T)
            tmp2 = vt1 - Lqr
            tmp2 = -vt2 - tmp2.dot(invLrr).dot(tmp2.T)
            vals[i] = np.fmax((tmp0 + tmp1), (tmp0 + tmp2))

        idx_selected = np.argmin(vals)
        idx_ondim = Uidx[idx_selected]
        return [(idx_ondim % self.X.shape[0], idx_ondim // self.X.shape[0])]
def select ( self , label_index , unlabel_index , * * kwargs ) : if len ( unlabel_index ) <= 1 : return unlabel_index unlabel_index = self . _check_multi_label_ind ( unlabel_index ) label_index = self . _check_multi_label_ind ( label_index ) L_kr = np . kron ( np . eye ( self . y . shape [ 1 ] ) , self . L ) nU = len ( unlabel_index ) # Only use the 2nd element # Uidx_col = [] # Uidx_row = [] # for uind in unlabel_index_li: #     Uidx_col.append(uind[1]) #     Uidx_row.append((uind[0] + uind[1] * self.X.shape[0]) % self.L.shape[0]) Uidx = unlabel_index . get_onedim_index ( order = 'F' , ins_num = self . X . shape [ 0 ] ) Sidx = label_index . get_onedim_index ( order = 'F' , ins_num = self . X . shape [ 0 ] ) Uidx = np . sort ( Uidx ) Sidx = np . sort ( Sidx ) Ys = [ self . y [ lind ] for lind in label_index ] # for lind in label_index: #     Sidx.append(lind[0]) #     Ys.append(self.y[lind]) Ys = np . asarray ( Ys ) Luu = L_kr [ np . ix_ ( Uidx , Uidx ) ] Lsu = L_kr [ np . ix_ ( Sidx , Uidx ) ] LL = np . linalg . pinv ( Luu ) # calculate the evaluation value for each pair in U vals = np . zeros ( nU ) YsLsu = Ys . dot ( Lsu ) . T for i in range ( nU ) : tmpidx = list ( range ( nU ) ) tmpidx . remove ( i ) Lqq = Luu [ i , i ] Lqr = Luu [ i , tmpidx ] tmp0 = Lqq # +Ys'*Lss*Ys; b = - ( LL [ i , tmpidx ] ) invLrr = LL [ np . ix_ ( tmpidx , tmpidx ) ] - b . T . dot ( b ) / LL [ i , i ] vt1 = YsLsu [ tmpidx ] vt2 = 2 * YsLsu [ i ] tmp1 = vt1 + Lqr tmp1 = vt2 - tmp1 . dot ( invLrr ) . dot ( tmp1 . T ) tmp2 = vt1 - Lqr tmp2 = - vt2 - tmp2 . dot ( invLrr ) . dot ( tmp2 . T ) vals [ i ] = np . fmax ( ( tmp0 + tmp1 ) , ( tmp0 + tmp2 ) ) idx_selected = np . argmin ( vals ) idx_ondim = Uidx [ idx_selected ] return [ ( idx_ondim % self . X . shape [ 0 ] , idx_ondim // self . X . shape [ 0 ] ) ]