Yes, the known issue in the Random Forest, it throws the strange math
exception in the case, when the preprocessed vector has the
different length with the vector which could be handled by the model.
I didn't see your another code, but I could suppose, that you have another
preprocessing stages like one-hot-encoding that adds new columns and you
missed the link here

double accuracy = Evaluator.evaluate(
                    dataCache,
                    randomForestMdl,
                    vectorizer, <---------------------- should be correct
(the last in the chain and the same like in the fit() call ) preprocesser
                    new Accuracy<>()
                );

I'll add the ticket to throw another exception with the correct message to
explain this situation for the user.

чт, 6 февр. 2020 г. в 00:29, kencottrell <ken.cottr...@gridgain.com>:

> I have attempted to add this call to a RandomForestModel in order to obtain
> accuracy:
>
>           *double accuracy = Evaluator.evaluate(
>                     dataCache,
>                     randomForestMdl,
>                     vectorizer,
>                     new Accuracy<>()
>                 );
>
>                 System.out.println("\n>>> Accuracy " + accuracy);
>                 System.out.println("\n>>> Test Error " + (1 - accuracy));*
>
>
> But I get this exception (editted to remove extra detail). Am I using the
> wrong parameters?
>
> Exception in thread "main" java.lang.RuntimeException: class
> /org.apache.ignite.ml.math.exceptions.IndexException: Invalid (out of
> bound)
> index: 16
>         at
> org.apache.ignite.ml
> .selection.scoring.evaluator.Evaluator.calculateMetric(Evaluator.java:330)
>         at
> org.apache.ignite.ml
> .selection.scoring.evaluator.Evaluator.evaluate(Evaluator.java:57)
>         at com.gg.TrainRandomForest2.main(TrainRandomForest2.java:111)
> Caused by: class org.apache.ignite.ml.math.exceptions.IndexException:
> Invalid (out of bound) index: 16
>         at
>
> org.apache.ignite.ml.math.primitives.vector.AbstractVector.checkIndex(AbstractVector.java:174)
>         at
>
> org.apache.ignite.ml.math.primitives.vector.AbstractVector.get(AbstractVector.java:179)
>         at
>
> org.apache.ignite.ml.tree.randomforest.data.TreeNode.predict(TreeNode.java:91)
>         at
>
> org.apache.ignite.ml.tree.randomforest.data.TreeNode.predict(TreeNode.java:92)
>         at
>
> org.apache.ignite.ml.tree.randomforest.data.TreeRoot.predict(TreeRoot.java:52)
>         at
>
> org.apache.ignite.ml.tree.randomforest.data.TreeRoot.predict(TreeRoot.java:29)
>         at
> org.apache.ignite.ml
> .composition.ModelsComposition.predict(ModelsComposition.java:64)
>         at
> org.apache.ignite.ml
> .composition.ModelsComposition.predict(ModelsComposition.java:32)
>         at
> org.apache.ignite.ml
> .selection.scoring.cursor.CacheBasedLabelPairCursor$TruthWithPredictionIterator.next(CacheBasedLabelPairCursor.java:145)
>         at
> org.apache.ignite.ml
> .selection.scoring.cursor.CacheBasedLabelPairCursor$TruthWithPredictionIterator.next(CacheBasedLabelPairCursor.java:121)
>         at
> org.apache.ignite.ml
> .selection.scoring.metric.classification.Accuracy.score(Accuracy.java:36)
>         at
> org.apache.ignite.ml
> .selection.scoring.evaluator.Evaluator.calculateMetric(Evaluator.java:328)
>         ... 2 more
>
> /
>
>
>
> --
> Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/
>

Reply via email to