5

I am a beginner of using tsfresh. I am using it to extract characteristics from time series. Using the below code(sample code of tsfresh website) gives me 97 new features (F_x__abs_energy, F_x__range_count__max_1__min_-1, F_x__variance, F_x__standard_deviation and so on) for one feature named as F_x. But I don't need need all of them. Let's say i just want to calculate only F_x__variance and F_x__standard_deviation. What should I change in the below code?

from tsfresh import extract_relevant_features
from tsfresh.feature_extraction import ComprehensiveFCParameters
settings = ComprehensiveFCParameters()

features_filtered_direct = extract_relevant_features(df, y, column_id='id', column_sort='time')

I also read this documentation but I didn't find specific things to do this or may be I don't understand as a beginner. Correct me if I am wrong from my site.

2 Answers 2

6

So there are two things you can do:

  1. Setting the parameters of the feature extractor. This can be done by setting parameter "default_fc_parameters" in extract_features function. There are predefined settings that you can use. You can also make your own version and pass it to the function. The predefined ones are "ComprehensiveFCParameters", "MinimalFCParameters", and "EfficientFCParameters". Here is an example of how this is done:

    from tsfresh.feature_extraction import ComprehensiveFCParameters 
    from tsfresh.feature_extraction import extract_feature 
    settings = ComprehensiveFCParameters() 
    extract_features(df, default_fc_parameters=settings)
    

    similarly, you can define your features of interest as a dictionary and pass it as the "kind_to_fc_parameters" to the extract_features function. Look at the example below:

    kind_to_fc_parameters = {
    "F_x": {"mean": None, "std": None, "Variance": None} , "F_y" ={"min": None , "max": None }}
    extract_features(df, kind_to_fc_parameters =kind_to_fc_parameters)
    
  2. By getting all features and then filtering out the feature that you are interested in. The output of extract_features function is a data frame so you can just filter out the specific column that you are interested in. Here is an example:

      import pandas as pd
      from tsfresh.examples.robot_execution_failures import download_robot_execution_failures, load_robot_execution_failures
      from tsfresh import extract_features download_robot_execution_failures()
      timeseries, y = load_robot_execution_failures()
      extracted_features = extract_features(timeseries, column_id="id", column_sort="time")
      print(extracted_features["F_x__abs_energy"])
    

Take a look at the documentation for more info.

Sign up to request clarification or add additional context in comments.

Comments

0

For example, if you would want to calculate the absolute energy, import the function, abs_energy using the following:

from tsfresh.feature_extraction.feature_calculators import abs_energy

after which you could pass the time series as the argument: abs_energy(x)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.