neurostatslab / tensortools

A very simple and barebones tensor decomposition library for CP decomposition a.k.a. PARAFAC a.k.a. TCA
MIT License
162 stars 67 forks source link

WIP: Prediction API. #26

Closed arokem closed 3 years ago

arokem commented 4 years ago

Thanks for creating this useful project!

In working with the software, we (me and @zhounapeuw) found ourselves wanting to look directly at the reconstruction of the original tensor from the FitResult objects. Here, we propose an API for generating these "predictions" as a sum of the outer products of elements of the factors stored in the object.

Is this the right place to put something like this? Or is there a better way to recover this reconstruction?

ahwillia commented 4 years ago

Thanks for the feedback -- it makes me very happy that others are finding this useful!

I think what you are hoping to do could be achieved with:

result = FitResult(...)  
result.factors  # this is a KTensor object
result.factors.full()  # this is a reconstruction of the low rank tensor

I think full is a poor naming choice, and predict would be better. Perhaps we could just add a ktensor.predict() function that is synonymous with ktensor.full()? We can expose that functionality in FitResult as well.

Let me know if that checks out... I only glanced at this very quickly so I might have misunderstood something.

arokem commented 4 years ago

Yes. I think that we did was reimplement a (slow) version of the Khatri-Rao product + reshaping that are implemented in the full method. I think that the last commit I just pushed might give an API that makes sense. I think that the name full (or possibly asarray or to_array?) makes sense for the KTensor object, but predict makes more sense (to me) in the context of a FitResult object.

On Fri, Feb 28, 2020 at 12:25 PM Alex Williams notifications@github.com wrote:

Thanks for the feedback -- it makes me very happy that others are finding this useful!

I think what you are hoping to do could be achieved with:

result = FitResult(...) result.factors # this is a KTensor object result.factors.full() # this is a reconstruction of the low rank tensor

I think full is a poor naming choice, and predict would be better. Perhaps we could just add a ktensor.predict() function that is synonymous with ktensor.full()? We can expose that functionality in FitResult as well.

Let me know if that checks out... I only glanced at this very quickly so I might have misunderstood something.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ahwillia/tensortools/pull/26?email_source=notifications&email_token=AAA46NRQMYZ747DASWJMDN3RFFXK5A5CNFSM4K5GKTAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENKBH2Y#issuecomment-592712683, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA46NTMN34KNGWKCJTFKUDRFFXK5ANCNFSM4K5GKTAA .