(self, observed_entries, unkonwn_entries, **kwargs)
return [(self._train_idx[selected_feature // mc_sh[1]], selected_feature % mc_sh[1])]
Select a subset from the unlabeled set, return the selected instance and feature.

        Parameters
        ----------
        observed_entries: {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 features.

        unkonwn_entries: {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 features.

        Returns
        -------
        selected_feature: list
            The selected features, it is a list of tuples.
            Note that, the index is for the the WHOLE dataset, NOT THE TRAINING SET.
Select a subset from the unlabeled set, return the selected instance and feature.
Select a subset from the unlabeled set return the selected instance and feature .
def select(self, observed_entries, unkonwn_entries, **kwargs):
        """Select a subset from the unlabeled set, return the selected instance and feature.

        Parameters
        ----------
        observed_entries: {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 features.

        unkonwn_entries: {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 features.

        Returns
        -------
        selected_feature: list
            The selected features, it is a list of tuples.
            Note that, the index is for the the WHOLE dataset, NOT THE TRAINING SET.
        """
        # build map from value to index
        if len(unkonwn_entries) <= 1:
            return unkonwn_entries
        unkonwn_entries = self._check_feature_ind(unkonwn_entries)
        observed_entries = self._check_feature_ind(observed_entries)

        if self._train_idx is None:
            obi = observed_entries.get_instance_index()
            uni = unkonwn_entries.get_instance_index()
            self._train_idx = np.union1d(obi, uni)

        # map entries of the whole data to the training data
        tr_ob = []
        for entry in observed_entries:
            # if entry[0] in self._train_idx:
            ind_in_train = np.argwhere(self._train_idx == entry[0])[0][0]
            tr_ob.append((ind_in_train, entry[1]))
            # else:
            #     tr_ob.append(entry)
        tr_ob = MultiLabelIndexCollection(tr_ob)

        # matrix completion
        X_mc = AFASMC_mc(X=self.X[self._train_idx], y=self.y[self._train_idx], omega=tr_ob, **kwargs)
        self._feature_variance.append(X_mc)
        mc_sh = np.shape(X_mc)
        if len(self._feature_variance) >= 2:
            var_mat = np.zeros(mc_sh)
            for i in range(mc_sh[0]):
                for j in range(mc_sh[1]):
                    var_mat[i, j] = np.var([mat[i][j] for mat in self._feature_variance])
            var_mat *= 1 - tr_ob.get_matrix_mask(mat_shape=mc_sh, sparse=False)
            # in the first 2 rounds, all entries are 0, you will select the known elements.
            selected_feature = np.argmax(var_mat)  # a 1d index in training set
        else:
            selected_feature = np.argmax(1 - tr_ob.get_matrix_mask(mat_shape=mc_sh, sparse=False))

        return [(self._train_idx[selected_feature // mc_sh[1]], selected_feature % mc_sh[1])]
def select ( self , observed_entries , unkonwn_entries , * * kwargs ) : # build map from value to index if len ( unkonwn_entries ) <= 1 : return unkonwn_entries unkonwn_entries = self . _check_feature_ind ( unkonwn_entries ) observed_entries = self . _check_feature_ind ( observed_entries ) if self . _train_idx is None : obi = observed_entries . get_instance_index ( ) uni = unkonwn_entries . get_instance_index ( ) self . _train_idx = np . union1d ( obi , uni ) # map entries of the whole data to the training data tr_ob = [ ] for entry in observed_entries : # if entry[0] in self._train_idx: ind_in_train = np . argwhere ( self . _train_idx == entry [ 0 ] ) [ 0 ] [ 0 ] tr_ob . append ( ( ind_in_train , entry [ 1 ] ) ) # else: #     tr_ob.append(entry) tr_ob = MultiLabelIndexCollection ( tr_ob ) # matrix completion X_mc = AFASMC_mc ( X = self . X [ self . _train_idx ] , y = self . y [ self . _train_idx ] , omega = tr_ob , * * kwargs ) self . _feature_variance . append ( X_mc ) mc_sh = np . shape ( X_mc ) if len ( self . _feature_variance ) >= 2 : var_mat = np . zeros ( mc_sh ) for i in range ( mc_sh [ 0 ] ) : for j in range ( mc_sh [ 1 ] ) : var_mat [ i , j ] = np . var ( [ mat [ i ] [ j ] for mat in self . _feature_variance ] ) var_mat *= 1 - tr_ob . get_matrix_mask ( mat_shape = mc_sh , sparse = False ) # in the first 2 rounds, all entries are 0, you will select the known elements. selected_feature = np . argmax ( var_mat ) # a 1d index in training set else : selected_feature = np . argmax ( 1 - tr_ob . get_matrix_mask ( mat_shape = mc_sh , sparse = False ) ) return [ ( self . _train_idx [ selected_feature // mc_sh [ 1 ] ] , selected_feature % mc_sh [ 1 ] ) ]