New attribute created for PredictionModel subclass doesn't show up
Hi,
I am currently stuck with a quite simple problem. I have created a subclass of PredictionModel and modified the method createPredictionAttributes() as follows:
I would be glad about any help with this.
Best regards
Matthias
I am currently stuck with a quite simple problem. I have created a subclass of PredictionModel and modified the method createPredictionAttributes() as follows:
protected Attribute createPredictionAttributes(ExampleSet exampleSet, Attribute label) {Creating the "confidence(...)" attributes works fine. After this I want to have an additional attribute "confidence" that holds the confidence of the value that was actually predicted. When printing the attribute to console I get the index of the attribute, which is the number of the existing attributes + 1. But the additional attribute doesn't show up in my example set after "Apply Model". I tried using different names or adding it as regular attribute. No chance...
// create and add prediction attribute
/* make the label attribute independent from an existing label in the example set (since this had to be generated as dummy when classifying documents)
* original code:
* Attribute predictedLabel = AttributeFactory.createAttribute(label, Attributes.PREDICTION_NAME);
* predictedLabel.clearTransformations();
*/
Attribute predictedLabel = AttributeFactory.createAttribute(Attributes.PREDICTION_NAME, Ontology.NOMINAL);
ExampleTable table = exampleSet.getExampleTable();
Attributes attributes = exampleSet.getAttributes();
table.addAttribute(predictedLabel);
attributes.setPredictedLabel(predictedLabel);
// check whether confidence labels should be constructed
if (supportsConfidences(predictedLabel)) {
Iterator<String> labelIterator = model.classIndex.iterator();
while (labelIterator.hasNext()) {
String labelValue = labelIterator.next();
Attribute confidence = AttributeFactory.createAttribute(Attributes.CONFIDENCE_NAME + "(" + labelValue + ")", Ontology.REAL);
table.addAttribute(confidence);
attributes.setSpecialAttribute(confidence, Attributes.CONFIDENCE_NAME + "_" + labelValue);
}
// create an additional attribute for the confidence of the predicted value
Attribute predictionConfidence = AttributeFactory.createAttribute(Attributes.CONFIDENCE_NAME, Ontology.REAL);
table.addAttribute(predictionConfidence);
attributes.setSpecialAttribute(predictionConfidence, Attributes.CONFIDENCE_NAME);
}
return predictedLabel;
}
I would be glad about any help with this.
Best regards
Matthias