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?
1 Answer
$\begingroup$
$\endgroup$
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()
best_features.sort_values(by=['p_value'])
best_features
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.