Details for iMoodJournal_visualization.ipynb

Published by Wenqiu999

Description

Visualize the data exported from iMoodJournal.

1

Tags & Data Sources

visualization mood change mood variance iMoodJournal

Comments

Please log in to comment.

Notebook
Last updated 4 years ago

This notebook is used to analyze mood changed over time based on iMoodJournal data. It used a data file exported from iMoodJournal. You can upload your own Mood data and use the code to analyze. And This notebook is free to reuse and adapt, distributed under an MIT license: https://opensource.org/licenses/MIT

Let's import packages first.

Load the data.

First, let's start with a line plot of the full time period to show the changes over time.

The chart above shows the trend of your mood change over the whole period. Now, let's take a look at how our mood changes daily. Calculate the average level of daily mood.

Then, compare the daily average mood with the mood log.

From the chart above, we can see the difference between your actual mood data and the daily average.

To explore how your mood changes everyday and also compare across the whole period, let's use heat map to plot in a more colorful way. First, we need to convert the incomplete time list into a complete time list. The mood level of the moment will be recorded as NAN if there isn't any data point at that time.

/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:12: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  if sys.path[0] == '':
/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:13: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  del sys.path[0]

Now, we have our complete hourly mood log. Let's transpose the matrix first.

Let's use heatmap to provide a more intuitive, left-to-right data layout, with each row representing the hour and each column representing the day. Color Red stands for good mood, the more red the better. Color Blue stands for bad mood, while color Green means your mood was so-so at that time.

We can also further explore your mood changes within one day. Select one date and plot your mood log of that day.

To further explore the variation of the mood during this period, we will try to use Pareto chart to highlight the most representative mood levels over the whole period. First, we need to caculate the frequency of the levels of mood.

Out[14]:
LevelText Date
0 Bad 20
1 Good 127
2 Great 3
3 Meh 21
4 Okay 130
5 So-so 58
6 Very bad 1
7 Very good 30

Then let's plot the frequency in Bar chart.

Now, we can use a pareto chart to represnt both the frequency and the cumulative percentage of the mood levels.

The cumulative percentage may vary based on the type of your mood. Let's also plot two separate Pareto Charts for negative mood and positive mood.

Events happened in someone's daily life can influence his/her mood. Let's highlight the period and add annotations to help you understand your own mood. Please input the time period and the event happened during the period below.

Now, we can grab this period and the event.

Let's take a look at the peak and nadir of your mood during this period.

The moment that your felt best during the period: 2019-07-02 12:20:00
The moment that your felt worse during the period: 2019-07-04 20:09:00

According to the time points above, you can input the events happened at that moment below.

Now, we can highlight the period you selected and add your notes to the plot.

Let's take a look at the tags you added now.

First, Let's try to plot a bar chart to explore the frequencies of the tags you used.

To present the frequecies of tags in another way, we can use word cloud. The bigger the font of the tag is, the more frequent you used this tag.

Requirement already satisfied: wordcloud in /opt/conda/lib/python3.6/site-packages
Requirement already satisfied: pillow in /opt/conda/lib/python3.6/site-packages (from wordcloud)
Requirement already satisfied: numpy>=1.6.1 in /opt/conda/lib/python3.6/site-packages (from wordcloud)
You are using pip version 9.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

To compare the difference of your mood trend on weekdays and weekends, let's plot your actual mood data point in a run chart as well as lines representing the hourly average and rolling means.