Skip to content

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

Open

Description

@BK201-kkk

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

Activity

  1. 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?[/+] on Jan 26, 2025
  2. Jacob-Stevens-Haas commented on Jan 27, 2025

    @Jacob-Stevens-Haas
    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docNeeds an edit to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions