use of org.apache.ignite.ml.util.generators.primitives.scalar.UniformRandomProducer in project ignite by apache.
the class ParametricVectorGeneratorExample method main.
/**
* Run example.
*
* @param args Args.
*/
public static void main(String... args) throws IOException {
// Example of Archimedean spiral.
DataStreamGenerator spiral = new ParametricVectorGenerator(// 't' will be in [-50, 50] range
new UniformRandomProducer(-50, 50), t -> Math.cos(Math.abs(t)) * Math.abs(t), t -> Math.sin(Math.abs(t)) * Math.abs(t)).asDataStream();
Tracer.showClassificationDatasetHtml("Spiral", spiral, 20000, 0, 1, false);
// Example of heart shape.
DataStreamGenerator heart = new ParametricVectorGenerator(new UniformRandomProducer(-50, 50), t -> 16 * Math.pow(Math.sin(t), 3), t -> 13 * Math.cos(t) - 5 * Math.cos(2 * t) - 2 * Math.cos(3 * t) - Math.cos(4 * t)).asDataStream();
Tracer.showClassificationDatasetHtml("Heart", heart, 2000, 0, 1, false);
// Example of butterfly-like shape.
DataStreamGenerator butterfly = new ParametricVectorGenerator(// 't' will be in [-100, 100] range
new UniformRandomProducer(-100, 100), t -> 10 * Math.sin(t) * (Math.exp(Math.cos(t)) - 2 * Math.cos(4 * t) - Math.pow(Math.sin(t / 12), 5)), t -> 10 * Math.cos(t) * (Math.exp(Math.cos(t)) - 2 * Math.cos(4 * t) - Math.pow(Math.sin(t / 12), 5))).asDataStream();
Tracer.showClassificationDatasetHtml("Butterfly", butterfly, 2000, 0, 1, false);
System.out.flush();
}
use of org.apache.ignite.ml.util.generators.primitives.scalar.UniformRandomProducer in project ignite by apache.
the class VectorGeneratorTest method testMap.
/**
*/
@Test
public void testMap() {
Vector originalVec = new UniformRandomProducer(-1, 1).vectorize(2).get();
Vector doubledVec = VectorGeneratorPrimitives.constant(originalVec).map(v -> v.times(2.)).get();
assertArrayEquals(originalVec.times(2.).asArray(), doubledVec.asArray(), 1e-7);
}
Aggregations