Search in sources :

Example 1 with ParametricVectorGenerator

use of org.apache.ignite.ml.util.generators.primitives.vector.ParametricVectorGenerator 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();
}
Also used : DataStreamGenerator(org.apache.ignite.ml.util.generators.DataStreamGenerator) ParametricVectorGenerator(org.apache.ignite.ml.util.generators.primitives.vector.ParametricVectorGenerator) IOException(java.io.IOException) Tracer(org.apache.ignite.ml.math.Tracer) UniformRandomProducer(org.apache.ignite.ml.util.generators.primitives.scalar.UniformRandomProducer) UniformRandomProducer(org.apache.ignite.ml.util.generators.primitives.scalar.UniformRandomProducer) ParametricVectorGenerator(org.apache.ignite.ml.util.generators.primitives.vector.ParametricVectorGenerator) DataStreamGenerator(org.apache.ignite.ml.util.generators.DataStreamGenerator)

Aggregations

IOException (java.io.IOException)1 Tracer (org.apache.ignite.ml.math.Tracer)1 DataStreamGenerator (org.apache.ignite.ml.util.generators.DataStreamGenerator)1 UniformRandomProducer (org.apache.ignite.ml.util.generators.primitives.scalar.UniformRandomProducer)1 ParametricVectorGenerator (org.apache.ignite.ml.util.generators.primitives.vector.ParametricVectorGenerator)1