Search in sources :

Example 1 with BinaryObjectVectorizer

use of org.apache.ignite.ml.dataset.feature.extractor.impl.BinaryObjectVectorizer in project ignite by apache.

the class KeepBinaryTest method test.

/**
 * Startup Ignite, populate cache and train some model.
 */
@Test
public void test() {
    IgniteCache<Integer, BinaryObject> dataCache = populateCache(ignite);
    KMeansTrainer trainer = new KMeansTrainer();
    CacheBasedDatasetBuilder<Integer, BinaryObject> datasetBuilder = new CacheBasedDatasetBuilder<>(ignite, dataCache).withKeepBinary(true);
    KMeansModel mdl = trainer.fit(datasetBuilder, new BinaryObjectVectorizer<Integer>("feature1").labeled("label"));
    Integer zeroCentre = mdl.predict(VectorUtils.num2Vec(0.0));
    assertTrue(mdl.centers()[zeroCentre].get(0) == 0);
}
Also used : KMeansModel(org.apache.ignite.ml.clustering.kmeans.KMeansModel) BinaryObjectVectorizer(org.apache.ignite.ml.dataset.feature.extractor.impl.BinaryObjectVectorizer) BinaryObject(org.apache.ignite.binary.BinaryObject) KMeansTrainer(org.apache.ignite.ml.clustering.kmeans.KMeansTrainer) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

BinaryObject (org.apache.ignite.binary.BinaryObject)1 KMeansModel (org.apache.ignite.ml.clustering.kmeans.KMeansModel)1 KMeansTrainer (org.apache.ignite.ml.clustering.kmeans.KMeansTrainer)1 BinaryObjectVectorizer (org.apache.ignite.ml.dataset.feature.extractor.impl.BinaryObjectVectorizer)1 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)1 Test (org.junit.Test)1