def subset_reencode_features(x_unvec, feat_encoding_dict):
    """Filter then re-encode features after feature selection.

    Arguments:
        x_unvec: [[int]]
            feature indices that have not been vectorized; each inner list
            collects the indices of features that are present (binary on)
            for a sample
        feat_encoding_dict: {int: int}
            dictionary mapping old feature indices to new feature indices

    Returns:
        x_unvec_new: [[int]]
            modified feature indices that have not been vectorized; each inner
            list collects the indices of features that are present (binary on)
            for a sample
    """
    return [[feat_encoding_dict[feat_idx] for feat_idx in x if
             feat_idx in feat_encoding_dict] for x in x_unvec]