Re: How to classify unseen multi instance data?
Peter Reutemann <[email protected]> Fri, 26 Jan 2024 09:44:53 +1300
| Newsgroups | gmane.comp.ai.weka |
|---|---|
| Message-ID | <CAHoQ12LyEwiJz-YHbpXNUJZgnbC516-SSVfyhr=Hnc6fTgk54A@mail.gmail.com> |
> > Even for multi-instance data you only use a single Instance object, > > representing a single bag, for making predictions. > > My confusion stemmed from the somewhat unfortunate terminology, whereby > I thought an Instance object is single-instance and Instances is > multi-instance - which I now believe to be wrong. An Instance can either > be single- or multi-instance and if it is multi-instance we also call it > a bag. Instances is then either: > > - a bunch of bags or > - a bunch of single-instance Instance objects Instances = dataset, a collection of examples Instance = single example > The next point to note is that training a model is done off an Instances > object, whereas classification of unseen data is using an Instance. > Therefore the answer to my original question appears to be thus: > > When training a model, first get the data from somewhere (ARFF file, > database, ...) and then convert it to an Instances object. When > classifying unseen data, use the exact same code to create an Instances > object (optionally skipping the class values, which are not needed > here). Then it's just a matter of passing Instances.firstInstance() to > the classifier. Hopefully I explained it correctly now :) At prediction time you re-use (rather than re-create) the header from the training data to create new Instance objects. These Instance objects you then present to the classifier to obtain predictions. > FWIW, from a software engineering standpoint single- and multi-instance > data should be distinguishable by their type (Java class). > Multi-instance data should probably implement an additional interface. Yes and no. Whilst it would be nice to determine this via the Java type, the general RELATIONAL attribute is column-based and not row-based (and we already have DenseInstance and SparseInstance row types). The idea behind the attribute is to represent data from a relational database. But, this attribute can also be used to represent the simpler multi-instance data, by encapsulating the bag in such an attribute. Originally, multi-instance learning was available through a separate framework called MILK. Eibe then added the RELATIONAL attribute type to Weka, to make it possible having multi-instance learning as part of Weka via optional Weka packages. The RELAGGS filter is specifically designed for processing data from a relational database (the original code worked straight off JDBC databases): https://weka.sourceforge.io/doc.stable/weka/filters/unsupervised/attribute/RELAGGS.html So, using the attribute-based approach rather than the Java-type-row approach is more flexible. :-) Cheers, Peter -- Peter Reutemann Dept. of Computer Science University of Waikato, Hamilton, NZ Mobile +64 22 190 2375 https://www.cs.waikato.ac.nz/~fracpete/ http://www.data-mining.co.nz/ _______________________________________________ Wekalist mailing list -- [email protected] Send posts to [email protected] To unsubscribe send an email to [email protected] To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html