Search in sources :

Example 1 with BinarizationTrainer

use of org.apache.ignite.ml.preprocessing.binarization.BinarizationTrainer in project ignite by apache.

the class BinarizationExample method main.

/**
 * Run example.
 */
public static void main(String[] args) throws Exception {
    try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
        System.out.println(">>> Binarization example started.");
        IgniteCache<Integer, Vector> data = null;
        try {
            data = createCache(ignite);
            Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<>(1);
            // Defines second preprocessor that binarizes features.
            Preprocessor<Integer, Vector> preprocessor = new BinarizationTrainer<Integer, Vector>().withThreshold(40).fit(ignite, data, vectorizer);
            // Creates a cache based simple dataset containing features and providing standard dataset API.
            try (SimpleDataset<?> dataset = DatasetFactory.createSimpleDataset(ignite, data, preprocessor)) {
                new DatasetHelper(dataset).describe();
            }
            System.out.println(">>> Binarization example completed.");
        } finally {
            data.destroy();
        }
    } finally {
        System.out.flush();
    }
}
Also used : BinarizationTrainer(org.apache.ignite.ml.preprocessing.binarization.BinarizationTrainer) DummyVectorizer(org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer) Ignite(org.apache.ignite.Ignite) Vector(org.apache.ignite.ml.math.primitives.vector.Vector) DenseVector(org.apache.ignite.ml.math.primitives.vector.impl.DenseVector) DatasetHelper(org.apache.ignite.examples.ml.util.DatasetHelper)

Aggregations

Ignite (org.apache.ignite.Ignite)1 DatasetHelper (org.apache.ignite.examples.ml.util.DatasetHelper)1 DummyVectorizer (org.apache.ignite.ml.dataset.feature.extractor.impl.DummyVectorizer)1 Vector (org.apache.ignite.ml.math.primitives.vector.Vector)1 DenseVector (org.apache.ignite.ml.math.primitives.vector.impl.DenseVector)1 BinarizationTrainer (org.apache.ignite.ml.preprocessing.binarization.BinarizationTrainer)1