Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MrDMD] Enable per-level (and per-leaf) choice of DMD implementation #260

Merged
merged 2 commits into from
Apr 26, 2022

Conversation

fandreuz
Copy link
Contributor

@fandreuz fandreuz commented Apr 16, 2022

There are some use cases (see #251) in which it would be convenient to select different kinds of DMDs according to the level inside MrDMD, or to change some parameter depending on the depth.

In this PR I added the method _dmd_builder, which provides DMD-builder functions and generalizes the current approach for the construction of DMD instances. After this PR the parameter dmd of the constructor of MrDMD accepts values of type list, tuple, function and DMDBase. See the documentation of MrDMD._dmd_builder for more details and examples.

Example

We use a different kind of DMD if we are near the middle part of the time window:

>>> def my_dmds(level, leaf):
...     level_size = pow(2,level)
...     distance_from_middle = abs(leaf - level_size // 2)
...     # we choose 2 as a random threshold
...     if distance_from_middle < 2:
...         return HankelDMD(d=5)
...     else:
...         return DMD(svd_rank=3)
>>> MrDMD(dmd=my_dmds, max_level=5).fit(X)

@fandreuz fandreuz force-pushed the mrdmd-subdmd-per-level branch 3 times, most recently from 1380d8e to 86fd20f Compare April 16, 2022 22:38
@fandreuz fandreuz force-pushed the mrdmd-subdmd-per-level branch 2 times, most recently from a677f08 to 34a3d6a Compare April 22, 2022 12:26
@ndem0 ndem0 merged commit 65cdf42 into PyDMD:master Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants