umap icon indicating copy to clipboard operation
umap copied to clipboard

AlignedUMAP: transform new observations

Open spadarian opened this issue 2 years ago • 2 comments

Hi,

I was wondering if it is possible to transform new observations into the aligned embedding space.

Ideally, I would like to:

  • Use AlignedUMAP on dataset A and B (let's assume they have the same number of samples), with their corresponding relations (which is a 1:1 map... e.g. 0 -> 0, 1 -> 1, etc).

  • When I get a new sample for either A or B, I would like to transform the new sample to the aligned space.

  • Also, I would like to be able to back transform the new embedding to either of the original spaces (A or B)

I was hoping to do something like:

aligned_mapper = umap.AlignedUMAP(n_components=1000, target_metric='l1').fit([A, B], relations=relations)
emb = aligned_mapper.mappers_[0].transform(new_A)
back_A = aligned_mapper.mappers_[0].inverse_transform(emb)
back_B = aligned_mapper.mappers_[1].inverse_transform(emb)

but I realised that there are a bunch of steps after fitting each mapper (e.g.: procrustes_align).

Is it even possible to do this?

Cheers!

spadarian avatar Jan 27 '23 04:01 spadarian

Theoretically it is possible, but there certainly isn't code for handling such a case currently. It would be a non-trivial project to get something written that would actually do a decent job of this. Sorry I can't be more help right now.

lmcinnes avatar Jan 29 '23 00:01 lmcinnes

Hello,

Thanks for sharing this fantastic work.

I think that I have a question falling in the same category. I have mulit-variate time series according to the age of subjects (e.g., t=age= [1:1:90] ). I am using aligned_umap to reduce the number of components. Once I have my 2D+t embedding, I would like for a new subject to project in into the 2D embedding corresponding to his/her age. I failed to find the aligned_mapper.mappers_[t].transform(new_Subject) function? Does such function exist? Could you send me an example of .transform function calling in this case?

Best,

pierrickvolbrain avatar Nov 01 '23 08:11 pierrickvolbrain