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

number_of_maxima only returns maxima of last key in the dictionary. #1072

Open
siddij3 opened this issue May 1, 2024 · 2 comments
Open

number_of_maxima only returns maxima of last key in the dictionary. #1072

siddij3 opened this issue May 1, 2024 · 2 comments
Labels

Comments

@siddij3
Copy link

siddij3 commented May 1, 2024

I ran kind_to_fc_parameters to extract custom parameters from the extract_features() function with a set of parameters, and in them was the following:

                "mean_n_absolute_max": [
                    {
                        "number_of_maxima": 7,
                        "number_of_maxima": 9,
                        "number_of_maxima": 11,
                        "number_of_maxima": 13,
                        "number_of_maxima": 15,
                        "number_of_maxima": 17,
                        "number_of_maxima": 19,
                        "number_of_maxima": 21,
                        "number_of_maxima": 23,
                    }
                ],

When looking at the returned columns, it only returned number_of_maxima_23 for all the timeseries columns.

Intial timeseries columns:

datetime  C_DIOXIDE  AMMONIA  H_SULFIDE  OXYGEN  TEMPERATURE

Extracted:

C_DIOXIDE-mean_n_absolute_max-number_of_maxima_23  AMMONIA-mean_n_absolute_max-number_of_maxima_23  OXYGEN-mean_n_absolute_max-number_of_maxima_23 etc. 

Environment:

  • Python version: 3.11.5
  • Operating System: Windows & Debian
  • tsfresh version: 0.20.0
  • Install method (conda, pip, source): pip
@siddij3 siddij3 added the bug label May 1, 2024
@nils-braun
Copy link
Collaborator

Hi @siddij3 (sorry for the super late response! )
I do not know where you got this specific list from (maybe you compiled it yourself?), but for usage in the kind_to_fc_parameters, this list has the wrong format. A your basically have a single dictionary for all the number_of_maxima settings, python will go ahead and combine them all into one key (you can go ahead and look at the resulting settings e.g. with a print statement and you will see, that even before you pass it to tsfresh, there is only a single entry (the last one) in it).
The format expected by tsfresh is a list of dictionaries. So for your use case:

settings = {
    "mean_n_absolute_max": [
        {
            "number_of_maxima": 7,
        },
        {
            "number_of_maxima": 9,
        },
        {
            "number_of_maxima": 11,
        },
        {
            "number_of_maxima": 13,
        },
        {
            "number_of_maxima": 15,
        },
        {
            "number_of_maxima": 17,
        },
        {
            "number_of_maxima": 19,
        },
        {
            "number_of_maxima": 21,
        },
        {
            "number_of_maxima": 23,
        }
    ],
}

With this, it will work as expected.

@siddij3
Copy link
Author

siddij3 commented May 29, 2024

Thanks for replying!
I compiled the list myself after filtering through the features based on their results and the physical implications of the features.
I completely overlooked the dictionary key overlapping. Thanks for pointing that out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants