0% found this document useful (0 votes)
4 views14 pages

SoulScript: Sentiment Analysis for Mental Health

Uploaded by

deysoumyajit323
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views14 pages

SoulScript: Sentiment Analysis for Mental Health

Uploaded by

deysoumyajit323
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PROJECT REPORT

On
SoulScript: A Data-Driven Sentiment Analysis Platform for
Mental Health and Mood Tracking

By

SHINJINI NAG
[22CS011181]
SIDDHARTHA SANKAR BERA
[22CSO11189]
SRIJITA DASGUPTA
[22CS011215]
SOUMYAJIT DEY
[22CS011206]

Under the supervision


Of

Dr Tanaya Das
Assistant Professor
Department of Computer Science & Engineering
(2024)

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING
JIS UNIVERSITY,KOLKATA
ABSTRACT
SoulScript is an interactive journaling and mood-tracking platform that leverages data science
and Natural Language Processing (NLP) techniques to analyze user-generated text and provide
actionable mental health insights. The platform allows users to either freely express their
thoughts or respond to curated prompts, subsequently performing sentiment analysis to calculate
a quantified mood score. Built with the Streamlit framework, the application offers a
user-friendly interface that integrates dynamic data visualization and personalized feedback to
enhance emotional awareness and promote mental well-being.

The sentiment analysis is powered by TextBlob, a pre-trained NLP model that computes the
polarity score of journal entries, quantifying sentiments on a scale from -1 (negative sentiment)
to +1 (positive sentiment). The raw polarity scores are normalized to a 0-10 range, providing
users with an intuitive "Mood Score." Daily mood scores are logged, enabling the construction of
a time-series dataset that tracks emotional trends throughout the week. The system visualizes
these trends via a line graph, plotting scores for each day from Monday through Sunday, and
generates a comprehensive weekly mood report. This report includes the user’s average mood
score, variability metrics, and a textual summary of emotional trends, offering a deeper
understanding of mental states over time.

The project employs Pandas for data storage and manipulation, Matplotlib for creating
time-series visualizations, and TextBlob for sentiment scoring. The app also provides real-time
personalized recommendations: uplifting messages for high mood scores and actionable
strategies for improving mental health when scores are low.

SoulScript demonstrates the practical application of data science in mental health by combining
real-time sentiment analysis, user-specific data visualization, and personalized feedback. Its
potential extends to predictive modeling for early intervention in mental health crises, making it
a scalable and impactful tool for emotional well-being monitoring in diverse populations.

Keywords: Sentiment Analysis, Natural Language Processing, Mental health tracking,


TextBlob, mood score visualization, Journaling platform.
INTRODUCTION
Mental health is a critical component of overall well-being, yet it is often overlooked or
stigmatized. According to the World Health Organization, over 970 million people
worldwide—approximately 13% of the global population—struggle with mental health disorders
such as anxiety and depression. Depression alone is the leading cause of disability worldwide,
affecting over 280 million people. Studies indicate that individuals with untreated mental health
conditions face a 20% higher risk of developing chronic illnesses and reduced life satisfaction.

Among various therapeutic techniques, journaling has emerged as a powerful tool for enhancing
mental health. Research shows that expressive writing can reduce stress by up to 27%, while
85% of people who journal regularly report improved emotional clarity and reduced anxiety
levels.

With the advent of data science and Natural Language Processing (NLP), traditional journaling
can be transformed into an insightful and interactive experience. SoulScript is a
sentiment-analysis-based journaling platform that combines the therapeutic benefits of writing
with the analytical power of technology. By analyzing sentiment, the app provides a quantified
mood score and tracks weekly emotional trends through interactive visualizations.

This project bridges the gap between emotional well-being and technology, offering a scalable,
user-friendly solution for mental health tracking and enhancement in the digital age.

Key Contributions of this Project

1. Sentiment Analysis for Journaling: Utilizes TextBlob to analyze journal entries and
generate a mood score, offering personalized feedback based on sentiment.
2. Mood Tracking and Visualization: Tracks daily mood scores and provides interactive
graphs to visualize emotional trends over time.
3. Personalized Mental Health Recommendations: Delivers real-time recommendations
based on sentiment scores to improve mental well-being.
4. Weekly Mood Reports: Generates a detailed report summarizing weekly mood trends
and insights to help users manage their emotional health.
BACKGROUND & LITERATURE SURVEY

[1] PRISM: A DATA-DRIVEN PLATFORM FOR MONITORING MENTAL HEALTH.

MAULIK R. KAMDAR and MICHELLE J. WU.

Stanford University.

The study lacks a robust validation with a larger and more diverse sample, limiting the
generalizability of its findings. Additionally, the reliance on self-reported emotional states for
model training may introduce biases and limit objective measurement accuracy.

[2] A survey on big data-driven digital phenotyping of mental health.

Yunji Liang, Xiaolong Zhen, Daniel D. Zeng.

Polytechnical Univeristy.

The review lacks a detailed discussion on the ethical and privacy concerns associated with using
ubiquitous sensors and social media data for mental health monitoring. Additionally, the
proposed research framework appears broad and may benefit from more concrete, actionable
recommendations for advancing the field.

[3] Emotional Health: A Data Driven Approach to Understand our Emotions and Improve
our Health.

Chandrasekar Vuppalapati; Sharat Kedari; Anitha Ilapakurti; Santosh Kedari; Jaya Shankar.

San Jose State University.

The abstract lacks clarity on the specific methods or technologies used to capture and interpret
physiological signals for emotion recognition, making it vague in terms of practical
implementation. Additionally, it does not address the potential challenges related to the accuracy,
ethical concerns, or privacy issues of using such data in emotion recognition systems.

[4] Emotion AI-Driven Sentiment Analysis: A Survey, Future Research Directions, and
Open Issues.

Priya Chakriswaran, Durai Raj Vincent.

Soonchunhyang University.
The paper lacks a critical evaluation of the limitations and challenges faced by the various
sentiment analysis approaches it reviews. Additionally, it provides limited insights into how the
findings can be applied to real-world emotion AI applications, particularly in sensitive domains
like mental health.

[5] Explainable Deep Attention Active Learning for Sentimental Analytics of Mental
Disorder.

Usman Ahmed, Rutvij H. Jhaveri.

Pandit Deendayal Energy University.

The approach lacks a clear comparison with existing models to demonstrate its relative
advantages and limitations. Additionally, the reliance on unstructured data and active learning
raises concerns about data quality and the model's scalability in real-world applications.

[6] A Smart Data-Driven Prototype for Depression and Stress Tracking in Patients.

Pragya Pranjal, Saahil Mallick, Malvika Madan, Sushruta Mishra.

Kalinga Institute of Industrial Technology University.

The paper lacks a detailed explanation of how IoT devices and emotion detection methods are
integrated into the proposed model and the potential limitations of such integration. Additionally,
the high success rate of 96.1% is not sufficiently validated with diverse patient populations or
real-world settings, raising concerns about its generalizability.

[7] Augmented Intelligence in Mental Health Care: Sentiment Analysis and Emotion
Detection with Health Care Perspective.

Asmita De, Sushruta Mishra.

Deemed to be University.

The paper lacks depth in discussing the specific challenges and limitations of using sentiment
analysis for mental health, particularly in relation to data quality and ethical concerns.
Additionally, it fails to provide concrete examples or case studies to demonstrate the practical
application of sentiment analysis in real-world mental health monitoring.

[8] Mobile and wearable sensors for data-driven health monitoring system: State-of-the-art
and future prospect.

Chioma Virginia Anikwe, Henry Friday Nweke, Anayo Chukwu Ikegwu.


Alex Ekwueme Federal University.

The paper provides a broad overview but lacks in-depth analysis of the specific challenges
associated with integrating and scaling sensor-based health systems in real-world settings.
Additionally, it does not sufficiently address issues like data privacy, sensor accuracy, or the
practical limitations of deploying these systems on a large scale.

[9] Digital health data-driven approaches to understand human behavior.

Lisa A. Marsch.

University of Chinese Academy of Sciences.

The review lacks specific examples or case studies that demonstrate the practical application of
digital health data in real-world settings, making it difficult to assess its impact. Additionally, the
manuscript does not address key challenges, such as data privacy, security, or the integration of
digital health data into existing clinical workflows.

[10] Promoting Remote Employee Well-being: Role of Emotion Detection, Social Media
Analysis, Mental Health Monitoring, and Performance Tracking.

Kushan Dimantha De Silva, Punsith, Hivindu.

The Islamic University.

The study lacks clarity on how emotion detection and social media analysis are ethically
managed, especially concerning privacy concerns of remote employees. Furthermore, the
reliance on self-reported feedback and subjective performance tracking may introduce biases,
limiting the accuracy of mental health predictions and work efficiency assessments.
METHODOLOGY
User Input Handling and Data Acquisition

In this project, user input is gathered through interactive widgets in Streamlit, such as text input
fields and buttons, allowing users to freely express their thoughts and emotions. The app offers
the option to either write a personal entry or select from a pre-defined journal prompt to guide
the user. Once the user provides their input, the system captures the raw text, preparing it for
further analysis. This real-time input handling ensures smooth and intuitive interactions,
providing a seamless experience for users to track their mental well-being.

Data Persistence and Management

User input data, including journal entries, sentiment scores,


and mood tracking information, is stored and managed using
Pandas for efficient CSV data handling. When users submit
their entries, the raw text along with the associated sentiment
score and mood ratings are stored in a structured CSV file.
Pandas provides powerful tools for organizing this data,
allowing for easy manipulation, retrieval, and analysis. The
data is continuously updated with each new entry, ensuring
the dataset remains current and relevant. The system tracks
daily mood fluctuations over time, enabling comprehensive
mood tracking and time-series analysis. This persistent storage mechanism ensures that all user
data is securely retained and easily accessible for future analysis and visualization.
Sentiment Analysis with TextBlob

Sentiment analysis in this project is implemented


using TextBlob, a powerful Natural Language
Processing (NLP) library. For each journal entry, the
system extracts the polarity
score, which ranges from -1
(negative sentiment) to +1
(positive sentiment). This
polarity score is then transformed into a normalized mood score on a
scale of 0 to 10. A polarity score of -1 is mapped to a mood score of 0,
indicating very negative sentiment, while a score of +1 corresponds to a
mood score of 10, reflecting highly positive sentiment. Scores in between
are linearly scaled to provide a nuanced representation of the user’s
emotional state.

Dynamic Mood Visualization

Dynamic mood visualization is achieved using Matplotlib


and Pandas to create time-series plots of daily mood scores.
Each user entry, including the mood score and timestamp, is
stored in a Pandas DataFrame with datetime indexing to
accurately track daily moods. These mood scores are then
plotted over time using Matplotlib, providing a clear visual
representation of mood trends. The plot is dynamically updated
with each new entry, offering real-time mood tracking. This
visualization technique helps users identify patterns and
emotional shifts, while Matplotlib allows for customization,
enhancing the clarity of the time-series analysis.

Personalized Feedback Generation based on


Sentiment

A rule-based system is implemented to dynamically


generate feedback based on the mood score from
sentiment analysis. Scores < 5 are flagged as reflecting
negative emotions, triggering actionable
recommendations like relaxation techniques or
mindfulness exercises to improve mental well-being. Scores ≥ 5, associated with positive
emotions, activate positive reinforcement mechanisms, providing motivational messages and
affirming the user’s progress. This logic-driven feedback loop ensures that each journal entry
receives context-appropriate support, creating a <constructive and empathetic> journaling
environment.

Weekly Mood Trend Analysis and Report Generation

Weekly mood trends are analyzed by aggregating daily mood scores using Pandas to compute
metrics like the weekly average (μ = Σx / n,) where x is the daily mood score and n is the
number of entries) and variability (σ² = Σ(x - μ)² / n,) where σ² represents variance).
These metrics provide insights into emotional stability and fluctuations over the week. Using
Matplotlib, the mood scores are visualized as a line graph, highlighting trends over seven days.
Additionally, textual reports summarizing patterns, such as "Consistent positive mood" or
"Increased variability mid-week," are generated. This combination of statistical metrics and
visual representation offers users a clear understanding of their emotional trajectory.

Front-End Interface Development with Streamlit

The front-end interface is designed in


Streamlit to provide an intuitive and interactive
user experience. Features include real-time
input forms for journaling, dynamic updates
for sentiment-based feedback, and
visualizations like mood graphs. The
streamlined layout ensures seamless navigation,
while widgets like buttons and text areas
enhance user interaction, enabling an engaging
and responsive interface.

Deployment and Hosting of Web Application

The application is deployed on Streamlit Community Cloud, enabling seamless hosting and
accessibility. This platform allows the app to run directly in the browser, ensuring users can
interact with it without requiring local installations.
EXPERIMENT & RESULTS

User Input: Prompt or Freestyle Journaling

The app begins by presenting the user with two options: either to write freely or choose from a
range of pre-defined prompts. The prompts are displayed as short, engaging one-liners to
inspire journaling. Users can switch prompts until they find one they like or opt to write their
own thoughts. The journaling entry is submitted through a simple text input form.

Sentiment Analysis and Feedback Generation

Upon submission, the app performs sentiment analysis using TextBlob in real-time. It
calculates the polarity score and converts it into a normalized mood score on a scale of 0–10.
Based on this score, the app generates personalized feedback. For scores below 5, users receive
mental health suggestions such as relaxation techniques, while higher scores trigger positive
reinforcement with motivational messages.
Navigation Through Tabs

The interface features two tabs:

1. Journaling Tab: Allows users to continue writing and submitting entries.


2. Weekly Report Tab: Displays a detailed summary of mood trends over the past week.

Weekly Report: Mood Analysis and Recommendations

In the Weekly Report Tab, the app aggregates all journal entries from the past seven days. It
displays a line graph plotting daily mood scores using Matplotlib, providing a visual
representation of mood fluctuations. Below the chart, a textual report summarizes the user’s
emotional trends, including the weekly average mood score and variability. Recommendations
are tailored to the weekly patterns, offering actionable insights to improve emotional well-being.

This structured flow ensures that the app delivers an engaging, data-driven journaling experience
while offering meaningful insights into users' mental health.
CONCLUSION & FUTURE SCOPE
The project successfully demonstrates the integration of sentiment analysis and data
visualization to create an interactive journaling application, SoulScript. By providing
personalized feedback and tracking emotional trends over time, the app offers users a meaningful
way to monitor their mental well-being. The use of Streamlit ensures an engaging and
user-friendly interface, while the combination of Pandas and Matplotlib delivers accurate data
management and visualization. Overall, the project emphasizes the potential of technology in
enhancing self-awareness and promoting positive mental health practices.

Future Scope

1. Advanced Sentiment Analysis Models: Integrate more sophisticated machine learning


models or transformer-based NLP models, such as BERT, for improved sentiment
accuracy.
2. Customizable Prompts and Recommendations: Allow users to personalize journaling
prompts and feedback, tailoring the experience to individual needs and preferences.
3. Integration with External Platforms: Expand the app by integrating with platforms like
Google Calendar or fitness trackers to correlate mood trends with lifestyle habits,
providing deeper insights into mental health.
REFERENCE
[1] Kamdar, M.R. and Wu, M.J., 2016. PRISM: a data-driven platform for monitoring mental health. In
Biocomputing 2016: Proceedings of the Pacific Symposium (pp. 333-344).

[2] Liang, Y., Zheng, X. and Zeng, D.D., 2019. A survey on big data-driven digital phenotyping of mental
health. Information Fusion, 52, pp.290-307.

[3] Vuppalapati, C., Kedari, S., Ilapakurti, A., Kedari, S. and Shankar, J., 2019, August. Emotional health:
A data driven approach to understand our emotions and improve our health. In 2019 IEEE International
Conference on Computational Science and Engineering (CSE) and IEEE International Conference on
Embedded and Ubiquitous Computing (EUC) (pp. 339-347). IEEE.

[4] Chakriswaran, P., Vincent, D.R., Srinivasan, K., Sharma, V., Chang, C.Y. and Reina, D.G., 2019.
Emotion AI-driven sentiment analysis: A survey, future research directions, and open issues. Applied
Sciences, 9(24), p.5462.

[5] Ahmed, U., Jhaveri, R.H., Srivastava, G. and Lin, J.C.W., 2022. Explainable deep attention active
learning for sentimental analytics of mental disorder. Transactions on Asian and Low-Resource Language
Information Processing.

[6] Pranjal, P., Mallick, S., Madan, M., Mishra, S., Alkhayyat, A. and Bhaktisudha, S., 2023, February. A
Smart Data-Driven Prototype for Depression and Stress Tracking in Patients. In International Conference
On Innovative Computing And Communication (pp. 423-434). Singapore: Springer Nature Singapore.

[7] De, A. and Mishra, S., 2022. Augmented intelligence in mental health care: sentiment analysis and
emotion detection with health care perspective. Augmented intelligence in healthcare: a pragmatic and
integrated analysis, pp.205-235.

[8] Anikwe, C.V., Nweke, H.F., Ikegwu, A.C., Egwuonwu, C.A., Onu, F.U., Alo, U.R. and Teh, Y.W.,
2022. Mobile and wearable sensors for data-driven health monitoring system: State-of-the-art and future
prospect. Expert Systems with Applications, 202, p.117362.

[9] Anikwe, C.V., Nweke, H.F., Ikegwu, A.C., Egwuonwu, C.A., Onu, F.U., Alo, U.R. and Teh, Y.W.,
2022. Mobile and wearable sensors for data-driven health monitoring system: State-of-the-art and future
prospect. Expert Systems with Applications, 202, p.117362.

[10] De Silva, K.D., Punsith, H., Damayanthi, H.N.P., Perera, R., Chandrasiri, S. and De Silva, H., 2023.
Promoting Remote Employee Well-being: Role of Emotion Detection, Social Media Analysis, Mental
Health Monitoring, and Performance Tracking. International Research Journal of Innovations in
Engineering and Technology, 7(10), p.42.

You might also like