Hello!
Currently, I am trying to generate rule-based models using the AQ15 algorithm. For some datasets, I encounter a NullPointerException
. After some debugging, I have identified the issue.
I am using the rseslib library by importing the Java package. I create my model using the following function:
DoubleDataTable trainTable = new ArrayListDoubleDataTable(new File(trainPath), new EmptyProgress());
...
AQ15Classifier aq15 = new AQ15Classifier((Properties) null, trainTable, prog);
When running AQ15Classifier()
I got the error. This creator runs generate(DoubleDataTable tab, Progress prog)
from class CoveringRuleGenerator
. In this generate
function, the generate
function from AQ15OneRuleGenerator
is started.
In the function generate
from AQ15OneRuleGenerator
there is a code:
Rule rule = null;
if (candidates.size() > 0) {
rule = new BooleanFunctionRule((BooleanFunction)candidates.get(0), e_pos.getDecision(), examples.attributes().nominalDecisionAttribute());
}
return rule;
For some dataset the candidates.size()
is equal 0
and this function returns null
. This value goes back to generate
function from CoveringRuleGenerator
, where there is a code:
for(int prooningObjts = uncovered.size(); (double)uncovered.size() > this.m_prooning * (double)prooningObjts; uncovered = this.removeCovered(uncovered, rules)) {
rules.add(this.m_oneRuleGenerator.generate(tab, uncovered, this.m_k, dec));
}
For example, after some iterations I got rules
object that looks like this:
We can see that the last added rule is null
. Then, the function uncovered = this.removeCovered(uncovered, rules)
is started (this execution is inside the above for
loop). The removeCovered
function is called with the rules object, which has a null value, resulting in a NullPointerException
.
Can I do something that will eliminate the NullPointerException
error?
I add simple code and dataset for which the problem occurs.
AQ15ErrorExample.zip