@Test public void testConvergenceChecking() { data.put(666, VectorUtils.of(10, 11).labeled(100000.0)); LocalDatasetBuilder<Integer, LabeledVector<Double>> datasetBuilder = new LocalDatasetBuilder<>(data, 1); ConvergenceChecker<Integer, LabeledVector<Double>> checker = createChecker( new MedianOfMedianConvergenceCheckerFactory(0.1), datasetBuilder); double error = checker.computeError(VectorUtils.of(1, 2), 4.0, notConvergedMdl); Assert.assertEquals(1.9, error, 0.01); LearningEnvironmentBuilder envBuilder = TestUtils.testEnvBuilder(); Assert.assertFalse(checker.isConverged(envBuilder, datasetBuilder, notConvergedMdl)); Assert.assertTrue(checker.isConverged(envBuilder, datasetBuilder, convergedMdl)); try (LocalDataset<EmptyContext, FeatureMatrixWithLabelsOnHeapData> dataset = datasetBuilder.build( envBuilder, new EmptyContextBuilder<>(), new FeatureMatrixWithLabelsOnHeapDataBuilder<>(vectorizer), TestUtils.testEnvBuilder().buildForTrainer())) { double onDSError = checker.computeMeanErrorOnDataset(dataset, notConvergedMdl); Assert.assertEquals(1.6, onDSError, 0.01); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public Double computeMeanErrorOnDataset( Dataset<EmptyContext, ? extends FeatureMatrixWithLabelsOnHeapData> dataset, ModelsComposition mdl) { double[] medians = dataset.compute( data -> computeMedian(mdl, data), this::reduce ); if (medians == null) return Double.POSITIVE_INFINITY; return getMedian(medians); }
MedianOfMedianConvergenceChecker extends ConvergenceChecker<K, V> { @Override public Double computeMeanErrorOnDataset( Dataset<EmptyContext, ? extends FeatureMatrixWithLabelsOnHeapData> dataset, ModelsComposition mdl) { double[] medians = dataset.compute( data -> computeMedian(mdl, data), this::reduce ); if (medians == null) return Double.POSITIVE_INFINITY; return getMedian(medians); } }
MedianOfMedianConvergenceChecker extends ConvergenceChecker<K, V> { @Override public Double computeMeanErrorOnDataset( Dataset<EmptyContext, ? extends FeatureMatrixWithLabelsOnHeapData> dataset, ModelsComposition mdl) { double[] medians = dataset.compute( data -> computeMedian(mdl, data), this::reduce ); if (medians == null) return Double.POSITIVE_INFINITY; return getMedian(medians); } MedianOfMedianConvergenceChecker(long sampleSize, IgniteFunction<Double, Double> lblMapping, Loss loss,
        DatasetBuilder<K, V> datasetBuilder, Preprocessor<K, V> preprocessor, double precision); }
MedianOfMedianConvergenceChecker extends ConvergenceChecker<K, V> { @Override public Double computeMeanErrorOnDataset( Dataset<EmptyContext, ? extends FeatureMatrixWithLabelsOnHeapData> dataset, ModelsComposition mdl) { double[] medians = dataset.compute( data -> computeMedian(mdl, data), this::reduce ); if (medians == null) return Double.POSITIVE_INFINITY; return getMedian(medians); } MedianOfMedianConvergenceChecker(long sampleSize, IgniteFunction<Double, Double> lblMapping, Loss loss,
        DatasetBuilder<K, V> datasetBuilder, Preprocessor<K, V> preprocessor, double precision); @Override Double computeMeanErrorOnDataset(
        Dataset<EmptyContext, ? extends FeatureMatrixWithLabelsOnHeapData> dataset,
        ModelsComposition mdl); }
MedianOfMedianConvergenceChecker extends ConvergenceChecker<K, V> { @Override public Double computeMeanErrorOnDataset( Dataset<EmptyContext, ? extends FeatureMatrixWithLabelsOnHeapData> dataset, ModelsComposition mdl) { double[] medians = dataset.compute( data -> computeMedian(mdl, data), this::reduce ); if (medians == null) return Double.POSITIVE_INFINITY; return getMedian(medians); } MedianOfMedianConvergenceChecker(long sampleSize, IgniteFunction<Double, Double> lblMapping, Loss loss,
        DatasetBuilder<K, V> datasetBuilder, Preprocessor<K, V> preprocessor, double precision); @Override Double computeMeanErrorOnDataset(
        Dataset<EmptyContext, ? extends FeatureMatrixWithLabelsOnHeapData> dataset,
        ModelsComposition mdl);  }