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

During the feature extraction process, how could I set the param from a subset of another columns. #1040

Open
lk1983823 opened this issue Aug 24, 2023 · 1 comment
Labels

Comments

@lk1983823
Copy link

For example, I want to use "number_crossing_m" to a column named "x1". So I have to set a parameter "m" to it. However, for the param "m", I want to let it be the mean of another column like "x2" or the "x1" itself. How should I do it ?

Thanks.

@lk1983823 lk1983823 added the bug label Aug 24, 2023
@kohlrabi90
Copy link
Contributor

Hi @lk1983823 ,
with the default feature extraction function, it is not possible to do this. However, you could run the extraction on each of your time series (columns) separately: first, extract the mean, then adjust the settings, and finally call feature extraction only on one series. Then repeat for the next.
You can use the feature extraction settings to customize "m".

Here is an example how you can set "m"

from tsfresh.feature_extraction import ComprehensiveFCParameters
from tsfresh.feature_extraction import extract_features

# Adjust the value for m
settings = ComprehensiveFCParameters()
settings["number_crossing_m"] = [{'m': your_mean_value}]

results = extract_features(df,  default_fc_parameters=settings)

Additionally, (but more complex), you could write your own custom feature calculator, which does (1) calculate the mean and (2) then call the original feature calculator. However, that only works for a single column (not when you want to use the mean for x2 for calculating x1). I would recommend the first option.

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