metric-learn
metric-learn copied to clipboard
Refactor LMNN as a triplets learner
Addresses my request in #210.
- Introduces a _BaseLMNN/ LMNN class to operate on triplets, s.t.
d(triplets[i, 0],triplets[i, 1]) < d(triplets[i, 0], triplets[i, 2])- the same setup as SCML.
- from this definition of triplets, create a 'label mask', an nxn matrix with mask[i,j] = 1 and mask[i,k] = -1 for the set triplet[i,j,k] (else 0).
- This simply reformulates the
loss_grad/_find_impostorsto operate on this label mask (imposters that violate the large margin) are detected by evaluating the squared distances of entries implied by -1 values in the mask. - the desired parameter k can be inferred from the triplets by counting unique occurrences of genuine and imposter pairs
- Renames LMNN to LMNN_Supervised.