@Test public void testAsDataStream() { VectorGeneratorsFamily family = new VectorGeneratorsFamily.Builder() .add(() -> VectorUtils.of(0.)) .add(() -> VectorUtils.of(1.)) .add(() -> VectorUtils.of(2.)) .build(0L); family.asDataStream().labeled().limit(100).forEach(v -> { assertEquals(v.features().get(0), v.label(), 1e-7); }); }
@Override public DataStreamGenerator asDataStream() { VectorGeneratorsFamily gen = this; return new DataStreamGenerator() { @Override public Stream<LabeledVector<Double>> labeled() { return Stream.generate(gen::getWithId) .map(v -> new LabeledVector<>(v.vector, (double)v.distributionId)); } }; }
VectorGeneratorsFamily implements VectorGenerator { @Override public DataStreamGenerator asDataStream() { VectorGeneratorsFamily gen = this; return new DataStreamGenerator() { @Override public Stream<LabeledVector<Double>> labeled() { return Stream.generate(gen::getWithId) .map(v -> new LabeledVector<>(v.vector, (double)v.distributionId)); } }; } }
VectorGeneratorsFamily implements VectorGenerator { @Override public DataStreamGenerator asDataStream() { VectorGeneratorsFamily gen = this; return new DataStreamGenerator() { @Override public Stream<LabeledVector<Double>> labeled() { return Stream.generate(gen::getWithId) .map(v -> new LabeledVector<>(v.vector, (double)v.distributionId)); } }; } private  VectorGeneratorsFamily(List<VectorGenerator> family, DiscreteRandomProducer selector); }
VectorGeneratorsFamily implements VectorGenerator { @Override public DataStreamGenerator asDataStream() { VectorGeneratorsFamily gen = this; return new DataStreamGenerator() { @Override public Stream<LabeledVector<Double>> labeled() { return Stream.generate(gen::getWithId) .map(v -> new LabeledVector<>(v.vector, (double)v.distributionId)); } }; } private  VectorGeneratorsFamily(List<VectorGenerator> family, DiscreteRandomProducer selector); @Override Vector get(); VectorWithDistributionId getWithId(); @Override DataStreamGenerator asDataStream(); }
VectorGeneratorsFamily implements VectorGenerator { @Override public DataStreamGenerator asDataStream() { VectorGeneratorsFamily gen = this; return new DataStreamGenerator() { @Override public Stream<LabeledVector<Double>> labeled() { return Stream.generate(gen::getWithId) .map(v -> new LabeledVector<>(v.vector, (double)v.distributionId)); } }; } private  VectorGeneratorsFamily(List<VectorGenerator> family, DiscreteRandomProducer selector); @Override Vector get(); VectorWithDistributionId getWithId(); @Override DataStreamGenerator asDataStream();  }