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

How to use CustomLibrary to achieve that each variable has an associated library? #592

Open
BK201-kkk opened this issue Jan 26, 2025 · 1 comment
Labels
doc Needs an edit to documentation

Comments

@BK201-kkk
Copy link

BK201-kkk commented Jan 26, 2025

I try to create a separate library for each variable through CustomLibrary. This means that my input data consists of n different variables, with shape (time_steps, num_variables). For each ode xi_dot that I want to regress, there is a separate library. My idea is to build library_functions = [
[x0_library], # x0 function library
[x1_library], # x1 function library
[x2_library], # x2 function library
[x3_library], # x3 function library
[x4_library], # x4 function library
[x5_library], # x5 function library
[x6_library], # x6 function library
[x7_library], # x7 function library
]
lib = ps.CustomLibrary(library_functions=library_functions)
AttributeError: 'list' object has no attribute 'code'
But this doesn't seem to work, please let me know if I'm missing something, thank you very much for your answer!

My idea is based on the description on the pysindy website:
library_functions (list of mathematical functions) – Functions to include in the library. Default is to use same functions for all variables. Can also be used so that each variable has an associated library, in this case library_functions is shape (n_input_features, num_library_functions)
, but it doesn't seem to work

@BK201-kkk BK201-kkk changed the title How to use CustomLibrary to ensure that each variable has an associated library? How to use CustomLibrary to achieve that each variable has an associated library? Jan 26, 2025
@Jacob-Stevens-Haas
Copy link
Member

library_functions (list of mathematical functions) – Functions to include in the library. Default is to use same functions for all variables. Can also be used so that each variable has an associated library, in this case library_functions is shape (n_input_features, num_library_functions)

This is a mistake in the documentation. The correct way is to use a GeneralizedLibrary, which is a wrapper that has the specific purpose of controlling how variables and libraries are combined. It has an inputs_per_library argument that handles this.

@Jacob-Stevens-Haas Jacob-Stevens-Haas added the doc Needs an edit to documentation label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Needs an edit to documentation
Projects
None yet
Development

No branches or pull requests

2 participants