@Test public void testFilter() { double[][] features = new double[][]{{0}, {1}, {2}, {3}, {4}, {5}}; double[] labels = new double[]{0, 1, 2, 3, 4, 5}; DecisionTreeData data = new DecisionTreeData(features, labels, useIdx); DecisionTreeData filteredData = data.filter(obj -> obj[0] > 2); assertArrayEquals(new double[][]{{3}, {4}, {5}}, filteredData.getFeatures()); assertArrayEquals(new double[]{3, 4, 5}, filteredData.getLabels(), 1e-10); }
public DecisionTreeData filter(TreeFilter filter) { int size = 0; double[][] features = getFeatures(); double[] labels = getLabels(); for (int i = 0; i < features.length; i++) if (filter.test(features[i])) size++; double[][] newFeatures = new double[size][]; double[] newLabels = new double[size]; int ptr = 0; for (int i = 0; i < features.length; i++) { if (filter.test(features[i])) { newFeatures[ptr] = features[i]; newLabels[ptr] = labels[i]; ptr++; } } return new DecisionTreeData(newFeatures, newLabels, buildIdx); }
DecisionTreeData extends FeatureMatrixWithLabelsOnHeapData implements AutoCloseable { public DecisionTreeData filter(TreeFilter filter) { int size = 0; double[][] features = getFeatures(); double[] labels = getLabels(); for (int i = 0; i < features.length; i++) if (filter.test(features[i])) size++; double[][] newFeatures = new double[size][]; double[] newLabels = new double[size]; int ptr = 0; for (int i = 0; i < features.length; i++) { if (filter.test(features[i])) { newFeatures[ptr] = features[i]; newLabels[ptr] = labels[i]; ptr++; } } return new DecisionTreeData(newFeatures, newLabels, buildIdx); } }
DecisionTreeData extends FeatureMatrixWithLabelsOnHeapData implements AutoCloseable { public DecisionTreeData filter(TreeFilter filter) { int size = 0; double[][] features = getFeatures(); double[] labels = getLabels(); for (int i = 0; i < features.length; i++) if (filter.test(features[i])) size++; double[][] newFeatures = new double[size][]; double[] newLabels = new double[size]; int ptr = 0; for (int i = 0; i < features.length; i++) { if (filter.test(features[i])) { newFeatures[ptr] = features[i]; newLabels[ptr] = labels[i]; ptr++; } } return new DecisionTreeData(newFeatures, newLabels, buildIdx); } DecisionTreeData(double[][] features, double[] labels, boolean buildIdx); }
DecisionTreeData extends FeatureMatrixWithLabelsOnHeapData implements AutoCloseable { public DecisionTreeData filter(TreeFilter filter) { int size = 0; double[][] features = getFeatures(); double[] labels = getLabels(); for (int i = 0; i < features.length; i++) if (filter.test(features[i])) size++; double[][] newFeatures = new double[size][]; double[] newLabels = new double[size]; int ptr = 0; for (int i = 0; i < features.length; i++) { if (filter.test(features[i])) { newFeatures[ptr] = features[i]; newLabels[ptr] = labels[i]; ptr++; } } return new DecisionTreeData(newFeatures, newLabels, buildIdx); } DecisionTreeData(double[][] features, double[] labels, boolean buildIdx); DecisionTreeData filter(TreeFilter filter); void sort(int col); double[] getCopiedOriginalLabels(); void setCopiedOriginalLabels(double[] copiedOriginalLabels); @Override void close(); TreeDataIndex createIndexByFilter(int depth, TreeFilter filter); }
DecisionTreeData extends FeatureMatrixWithLabelsOnHeapData implements AutoCloseable { public DecisionTreeData filter(TreeFilter filter) { int size = 0; double[][] features = getFeatures(); double[] labels = getLabels(); for (int i = 0; i < features.length; i++) if (filter.test(features[i])) size++; double[][] newFeatures = new double[size][]; double[] newLabels = new double[size]; int ptr = 0; for (int i = 0; i < features.length; i++) { if (filter.test(features[i])) { newFeatures[ptr] = features[i]; newLabels[ptr] = labels[i]; ptr++; } } return new DecisionTreeData(newFeatures, newLabels, buildIdx); } DecisionTreeData(double[][] features, double[] labels, boolean buildIdx); DecisionTreeData filter(TreeFilter filter); void sort(int col); double[] getCopiedOriginalLabels(); void setCopiedOriginalLabels(double[] copiedOriginalLabels); @Override void close(); TreeDataIndex createIndexByFilter(int depth, TreeFilter filter);  }