Get Model Results
September 24, 2015

Once you have retrieved the analyzed results from the SCiO cloud, you can get its value according to the attribute type. The value can be either an estimation (including the unit type). or a classification.

The following code demonstrates how to retrieve the attribute type and its value:

final ScioModel model = getItem(position);
final String value;
String unit = null;

switch (model.getAttributes().get(0).getAttributeType()) {
   case STRING:
       value = ((ScioStringAttribute) (model.getAttributes().get(0))).getValue();
       break;
   case NUMERIC:
       value = String.valueOf(((ScioNumericAttribute) (model.getAttributes().get(0))).getValue());
       unit = model.getAttributes().get(0).getUnits();
       break;
   case DATE_TIME:
       value = ((ScioDatetimeAttribute) (model.getAttributes().get(0))).getValue().toString();
       break;
   default:
       value = "Unknown";
}

attributeName.setText(model.getName());

if (model.getType().equals(ScioModel.Type.ESTIMATION)) {
   attributeValue.setText(value + unit);
}
else {
   attributeValue.setText(value + " (" + String.format("%.2f", model.getConfidence()) + ")");

Leave a Reply