function [Xr] = compress_seq (X, y, dim)
    Xr = zeros(size(X, 1), dim);
    [idx_chisq, ~] = fscchi2(X, y);
    % Preserve the order in sequence
    retain = sort(idx_chisq (1:dim));
    for i = 1:dim
          Xr(:, i) = X(:, retain(i));
    end
end