How to show confidence attribute wit Naive Bayes operator

New Altair Community Member
Updated by Jocelyn
Hi to everyone,
I have a little problem, I'm trying to implement the learner operator Naive Bayes using the rapid miner API (in java using Net Beans). My code is:
MemoryExampleTable table = new MemoryExampleTable(attributes);
table.addDataRow(new DoubleArrayDataRow(context));
IOContainer container = new IOContainer(new IOObject[]{table.createExampleSet(label)});
container = container.append(model);
Operator applier = OperatorService.createOperator(ModelApplier.class);
container = applier.apply(container);
ExampleSet result = container.get(ExampleSet.class);
Attribute predictedLabel = result.getAttributes().getPredictedLabel();
double prediction = Double.parseDouble(result.iterator().next().getNominalValue(predictedLabel));
I'm trying to show the confidence attribute of the prediction but I don't know how to do it, I implemented this code:
double values[] = new double [100];
Iterator<Attribute> it = result.getAttributes().allAttributes();
int i = 0;
while(it.hasNext()) {
Example e = result.getExample(0);
values = e.getValue(it.next());
i++;
System.out.println(values);
}
but the output is all zeros;
Anyone know how can I take information about the confidence attribute? I tried also this method:
Attribute confidence = result.getAttributes().getSpecial("confidence(0)");
but the result is null.
Thank you for your help.
I have a little problem, I'm trying to implement the learner operator Naive Bayes using the rapid miner API (in java using Net Beans). My code is:
MemoryExampleTable table = new MemoryExampleTable(attributes);
table.addDataRow(new DoubleArrayDataRow(context));
IOContainer container = new IOContainer(new IOObject[]{table.createExampleSet(label)});
container = container.append(model);
Operator applier = OperatorService.createOperator(ModelApplier.class);
container = applier.apply(container);
ExampleSet result = container.get(ExampleSet.class);
Attribute predictedLabel = result.getAttributes().getPredictedLabel();
double prediction = Double.parseDouble(result.iterator().next().getNominalValue(predictedLabel));
I'm trying to show the confidence attribute of the prediction but I don't know how to do it, I implemented this code:
double values[] = new double [100];
Iterator<Attribute> it = result.getAttributes().allAttributes();
int i = 0;
while(it.hasNext()) {
Example e = result.getExample(0);
values = e.getValue(it.next());
i++;
System.out.println(values);
}
but the output is all zeros;
Anyone know how can I take information about the confidence attribute? I tried also this method:
Attribute confidence = result.getAttributes().getSpecial("confidence(0)");
but the result is null.
Thank you for your help.