Machine Learning & Stress Prediction

Seeking a reliable way to measure when I was am in a relaxed and focussed frame of mind and when I was feeling stress I looked again at the data I had collected for several sessions. I used the data from the readings when I was getting my tooth drilled and when I was giving a speech as a reliable reading of when I was in a stress state. I also used sessions of high coherence while using Heartmath Pro as a baseline for when I was in a relaxed state. I used this as a training set which I fed into an Artificial Neural Network using a freeware package called WEKA.  

The machine learning algorithm came back with a 98.3% accuracy on the ability to classify whether I was relaxed or stressed. Now that I had an algorithm I could run it on other data to see how it looked. First I ran the data for a meeting I had with a colleague that was very positive. Running the data I was not surprised to see that I was relaxed during the majority of the session. Twice I dropped into stress in a 53 minute meeting. That was consistent with my experience. 

Slide2

Running the algorithm on a second meeting gave me a different outcome. I remember the meeting well and the conversation was not combative, but the topic was more difficult. This result was more of a stress state with a four time periods where I was in Poise. Again this was consistent with my experience of the meeting. 

Slide1

I cut the data in the training set and the meeting data lists into 30 second increments. This is the shortest period of time needed to get a meaningful set of heart rate variability data.  It also allows me to use my previous work in returning to Poise as a comparison. The next step is to run the algorithm on the data from different situations. 

6 Comments

Interesting approach! What’s the input, the frequency spectrum data?

What motivated the choice of a neural net instead of the usual defaults for a binary classification problem (like a logistic regression)? Did it perform much better?

    The classification of Heart Rate Variability (HRV) measures as either being in stress can be examined using linear regression at this stage. I chose to start working with machine learning (ML) for several reasons. I see it as a stepping stone to better QS work in the future. I plan to add more features in future studies making the path to a solution more complex. ML can potentially find the stress/not point without even needing a training set. I would like to end with an application that takes moment to moment heart rate data, other inputs (cognitive responses to test, weather, etc) and finds a stress/not point. All of these contributed to picking ML as a tool to start using.

      > I see it as a stepping stone to better QS work in the future.

      I’m not sure what you learned from this, though. You used a blackbox method which you can’t intepret (which of the variables are important and predictive and why?) and which you didn’t compare to any other methods, and so you don’t know if the classification is good at all and didn’t test it on other data by your description. (A good paper on machine learning is “A Few Useful Things to Know about Machine Learning” http://www-edlab.cs.umass.edu/cs689/2013-readings/ml-survey.pdf Domingos 2012.) Taking a quick look at your summary:

      > The machine learning algorithm came back with a 98.3% accuracy on the ability to classify whether I was relaxed or stressed. Now that I had an algorithm I could run it on other data to see how it looked. First I ran the data for a meeting I had with a colleague that was very positive. Running the data I was not surprised to see that I was relaxed during the majority of the session. Twice I dropped into stress in a 53 minute meeting. That was consistent with my experience.

      98% may sound good, except stress is rare; if you classify each minute and you stress 96% accuracy (100 – ((2/53)*100)=96.2%) simply by marking every time period as relaxed! So how good is the neural network actually…?

      > ML can potentially find the stress/not point without even needing a training set.

      But you didn’t.

      Thanks very much for taking the time to read through my post and give feedback. Very useful to engage on the detail and I appreciate that immensely.

      I followed the protocol used by an academic study that ran four different ML algorithms on heart rate data. I used 11 derived features looking for those that would be the most relevant. Turns out the most relevant are the time based features rMSSD and HRVTI. This was similar to the academic study. So I learned that I did not need 11 features to get answers which reduced my load tremendously. I think that is an important bit of information.

      Stress in my experience is not rare. I have sessions where I am “in stress” over 60% of the time. So simply saying all periods are relaxed across multiple sessions would lead to very large errors. The accuracy was on a training set that pulled from very different contexts – having a tooth drilled vs. meditating.

      I have not yet done ML on the data without a training set and I look forward to doing that in the future. You asked why and I said that is the potential which informed my choice.

      All good stuff, and as a hobbyist I do this for fun. Your comments make it sharper and I appreciate it. Let’s keep the discussion going!

      Thanks,
      Paul

Leave a Reply

Name and email address are required. Your email address will not be published.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

You may use these HTML tags and attributes:

<a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <pre> <q cite=""> <strike> <strong> 

Follow

Get every new post delivered to your Inbox.

Join 1,128 other followers

%d bloggers like this: