GAA-UAM / scikit-fda

Functional Data Analysis Python package
https://fda.readthedocs.io
BSD 3-Clause "New" or "Revised" License
287 stars 51 forks source link

`FDataGrid.__call__` any (compatible) shape? #562

Open ego-thales opened 10 months ago

ego-thales commented 10 months ago

Hi,

Currently, FDataGrid.__call__ only takes shapes (n_samples, dim_domain) or (dim_domain,) (or () when dim_domain == 1). I think it would be natural to allow any shape + (dim_domain,) to allow for multiple dimension evaluation without going through the trouble of flattening before and unravelling after.

What do you think? Élie

vnmabus commented 10 months ago

Sorry, I have trouble understanding the proposed behaviour, can you show an example?

ego-thales commented 10 months ago

For example, suppose you have fd with dim_domain = 3, dim_codomain = 4. If I want to evaluate fd on an edge of its domain (which is a 2D surface of size, say, n*m), I would do the following:

Is it a bit more understandable?

It is essentially a situation I faced in implementing #561.

eliegoudout commented 7 months ago

For future reference in case we revisit, I make things more clear.

The proposed version is that :

We can also discuss about the best position for any_shape in the input and output shapes tuples.

vnmabus commented 7 months ago

So, I am toying with generalizing the functions in https://github.com/GAA-UAM/scikit-fda/tree/feature/ndfunction, and I am starting to modify the evaluation. What I want to achieve is:

This is a bit difficult to reason about, so I would appreciate any suggestions given all these constraints.

vnmabus commented 7 months ago

So, for the aligned non-grid case (the easiest to reason about), we would have:

vnmabus commented 7 months ago

Now, the unaligned case has exactly the same out-shape, but shape has to be present in in-shape too. The most natural way would be to have matching input and output, and so in-shape should be (shape, points_shape, input_shape).

It would have been great to be able to discern between aligned and unaligned from the shape of the evaluation points alone, without the need of an align keyword parameter, but I do not see how that could be possible given that points_shape is arbitrary.

Also, in this proposed API there is no discussion about broadcasting at all. We should probably discuss if/when broadcasting should be allowed and how.