1

I have a data frame which is a combination of FER (Facial Emotion Recognition) and Mood prediction

Now, the mood prediction dataset has two columns - Question and Prediction. The question represents three values [1 - Activation; 2 - Pleasance; 5- Stress] and the prediction column also has three values [0 - Low; 1 - Medium; 2 - High]. The index consists of timestamps.

I'd like to give a brief explanation about the screenshot 3 below. Let's consider the third row where the question value is 5 and the prediction value is 1. This indicates stress (5) of medium (1) level.

How can I plot the prediction of question values over time? I tried to do it but I am getting just one line for everything.

d = one.groupby('question')
dunk1 = d.get_group(1)
fig, ax1 = plt.subplots(figsize = (20,5))
x = one.index
y = one.prediction
ax1.plot(x,y,'r-')

Plot of my attempted code

image

I am looking to get an output that looks something like the following:

image

Screenshot of the dataset

dataset

William Miller
  • 9,839
  • 3
  • 25
  • 46

1 Answers1

1

You are plotting x and y from the original dataframe, not the grouped dataframe, you should be doing

d = one.groupby('question')
dunk1 = d.get_group(1)
fig, ax1 = plt.subplots(figsize = (20,5))
x = dunk1.index
y = dunk1.prediction
ax1.plot(x,y,'r-')

Or to plot all three question groups

d = one.groupby('question')
fig, ax = plt.subplots(figsize = (20,5))
for k in d.groups.keys():
    group = d.get_group(k)
    ax.plot(group.index, group.prediction)

But understand that this may not get you all the way to the result you want - there may be more filtering or sorting necessary.

William Miller
  • 9,839
  • 3
  • 25
  • 46
  • Mr. Miller, Thank you so much for your recommendation. This definitely worked and it looks like it answers a few other questions of my project too. Thank you so so so much. – Rahul Rewani Feb 10 '20 at 01:20
  • @RahulRewani Happy to help, feel free to comment with any follow up questions – William Miller Feb 10 '20 at 01:28