Professional Documents
Culture Documents
Final Yr Report
Final Yr Report
A PROJECT REPORT
Submitted by
KAVIYARASAN V 731120106011
MAHESHWARAN A 731120106015
AJAY M 731120106301
JEEVA ANANTH V 731120106307
BACHELOR OF ENGINEERING
In
Submitted by
KAVIYARASAN V 731120106011
MAHESHWARAN A 731120106015
AJAY M 731120106301
JEEVA ANANTH V 731120106307
BACHELOR OF ENGINEERING
In
SIGNATURE SIGNATURE
Dr. R. VALARMATHI ,M.E., Ph.D,, Dr.P.KALIRAM ,M.E.,Ph.D.,
HEAD OF THE DEPARTMENT ASSISTANT PROFESSOR
ENGINEERING, ERODE-638316.
ERODE-638316.
3
ACKNOWLEDGEMENT
Above all we are grateful to all our classmates and friends for their
friendly cooperation and their exhilarating company.
4
TABLE OF CONTENT
ABSTRACT
LIST OF FIGURES
LIST OF ABBREVIATIONS
1 INTRODUCTION 10
3 CHATBOTS 19
3.1 CHATBOT
3.2 TYPES OF CHATBOTS
3.3 HOW DO CHATBOTS WORK
3.4 OPTIONS TO BUILD CHATBOTS
3.5 CHATBOTS PLATFORM
ALTERNATIVES
3.6 SELECTED PLATFORM
6 SYSTEM DESIGN 35
8 SYSTEM TESTING 43
8.1 UNIT TESTING
8.2 INTEGRITY TESTING
9 CONCLUSION AND FUTURE 45
ENHANCEMENT
9.1 CONCLUSION
9.2 FUTURE ENHANCEMENT
10 APPENDIX
48
10.1 SOURCE CODE
10.2 OUTPUT
REFERENCES
6
ABSTRACT
Therefore, we will create a chatbot for get mental illness. The project
“COGITO” addresses the need for a user-friendly digital assistant aimed at
providing suggestions for the mental illness problems for the user.
7
LIST OF FIGURES
8
LIST OF ABBREVIATIONS
AI - Artificial Intelligence
9
CHAPTER 1
INTRODUCTION
10
1.1 PROBLEM STATEMENT
1.2 OBJECTIVES
Designing an AI Chatbot system capable of providing personalized mental
health support and interventions tailored to individual needs and
preferences.
Implementing machine learning algorithms to analyse user input,
behavioural patterns, and sentiment analysis to identify individuals at risk of
incomplete alleviation of depression symptoms, attrition, or loss of follow-
up.
Implementing AI algorithms to continuously monitor user progress,
symptom severity, and treatment adherence. The system should be able to
detect deviations from the expected trajectory and provide timely
interventions or adjustments to the treatment plan.
Establishing mechanisms for gathering user feedback, monitoring system
performance, and iterating on the AI Chatbot platform to continually
improve its effectiveness in addressing the challenges of incomplete
alleviation of depression symptoms, attrition, and loss of follow-up in
mental health treatment.
11
1.3 SCOPE
Conducting thorough research and analysis to understand the underlying
causes of incomplete alleviation of depression symptoms, attrition, and loss
of follow-up in mental health treatment. This involves reviewing existing
literature, studying patient demographics, and identifying common barriers
to successful treatment outcomes.
Developing AI Chatbot systems equipped with natural language processing
(NLP) capabilities to facilitate seamless communication with users. This
involves designing intuitive user interfaces, implementing machine learning
algorithms for sentiment analysis and personalized recommendations, and
integrating with backend systems for data management.
Collecting relevant data from various sources, including user interactions
with the AI Chatbot, electronic health records (EHR), wearable devices, and
other health monitoring tools. Ensuring interoperability and seamless
integration of data from disparate sources to provide a comprehensive view
of the user's mental health status and treatment history.
Designing and training machine learning algorithms to analyse user data,
predict treatment outcomes, detect early warning signs of relapse or attrition,
and personalize interventions. This involves selecting appropriate machine
learning models, preprocessing and feature engineering, model training,
validation, and optimization.
Conducting rigorous clinical validation studies to assess the effectiveness of
the AI Chatbot platform in improving treatment outcomes, reducing attrition
rates, and enhancing patient engagement. This involves collaborating with
mental health professionals, conducting randomized controlled trials
(RCTs), and collecting qualitative and quantitative feedback from users.
Prioritizing user-centred design principles to create engaging and interactive
experiences within the AI Chatbot platform. This includes designing
personalized interventions, providing real-time feedback and support, and
12
incorporating gamification elements to encourage continued engagement
and adherence to treatment plans.
Ensuring compliance with relevant regulations, such as HIPAA, GDPR
(General Data Protection Regulation), and ethical guidelines for the
responsible use of AI in healthcare. Implementing robust data privacy and
security measures to protect sensitive health information and maintain user
trust.
Planning for scalability and deployment of the AI Chatbot platform to reach
a wide audience of users across different geographical regions and
demographic groups. This involves designing scalable infrastructure,
optimizing performance for high concurrency, and addressing potential
challenges related to cultural and linguistic diversity.
13
CHAPTER 2
SYSTEM ANALYSIS
14
4. Digital Therapeutics:
1. Limited Accessibility:
15
can prevent individuals from receiving timely and adequate support.
4. Resource Constraint:
The use of digital platforms for mental health support raises concerns
about data privacy, confidentiality, and security. Users may be hesitant to
disclose sensitive information or engage in therapeutic activities online due
to fears of data breaches, unauthorized access, or misuse of personal
information.
16
2.3 PROPOSED SYSTEM
Key Features:
18
CHAPTER 3
CHATBOTS
3.1 CHATBOT
Base-line chatbot:
AI chatbot:
Hybrid Model:
19
3.3 HOW DO CHATBOTS WORK
a. Text chatbot analyses the inputted text and matches the text with
predefined data called intents which are categorized to manage the
conversation. The user utterance is tagged with one of these intents, even if
what the user says stretches over two or more intents. Most chatbots will
take the intent with the highest score and take the conversation down that
avenue.
From Scratch
Using platforms
21
Rasa: is an open source chatbot that is equipped with a natural
language processing tool. The open source tool is called Rasa NLU. You
can tweak and customize the machine learning algorithm that Rasa uses so
that you can create a model that provides the results you desire.
Rasa NLU can be run wherever you want it to, and none of your
training data has to be passed over to Google, Microsoft, Amazon, or
Facebook to train your chatbot.
But as we know, nothing is perfect and rasa has its disadvantages like:
22
CHAPTER 4
23
2. AI Chatbot Interface:
24
6. Accessibility and Multilingual Support:
Ensure the accessibility of the system for users with disabilities, including
support for screen readers and alternative input methods.
1. Performance:
The system should respond promptly to user queries and interactions, with
minimal latency.
2. Scalability:
3. Reliability:
Measures should be in place to ensure data integrity and prevent data loss
or corruption.
25
4. Security:
The system should have an intuitive user interface that is easy to navigate
and understand.
6. Compatibility:
7. Maintainability:
8. Ethical Considerations:
The system should adhere to ethical guidelines for the responsible use of AI
26
in healthcare, including transparency, fairness, and accountability.Bias
mitigation techniques should be implemented to ensure equitable treatment
across diverse user populations.
27
4.3 SYSTEM REQUIREMENTS
Keras(2.12.0)
LSTM(0.8.0)
Pandas(1.5.2)
Numpy(3.11.2)
Matplotlib(3.7.1)
28
4.4 SOFTWARE DESRIPTION
Python:
• Python is Interactive - One can actually sit at a Python prompt and interact
with the interpreter directly to write programs.
Python is available from its website, python.org. Once there, hover the
mouse over the Downloads menu, then over the Windows option, and then
click the button to download the latest release. Alternatively, click the
Downloads menu button and select a specific version from the downloads.
Install Python:
30
where to find Python (which they require in order to run). This is not
selected by default, so activate it at the bottom of the install windows.
NUMPY:
KERAS:
Keras is used to define the layers of the neural network model, including
input, hidden, and output layers. It provides a wide range of layer types,
such as dense, convolutional, recurrent, and embedding layers, allowing
for flexible model architectures.
It supports feature extraction and transformation through its various layer
types. It enables the extraction of meaningful features from input data,
which are essential for learning representations of mental health-related
concepts and patterns.
PANDAS:
The Pandas is employed to load the dataset containing mental health-
related questions and answers from a CSV file (mentalhealth.csv). It
enables efficient loading, manipulation, and exploration of tabular data,
ensuring easy access to the dataset for preprocessing and analysis.
31
missing values, and formatting data to prepare it for model training,
ensuring the quality and consistency of input data for the chatbot model.
TENSORFLOW.KERAS:
NLTK provides powerful tokenization tools that can split text into
individual words or sentences, a fundamental preprocessing step in natural
language processing tasks. It enables the chatbot to parse user input and
understand the structure of queries and responses.
NLTK offers built-in stop-word lists for various languages, allowing for
the removal of common words like "the", "is", and "and" that do not carry
significant meaning. This preprocessing step reduces noise in the text data
and improves the relevance of generated responses.
NLTK includes algorithms for part-of-speech tagging, which assigns
grammatical categories (e.g., noun, verb, adjective) to words in a sentence.
POS tagging helps the chatbot understand the syntactic structure of
sentences and generate grammatically correct responses.
NLTK supports stemming and lemmatization, two techniques for reducing
words to their base forms (e.g., "running" to "run" or "better" to "good").
32
CHAPTER 5
5.1MODEL DESCRIPTION
● Design an intuitive and user-friendly interface for interacting with the chatbot,
incorporating features such as text input, buttons, menus, and multimedia
content.
● Develop NLP algorithms to analyse user input, extract meaning, and generate
appropriate responses using techniques such as tokenization, named entity
recognition, and sentiment analysis.
KNOWLEDGE BASE:
33
USER MANAGEMENT:
● Set up secure databases and data storage systems to store user data,
conversation history, and analytics, ensuring compliance with data privacy
regulations and best practices.
● Integrate the chatbot with external APIs and services, such as crisis hotlines,
therapy directories, and mental health assessment tools, to enhance its
capabilities and provide additional support to users.
34
CHAPTER 6
SYSTEM DESIGN
USECASE DIAGRAM:
35
SEQUENCE DIAGRAM:
36
ACTIVITY DIAGRAM :
37
DATAFLOW DIAGRAM:
38
CHAPTER 7
PROJECT DESCRIPTION
39
7.1 ADVANTAGES:
1. Accessibility:
2. Scalability:
3. Personalization:
40
judgement or
41
stigma, fostering a safe and supportive environment for discussing their mental
health concerns.
5. Immediate Support:
6. Continuity of Care:
7. Reduced Stigma:
7.2 DISADVANTAGES:
43
2. Limited Understanding and Response:
Despite advances in natural language processing, AI chatbots may
struggle to fully understand the complexities of human emotions, nuances of
language, and context-specific issues. This can lead to misinterpretation of
user input and inappropriate or ineffective responses, potentially exacerbating
feelings of frustration or distress.
44
CHAPTER 8
SYSTEM TESTING
System testing is a crucial phase in the software development lifecycle
aimed at verifying that the entire system meets the specified requirements
and functions correctly as a cohesive whole. It involves testing the
integrated components, modules, and interactions to ensure that the system
behaves as expected and fulfills its intended purpose. For the given problem
statement of developing an AI Chatbot and machine learning-based mental
health support system, system testing involves various types of testing,
including unit testing and integrity testing.
This project has undergone the following testing procedures to
ensure its correctness
Unit testing
Integrity testing
2. Writing test cases to validate the behavior of each module under different
scenarios and edge cases.
3. Mocking dependencies and external services to isolate the unit being tested.
4. Performing tests for boundary conditions, error handling, and edge cases
to ensure robustness.
45
5. Automating unit tests using testing frameworks and tools to streamline
the testing process and ensure consistency.
46
CHAPTER 9
CONCLUSION AND FUTURE ENHANCEMENT
9.1 CONCLUSION:
47
9.2 FUTURE ENHANCEMENT:
49
CHAPTER 10
APPENDIX
10.1 SOURCE CODE:
Generative_based.ipynb:
Loading Data & Preliminary Analysis
%pip install -r 'requirements.txt'
import nltk
path_to_csv = 'mentalhealth.csv'
import re
import random
import pandas as pd
import numpy as np
from tensorflow.keras.utils import plot_model
from keras.models import load_model
import matplotlib.pyplot as plt
pd.set_option('mode.chained_assignment', None)
data=pd.read_csv(path_to_csv, nrows=20)
Data Preprocessing
for i in range(data.shape[0]): data['Answers']
[i]=re.sub(r'\n', ' ',data['Answers'][i])
data['Answers'][i]=re.sub('\(', '',data['Answers'][i])
data['Answers'][i]=re.sub(r'\)', '',data['Answers'][i])
data['Answers'][i]=re.sub(r',', '',data['Answers'][i])
data['Answers'][i]=re.sub(r'-', '',data['Answers'][i])
data['Answers'][i]=re.sub(r'/', '',data['Answers'][i])
data['Answers'][i]=re.sub(r'/', '',data['Answers'][i])
50
input_features_dict = dict([(token, i) for i, token
enumerate(input_tokens)])
target_features_dict = dict([(token, i) for i, token in
enumerate(target_tokens)])
reverse_target_features_dict = dict((i, token) for token, i in
target_features_dict.items())
input_features_dict
51
encoder_inout_data
decoder_Target_data
Training
from tensorflow import keras
from keras.layers import Input, LSTM, Dense
from keras.models import Model
dimensionality = 256 # Dimensionality
batch_size = 10 # The batch size and number of
epochs epochs = 500
latent_dim = 256
decoder_state_input_hidden = Input(shape=(latent_dim,))
decoder_state_input_cell = Input(shape=(latent_dim,))
decoder_states_inputs = [decoder_state_input_hidden,
decoder_state_input_cell]
52
decoder_states = [state_hidden, state_cell]
decoder_outputs = decoder_dense(decoder_outputs)
training_model = load_model('training_model.h5')
encoder_inputs = training_model.input[0]
encoder_outputs, state_h_enc, state_c_enc =
training_model.layers[2].output
encoder_states = [state_h_enc, state_c_enc]
encoder_model = Model(encoder_inputs, encoder_states)
53
10.2 OUTPUT
Figure 10.2.1
Figure 10.2.2
54
Figure 10.2.3
Figure 10.2.4
55
Figure 10.2.5
56
REFERENCES
WEBSITE LINK
1. https://rasa.com/docs/rasa/domain/
2. https://towardsdatascience.com/create-chatbot-using-
rasa-part-1-67f68e89ddad
3. https://ieeexplore.ieee.org/document/9197833
4. The Book Of Chatbots from Eliza to Chatgpt By Robert
Ciesla, University Of Helsinki, Finland.
57