garydoranjr / misvm

Multiple-Instance Support Vector Machines
BSD 3-Clause "New" or "Revised" License
234 stars 81 forks source link

Instance level predictions #8

Closed satpreetsingh closed 7 years ago

satpreetsingh commented 7 years ago

May I know if MISVM supports instance-level predictions?

garydoranjr commented 7 years ago

Hi Satpreet,

Yes, you should be able to get the instance-level predictions by passing instancePrediction=True to the predict function (https://github.com/garydoranjr/misvm/blob/master/misvm/sil.py#L50).

-Gary

satpreetsingh commented 7 years ago

Thank you, it seems like this has been implemented for 2/3 classifiers i.e. sbMIL & SIL, but not MissSVM. I was looking at help(MIssSVM), and didn't find it there.

garydoranjr commented 7 years ago

I see; yes, unfortunately this functionality is not implemented for all classifiers. One workaround is to create a list of "singleton" bags (bags that only contain one of each of the instances). Then, for most classifiers (mi-SVM, MICA, MissSVM, etc.), getting the bag labels for these singleton bags is equivalent to getting the instance labels of the individual instances they contain. The only classifiers this doesn't quite work for are the "set kernel" approaches (e.g., NSK), since these don't really produce meaningful instance-level labels (they directly learn bag-labeling functions).

Marjaneh-T commented 5 years ago

Hey Guys,

As you've mentioned above, to check the label in each instance for the test set, we put instancePrediction=True. I do have a question how it can predict labels for each instance without knowing the true label for it? And also, how we can add labels for each instance in each bag for training set?

garydoranjr commented 5 years ago

Hi @AshCK, one of the key learning tasks within the multiple-instance learning (MIL) framework is to predict instance labels using only bag-level label information. There are numerous strategies for doing this; I recommended reading the literature to learn more (the Wikipedia article provides a good overview). In the case of mi-SVM, for example, the idea is to treat instance labels as "latent" variables and optimize these while also optimizing the SVM solution, subject to the constraint that the latent instance labels are consistent with the bag labels.

The algorithms in this repository do not accept instance labels for training. If you had instance labels, then you could just use a standard supervised learning algorithm. In some cases, instance-level labels are available for MIL problems, but these are only used to evaluate the instance-level predictions of the algorithm.