Python Library (tsfresh) Convert to C++ for Time-Series Data

I am working on time-series data to build classic ML models for classification problem. I used a Python Library, tsfresh, to extract (calculate) all possible features on the data, and the library can filter significant features. Overall the library is very cool because it enables me to train the model with very high accuracy (0.95). However, I can’t use this preprocessing data on my company’s edge directly. It requires a python source code that can be converted to C++. I found on Edge Impulse has the custom processing block, which enable to export to C++. Can I paste the extract-feature functions from the tsfresh library into the file in the custom processing block so that it can export as C++? If yes, How can I do that?

This is the tsfresh library site where it shows all the function to extract the features
tsfresh.feature_extraction.feature_calculators — tsfresh 0.20.2.post0.dev1+ga7e14f8 documentation


1 Like

Hi @cindydao
I think the best starting point for you is our documentation about running the custom preprocessing blocks on the edge devices.
Generally, you need to implement/convert your Python code (or the key parts of the tsfresh library) into C/C++ and put the implementation in the extract_custom_block_features function (or any other name as you defined in the parameters.json of your custom preprocessing block).

Remember, your extract_custom_block_features function can be anything, not just a simple function. If you know how, you can even call external applications, and network services or call Python libraries directly using pybind11 or Python embeddings

Best regards,


Just in case Mat wasn’t clear, custom DSP block won’t export this code as CPP for you. You will need to manually port that py file.

As an alternative, many of the feature engineering offerings in tsfresh are present in our Flatten and Spectral Analysis blocks. Before converting tsfresh to cpp, you should try training your model with our blocks (you can use both as input to a model), and see if you can also get to 95% with our turnkey blocks. Those WILL automatically export to cpp


Thank you so much. I initially thought the custom DSP block can export my code to CPP. I will try those two blocks. Also, to convert those built-in processing blocks to C++, will have need to do on edge impulse interface or on my local computer?


When you’ve trained your model on our website and ready to run, refer to these tutorials and documents for how to deploy to test and run inference. Keeping coming back here if you get stuck or need any help with running the C++ inference library!