Search in sources :

Example 6 with GDBBinaryClassifierOnTreesTrainer

use of org.apache.ignite.ml.tree.boosting.GDBBinaryClassifierOnTreesTrainer in project ignite by apache.

the class GDBTrainerTest method testUpdate.

/**
 */
@Test
public void testUpdate() {
    int sampleSize = 100;
    double[] xs = new double[sampleSize];
    double[] ys = new double[sampleSize];
    for (int i = 0; i < sampleSize; i++) {
        xs[i] = i;
        ys[i] = ((int) (xs[i] / 10.0) % 2) == 0 ? -1.0 : 1.0;
    }
    Map<Integer, double[]> learningSample = new HashMap<>();
    for (int i = 0; i < sampleSize; i++) learningSample.put(i, new double[] { xs[i], ys[i] });
    IgniteBiFunction<Integer, double[], Vector> fExtr = (k, v) -> VectorUtils.of(v[0]);
    IgniteBiFunction<Integer, double[], Double> lExtr = (k, v) -> v[1];
    GDBTrainer classifTrainer = new GDBBinaryClassifierOnTreesTrainer(0.3, 500, 3, 0.0).withUsingIdx(true).withCheckConvergenceStgyFactory(new MeanAbsValueConvergenceCheckerFactory(0.3));
    GDBTrainer regressTrainer = new GDBRegressionOnTreesTrainer(0.3, 500, 3, 0.0).withUsingIdx(true).withCheckConvergenceStgyFactory(new MeanAbsValueConvergenceCheckerFactory(0.3));
// testUpdate(learningSample, fExtr, lExtr, classifTrainer);
// testUpdate(learningSample, fExtr, lExtr, regressTrainer);
}
Also used : TrainerTest(org.apache.ignite.ml.common.TrainerTest) WeightedPredictionsAggregator(org.apache.ignite.ml.composition.predictionsaggregator.WeightedPredictionsAggregator) BiFunction(java.util.function.BiFunction) Vector(org.apache.ignite.ml.math.primitives.vector.Vector) Assert.assertTrue(org.junit.Assert.assertTrue) HashMap(java.util.HashMap) Test(org.junit.Test) IgniteModel(org.apache.ignite.ml.IgniteModel) MeanAbsValueConvergenceCheckerFactory(org.apache.ignite.ml.composition.boosting.convergence.mean.MeanAbsValueConvergenceCheckerFactory) IgniteBiFunction(org.apache.ignite.ml.math.functions.IgniteBiFunction) ModelsComposition(org.apache.ignite.ml.composition.ModelsComposition) VectorUtils(org.apache.ignite.ml.math.primitives.vector.VectorUtils) GDBBinaryClassifierOnTreesTrainer(org.apache.ignite.ml.tree.boosting.GDBBinaryClassifierOnTreesTrainer) Map(java.util.Map) LocalDatasetBuilder(org.apache.ignite.ml.dataset.impl.local.LocalDatasetBuilder) DoubleArrayVectorizer(org.apache.ignite.ml.dataset.feature.extractor.impl.DoubleArrayVectorizer) GDBRegressionOnTreesTrainer(org.apache.ignite.ml.tree.boosting.GDBRegressionOnTreesTrainer) DecisionTreeModel(org.apache.ignite.ml.tree.DecisionTreeModel) ConvergenceCheckerStubFactory(org.apache.ignite.ml.composition.boosting.convergence.simple.ConvergenceCheckerStubFactory) Assert.assertEquals(org.junit.Assert.assertEquals) Vectorizer(org.apache.ignite.ml.dataset.feature.extractor.Vectorizer) GDBRegressionOnTreesTrainer(org.apache.ignite.ml.tree.boosting.GDBRegressionOnTreesTrainer) HashMap(java.util.HashMap) GDBBinaryClassifierOnTreesTrainer(org.apache.ignite.ml.tree.boosting.GDBBinaryClassifierOnTreesTrainer) MeanAbsValueConvergenceCheckerFactory(org.apache.ignite.ml.composition.boosting.convergence.mean.MeanAbsValueConvergenceCheckerFactory) Vector(org.apache.ignite.ml.math.primitives.vector.Vector) TrainerTest(org.apache.ignite.ml.common.TrainerTest) Test(org.junit.Test)

Aggregations

GDBBinaryClassifierOnTreesTrainer (org.apache.ignite.ml.tree.boosting.GDBBinaryClassifierOnTreesTrainer)6 Ignite (org.apache.ignite.Ignite)4 GDBTrainer (org.apache.ignite.ml.composition.boosting.GDBTrainer)4 MeanAbsValueConvergenceCheckerFactory (org.apache.ignite.ml.composition.boosting.convergence.mean.MeanAbsValueConvergenceCheckerFactory)4 ModelsComposition (org.apache.ignite.ml.composition.ModelsComposition)3 GDBModel (org.apache.ignite.ml.composition.boosting.GDBModel)3 DoubleArrayVectorizer (org.apache.ignite.ml.dataset.feature.extractor.impl.DoubleArrayVectorizer)3 Vector (org.apache.ignite.ml.math.primitives.vector.Vector)3 FileNotFoundException (java.io.FileNotFoundException)2 HashMap (java.util.HashMap)2 MedianOfMedianConvergenceCheckerFactory (org.apache.ignite.ml.composition.boosting.convergence.median.MedianOfMedianConvergenceCheckerFactory)2 ConvergenceCheckerStubFactory (org.apache.ignite.ml.composition.boosting.convergence.simple.ConvergenceCheckerStubFactory)2 WeightedPredictionsAggregator (org.apache.ignite.ml.composition.predictionsaggregator.WeightedPredictionsAggregator)2 Vectorizer (org.apache.ignite.ml.dataset.feature.extractor.Vectorizer)2 VectorUtils (org.apache.ignite.ml.math.primitives.vector.VectorUtils)2 EncoderTrainer (org.apache.ignite.ml.preprocessing.encoding.EncoderTrainer)2 DecisionTreeModel (org.apache.ignite.ml.tree.DecisionTreeModel)2 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1