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

1
  • Have you had a chance to try the method in my answer? Commented Feb 3, 2020 at 0:36

1 Answer 1

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.

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

2 Comments

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.
@RahulRewani Happy to help, feel free to comment with any follow up questions

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.