Answers.Body: <p>there's a lot to un-pack in this question.</p>
  
  <p><em>Why do they only pick 500 rows?</em></p>
  
  <p>my guess: in order to keep the example running quickly. tsfresh usually takes a while to calculate its features.  note that when they evaluated their model, they took the last 500 samples.</p>
  
  <p><em>What's the point of re-arranging the rows/columns?</em></p>
  
  <p>answer: the data frame format that tsfresh requires in order to calculate features is that format. it is a bit of a pain...especially when you need to keep track of an id-column for other data.</p>
  
  <p><em>When they build their decicion tree learner with the train data, they build it upon extracted features.</em> </p>
  
  <p>answer: yes</p>
  
  <p><em>But how can we then use this tree for new sensor data?
  Should we extract the features of the new data and pass it as input for the tree?</em></p>
  
  <p>answer: yes</p>
  
  <p><em>But new sensor data might not have as many features as the train data. Eg: (ValueError: Number of features of the model must match the input. Model n_features is 321 and input n_features is 312)</em></p>
  
  <p>answer: yes it will. I don't know where your copy-pasted error message came from. When you generate a set of features using tsfresh, you can do it in a couple of different ways. you can generate all of them or you can generate a subset of them---they generated a subset...but then subsetted it once again(using their importance stuff...whether you use the importance methods or other methods to select features you will end up with a bunch of features you need to calculate). If you follow the procedure for generating features based on a pre-determined subset (relevant_features in their case), you will end up with the same # of features.  This needs to be stressed...<strong>don't generate tsfeatures that you don't need!</strong> as it will take foooorever.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-25T22:23:39.127Z
Answers.LastActivityDate: 2019-11-25T22:23:39.127Z
Answers.UserDisplayName: user1269942
Body: <p>I've got a timeseries with sensor data (e.g. accelerometer and gyroscope). I now want to extract the activity out of it (e.g. walking, standing, driving, ...). I Followed <a href="https://github.com/blue-yonder/tsfresh/blob/master/notebooks/human_activity_recognition_multi_class_example.ipynb" rel="nofollow noreferrer">this Jupyter Notebook</a>. But there are some issues left.</p>
  
  <ol>
  <li>Why do they only pick 500 rows?</li>
  <li>What's the point of re-arranging the rows/columns?</li>
  <li>When they build their decicion tree learner with the train data, they build it upon extracted features. But how can we then use this tree for new sensor data? Should we extract the features of the new data and pass it as input for the tree? But new sensor data might not have as many features as the train data. Eg: <code>(ValueError: Number of features of the model must match the input. Model n_features is 321 and input n_features is 312)</code></li>
  </ol>
  
Tags: <classification><decision-trees><time-series>
Title: Feature extraction timeseries, model compatibility
UserDisplayName: Wouter Vandenputte
ThreadText: # Feature extraction timeseries, model compatibility
  
  (Asked by: username_0 on 2019-11-24)
  
  I've got a timeseries with sensor data (e.g. accelerometer and gyroscope). I now want to extract the activity out of it (e.g. walking, standing, driving, ...). I Followed [this Jupyter Notebook](https://github.com/blue-yonder/tsfresh/blob/master/notebooks/human_activity_recognition_multi_class_example.ipynb). But there are some issues left.
  
  1. Why do they only pick 500 rows?
  2. What's the point of re-arranging the rows/columns?
  3. When they build their decicion tree learner with the train data, they build it upon extracted features. But how can we then use this tree for new sensor data? Should we extract the features of the new data and pass it as input for the tree? But new sensor data might not have as many features as the train data. Eg: `(ValueError: Number of features of the model must match the input. Model n_features is 321 and input n_features is 312)`
  
  **Tags:** classification, decision-trees, time-series
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-25. Score: 2 | Accepted answer
  
  there's a lot to un-pack in this question.
  
  *Why do they only pick 500 rows?*
  
  my guess: in order to keep the example running quickly. tsfresh usually takes a while to calculate its features. note that when they evaluated their model, they took the last 500 samples.
  
  *What's the point of re-arranging the rows/columns?*
  
  answer: the data frame format that tsfresh requires in order to calculate features is that format. it is a bit of a pain...especially when you need to keep track of an id-column for other data.
  
  *When they build their decicion tree learner with the train data, they build it upon extracted features.*
  
  answer: yes
  
  *But how can we then use this tree for new sensor data?
  Should we extract the features of the new data and pass it as input for the tree?*
  
  answer: yes
  
  *But new sensor data might not have as many features as the train data. Eg: (ValueError: Number of features of the model must match the input. Model n\_features is 321 and input n\_features is 312)*
  
  answer: yes it will. I don't know where your copy-pasted error message came from. When you generate a set of features using tsfresh, you can do it in a couple of different ways. you can generate all of them or you can generate a subset of them---they generated a subset...but then subsetted it once again(using their importance stuff...whether you use the importance methods or other methods to select features you will end up with a bunch of features you need to calculate). If you follow the procedure for generating features based on a pre-determined subset (relevant\_features in their case), you will end up with the same # of features. This needs to be stressed...**don't generate tsfeatures that you don't need!** as it will take foooorever.
  
  
  ---
  
  