How can I select the top n features of time series dataset using tsfresh? Can I decide the number of top features I would like to extract?


You can use tsfresh relevance table to solve this issue. After you extract your features with tsfresh:

from tsfresh.examples import load_robot_execution_failures
from tsfresh import extract_features, select_features
from tsfresh.feature_selection.relevance import calculate_relevance_table

y = pd.Series(data = extracted_features['class'], index=extracted_features.index)

relevance_table = calculate_relevance_table(features2, y)
relevance_table = relevance_table[relevance_table.relevant]
relevance_table.sort_values("p_value", inplace=True)

best_features = relevance_table.copy()



From now on, the only thing you need to do to choose the top n features. Just select fist n rows with the help of pandas.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.