You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You currently require the annotations to be Integer (0,1,2,3,...).
Is this an intrinsic limitation of Weka?
If not, I think it would be very good to also support String annotations and predictions.
The reason being that when we store the classifier file it would be great it that could contain and output String based class prediction (otherwise one would have to keep track of the mapping from Integer to String somewhere else, and I am in fact not sure where).
The text was updated successfully, but these errors were encountered:
I was looking a bit into this myself and here are code snippets that could be useful for you as well:
Converting String annotations to numbers:
final List< String > annotations = new ArrayList<>( new HashSet<>( tableModel.getColumn( annotationColumn ) ) );
annotations.remove( "None" );
attributes.add( new Attribute( "annotations", annotations ) );
final HashMap< String, Integer > annotationToIndex = new HashMap<>();
for ( int i = 0; i < annotations.size(); i++ )
{
annotationToIndex.put( annotations.get( i ), i );
}
Above code can be used during the creation of the Instances to populate the class column, e.g. like this:
// add class index as last "feature"
doubles[ doubles.length - 1 ] = annotationToIndex.get( tableRow.getCell( annotationColumn ) );
new DenseInstance( 1.0, doubles );
Converting a numeric prediction to a String:
randomForest.classifyInstance( predictionInstance );
final String predictedAnnotation = predictionInstance.classAttribute().value( predictionInstance.classIndex() );
@haesleinhuepf
You currently require the annotations to be Integer (0,1,2,3,...).
Is this an intrinsic limitation of Weka?
If not, I think it would be very good to also support
String
annotations and predictions.The reason being that when we store the classifier file it would be great it that could contain and output String based class prediction (otherwise one would have to keep track of the mapping from Integer to String somewhere else, and I am in fact not sure where).
The text was updated successfully, but these errors were encountered: