GitHub user mgrzenda opened a pull request:
https://github.com/apache/incubator-samoa/pull/73
SAMOA-73: fixes NullPointerException in VerticalHoeffdingTree
java.lang.NullPointerException is in some cases thrown in
org.apache.samoa.learners.classifiers.trees.ModelAggregatorProcessor.process(ModelAggregatorProcessor.java:142)
The problem occurs because FoundNode objects in some cases contain null
node property. Such FoundNode objects can be created and are considered valid,
which directly follows from filterInstanceToLeaf(Instance inst, SplitNode
parent, int parentBranch) method of SplitNode class.
However, once a categorical feature is selected for the splits, the
following situation can happen:
1) first FoundNode object with null node object inside is created
2) Next, the tree structure is grown by establishing new LearningNode,
which is done in ModelAggregatorProcessor.java/trainOnInstanceImpl(FoundNode
foundNode, Instance inst)
3) The problem is the LearningNode is not added to FoundNode helper object
already existing at this stage, which causes NullPointerException exception
when trying to use it.
Solution: In such cases, the FoundNode object should reflect the newly
created tree extension. This can be done by injecting into the FoundNode the
newly created Node object. This is to keep FoundNode in sync with the most
recent tree structure. This is what this fix makes: it replaces null node
object with the newly created one.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/mgrzenda/incubator-samoa SAMOA-73
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-samoa/pull/73.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #73
----
commit 5d6733dda3f572fc0f14c15f2dbd306300a9a274
Author: Maciej Grzenda <[email protected]>
Date: 2017-11-20T14:56:24Z
SAMOA-73: fixes NullPointerException in VerticalHoeffdingTree
----
---