<commit_before>package univ.ml;

import com.clearspring.analytics.util.Lists;
import org.apache.commons.math.linear.BlockRealMatrix;
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.linear.SingularValueDecomposition;
import org.apache.commons.math.linear.SingularValueDecompositionImpl;

import java.util.List;
import java.util.stream.Collectors;

public class SVDCoreset extends BaseCoreset<WeightedDoublePoint> {

    private final int j;

    private final double epsilon;

    public SVDCoreset(final int d, final int j, final double epsilon) {
        this.j = j;
        this.epsilon = epsilon;



    }

    @Override
    public List<WeightedDoublePoint> takeSample(List<WeightedDoublePoint> pointset) {
        int d = pointset.size();
        int m = Math.min(j + (int)Math.ceil(j/epsilon) - 1, d - 1);

        final BlockRealMatrix A = new BlockRealMatrix(pointset.size(), d);
        int idx = 0;

        // Create block matrix so SVD algorithm will be able to work with it.
        for (WeightedDoublePoint each : pointset) {<commit_msg>Remove d from c'tor<commit_after>package univ.ml;

import com.clearspring.analytics.util.Lists;
import org.apache.commons.math.linear.BlockRealMatrix;
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.linear.SingularValueDecomposition;
import org.apache.commons.math.linear.SingularValueDecompositionImpl;

import java.util.List;
import java.util.stream.Collectors;

public class SVDCoreset extends BaseCoreset<WeightedDoublePoint> {

    private final int j;

    private final double epsilon;

    public SVDCoreset(final int j, final double epsilon) {
        this.j = j;
        this.epsilon = epsilon;
    }

    @Override
    public List<WeightedDoublePoint> takeSample(List<WeightedDoublePoint> pointset) {
        int d = pointset.size();
        int m = Math.min(j + (int)Math.ceil(j/epsilon) - 1, d - 1);

        final BlockRealMatrix A = new BlockRealMatrix(pointset.size(), d);
        int idx = 0;

        // Create block matrix so SVD algorithm will be able to work with it.
        for (WeightedDoublePoint each : pointset) {
{'fraction_non_alphanumeric': 0.09554730983302412, 'fraction_numerical': 0.0027829313543599257, 'mean_word_length': 3.49375, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1543364', 'n_tokens_mistral': 669, 'n_tokens_neox': 649, 'n_words': 168}