How to get confidences of predictions in JAVA code

User: "radone"
New Altair Community Member
Updated by Jocelyn
Greetings,
I made my RM plugin which works with predictions. I read predicted and true values as:

ExampleSet exampleSet = getInput(ExampleSet.class);
Iterator<Example> reader = exampleSet.iterator();
while (reader.hasNext()) {
Example example = reader.next();
DataRow row = example.getDataRow();
boolean trueGain = !(row
.get(example.getAttributes().getLabel()) > 0.0);
boolean predictedGain = !(row.get(example.getAttributes()
.getPredictedLabel()) > 0.0);
....
double confidenceTrue = ????
double confidenceFalse = ????
}
How can I read confidences of predicted binominal values?

Thanks in advance.

Find more posts tagged with

Sort by:
1 - 2 of 21
    User: "steffen"
    New Altair Community Member
    Hello Radone

    check out this method:

    for( Example example : set ){
                example.getConfidence( classValue );
    }
    In general it is recommended to iterate over the examples instead over the DataRows. Since the ExampleSet stores (roughly said) transformations of attributes and filters, you really shouldnt iterate over the underlying datatable represented by DataRows.

    If you want to get the name of the confidence Attribute, use:

    String confName = AttributeOntology#getConfidenceRoleName(String targetValue)
    Now you can retrieve the Attribute (if available)...

    Attribute confAttr = exampleSet.getAttributes.get(confName);
    and retrieve the value of the current example

    example.getNumericalValue(confAttr );
    Very long explanation, hope it was helpful though ;)

    regards,

    Steffen

    PS: "classValue" and "targetValue" mean the same, a value of the set of possible values of your label attribute.
    User: "radone"
    New Altair Community Member
    OP
    very helpfull,

    Thank you very much Steffen.