Making a copy of WEKA Instances

imageThis ‘thing’ took about 30 minutes to figure out. According to the WEKA documentation, if  you add a new Instance to an existing Instances object, String values are not transferred ! In case you are working on copying a dataset with a string attribute, you need to transfer the string manually. The code segment below copies the i^th instance from source to dest where the first attribute (at index 0) is a string attribute.


This should come in handy for text classification using WEKA (and hopefully save your time).

3 thoughts on “Making a copy of WEKA Instances

  1. Hi awais thank you very much for this. I don’t understand why there is no deep copy for instances, it would have been very useful I think.

    thanks for the help!

Leave a Reply

Your email address will not be published. Required fields are marked *