Authors: Farhanah Shah, Ravinder Pal Singh, Dr Satish
Certificate: View Certificate
Mental health issues that influence your emotions, thinking, and behaviour are referred to as mental illnesses, often known as mental health disorders. Depression, anxiety disorders, schizophrenia, eating disorders, and addictive behaviours are a few examples of mental illnesses. Many people occasionally experience issues with their mental health. Yet when persistent symptoms create regular worry and impair your capacity to perform, a mental health problem turns into a mental disorder. Mental health care is crucial in today\'s increasingly technological world, and neglecting such issues might have serious consequences. Thus, in order to address this issue, we are going to develop a Psychological healthcare system that is a functional retrieval based conversational artificial intelligence system that will analyze user’s psychological behaviour and provide the necessary advice for addressing these issues. The Conversational AI agent allows the User to ask any personal question about mental healthcare without having to visit the hospital in person. When a question is delivered to the Conversational AI agent, it receives a relevant response and displays it. The agent uses Natural language processing to transform the questions.
The major goal of this research is to narrow the communication gap between users and mental healthcare professionals by providing prompt responses to user questions. Internet addiction is more common nowadays, but people are less inclined to worry about their own health. They avoid going to the hospital for minor issues that might develop into serious mental conditions in the future.
Artificial intelligence provides computers the utmost ability to emulate human thought and behaviour. Conversational AI is an interdisciplinary field that combines techniques from computer science, linguistics, psychology, and other disciplines to create intelligent systems that can engage in natural, human-like conversations with users. These systems are designed to understand human language and respond in a way that is contextually relevant, informative, and engaging. To achieve this, the systems use a range of techniques, including natural language processing (NLP), machine learning (ML), and deep learning (DL). NLP allows the system to analyze and understand the structure and meaning of natural language input, while ML and DL techniques enable the system to learn from user interactions and improve over time.
Conversational AI has many practical applications, including virtual assistants like Siri, Google Assistant, and Alexa, which can answer questions, provide information, and perform tasks on behalf of the user. Chatbots are another popular application of conversational AI, used by businesses to automate customer service interactions and improve response times. It has the potential to revolutionize psychological condition analysis by providing a more efficient, objective, and personalized approach to diagnosis and treatment. By leveraging natural language processing and machine learning techniques, conversational AI systems can analyze language patterns and other behavioural cues to detect and diagnose various psychological conditions, such as depression, anxiety, and post-traumatic stress disorder (PTSD). One of the key advantages of conversational AI in psychological condition analysis is its ability to provide personalized and adaptive interventions. Conversational AI systems can monitor a patient's progress and adjust their interventions accordingly, providing targeted support and feedback based on the patient's unique needs and circumstances. These systems can also provide a more efficient and cost-effective approach to psychological condition analysis, particularly in areas where access to trained professionals is limited. For example, tele therapy using conversational AI can provide access to mental health services for individuals who live in remote or underserved areas.
However, there are also challenges associated with using conversational AI in psychological condition analysis, including the need to ensure patient privacy and the risk of biases in the data and algorithms used by the systems. Therefore, it is important to approach the use of conversational AI in psychological condition analysis with caution and carefully evaluate the benefits and risks before implementing such systems in clinical settings.
Computer programmes known as chatbots engage with users in natural language. The goal of this technology, which first emerged in the 1960s, was to determine whether chatbot systems could deceive users into thinking they were dealing with actual people. But, chatbot systems are not just created to amuse users and replicate human dialogue. Because chatbots primarily rely on artificial intelligence, we have chosen to contribute to health informatics utilising this technology. Computer programmes known as chatbots engage with users in natural language. Nowadays, chatbots are a component of virtual assistants like Google Assistant and may be accessible through the applications, websites, and instant messaging platforms of many different companies. Because chatbots primarily rely on artificial intelligence, we have chosen to contribute to mental health informatics utilising this technology.
Using natural language processing, this technology enables computer-to-computer communication (NLP). A chatbot is an entity that mimics human conversation in its specific acceptable setting while using text or voice and methods like natural language processing (NLP). This method aims to mimic a person's conversation. The creation of a user interface for sending input and receiving responses may be used to construct chatbot applications.
II. LITERATURE REVIEW
The chatbot will function as a virtual doctor, allowing patients to communicate with him or her. An algorithm for pattern matching and natural language processing was utilized to create this chatbot. Python is used in its development.  The Chatbot will take on the role of a virtual doctor and allow patients to communicate with the doctor virtually. Our method just analyses natural language in order to extract symptoms, which can make it simpler for senior, less technical people to communicate.  Users can pose a question thanks to the Natural Language Processing. In order to provide a response, the machine analyses the user's input for key components that might be related to certain attributes in a data collection. The goal of NLP is to identify the text's meaning. The text file containing the symptoms associated with a certain disease, on the basis of which we may anticipate the condition, is included in the saved data. Artificial intelligence is used in the paper to forecast the condition based on the symptoms and provide a list of potential therapies. It can aid in both issue identification and solution validation.  Pattern matching approach is used in the majority of chatbots, and it is sometimes referred to as a reply architecture that relies on coordinating types. By employing the logical operators AND, OR, and NOT, one may design patterns on their own. 
Table 1 Literature survey of Chatbots and NLPs used in various applications
Journal/ Conference Name/Year of publication
A Novel Approach for
Medical Assistance Using
Divya Madhu, Neeraj Jain C.
J , Elmy Sebastain , Shinoy
Shaji , Anandhu Ajayakumar
The suggested solution is to build an artificially intelligent system that can fulfil the requirements. Based on symptoms, artificial intelligence (AI) can forecast illnesses and provide a list of potential therapies.
A Self-Diagnosis Medical
Chatbot Using Artificial
Divya S , Indumathi V ,
Ishwarya S , Priyasankari M , Kalpana Devi S
Published in 2018 Volume 3
Issue 1 By MAT journals
The medical chatbot is created to lower healthcare expenditures and provide access to medical knowledge. A chatbot can only truly serve the user when it can identify all diseases and deliver the appropriate information.
Design and Development of
Diagnostic Chabot for
supporting Primary Health Care Systems.
Nadesh RK, Bushra Kidwai
Elsevier 2020 volume 167
Today's healthcare environment is increasingly reliant on technology.
Technology has altered how people engage with doctors and, in addition, how healthcare is delivered.
III. PROPOSED SYSTEM
The proposed system is the deep neural network based conversational AI agent implemented in Keras, which is a deep learning library in python. It is a keras functional API retrieval-based system that is focused on psychological medical analysis. Conversational agents that rely on retrieval operate on the theory of directed flows or graphs. In essence, these agents are taught to select the best response from a limited pool of prepared responses. The replies are either manually inputted or drawn from a knowledge base of previously collected data. The system has been trained such that it will recognize a collection of questions that may often occur in a conversation with psychologically abled user. The responses will help in analyzing the user’s psychological state. For this implementation, we have chosen domain for psychological medical conditions.
This paper focuses on the idea to develop a functional retrieval based deep learning conversational AI agent that will help in analyzing the users psychological conditions and in the long term help users in overcoming these issues.
A. Conversational AI Agent Basic Architecture
There are two separate processes in conversational AI logical architecture:
1. Building process
a. The building process starts with training data, which is the input training data set from which patterns in conversation are analyzed .Based on this learning, it extracts the features, intents, and various tags; once those features and tags are extracted. The learning is a DNN (deep neural network) based process. After initializing a DNN-based functional neural network, various concepts are tokenized and lemmatized, and after 200 learning epochs, the conversational memory is saved.
b. The deployment stage: once the model is saved, the second stage is deployment stage, which is the model's run state. In such situation, when the user enters the input on interface then this user’s input on the interface is transferred for processing, and this response is now provided by DNN. Fig 2 explains the architecture of the agent in detail.
B. Conversational AI Agent Design process
The design process consists of seven steps: scope and requirement, input identification, UI element comprehension, first interaction creation, conversation construction, and testing. The conversational AI Agent design process can be demonstrated in Fig 2.
Understanding the scope, requirements, platform to launch conversational AI agent, and its restrictions is the first stage in building Conversational AI. Finding user inputs from devices and intelligence systems in the form of text queries is the second stage. The third phase entails comprehending the User Interface (UI) components that can be found in our apps. There are five different types of user interface (UI) elements: Command Line (CL), Graphical User Interface (GUI), Menu-Driven Interface (MDI), Form-Based Interface (FBI), and Natural Language Interface (NLI). The next stage is to design the initial interaction and start a discussion after understanding user interface aspects.
Testing is the last step in the design process, and it's done on the interfaces and models to check the functionality and performance of the system.
As stated above that our main goal is to create a deep learning conversational AI agent that accepts input as a series of inquiries made by the user with different identities, gives the most correct answers, and guides the dialogue in a more meaningful way. The model used in this agent is constructed using a functional API of Keras instead of sequential API. As sequential API allows you to build models layer by layer. It has limitations in that it does not allow you to design models with several layers of inputs and outputs.
The system is developed in Python using the tools like NLTK, Tkinter. The model is developed using Keras functional API. The model is trained against the sample JSON dataset created based on the interactions with the people and researching the internet. This JSON file contains the data in the form of:
There are seven main steps to create a conversational AI agent in python:
a. Import And Load The Data File— we import the required packages for our agent and set the variables we'll be using. We have used the json loads module to load the input JSON data.
b. Preprocessing The Data— the data needs to be pre-processed before being able to use deep learning model. The data preprocessing can be explained using Fig 3. We need to preprocess the data using a variety of processes depending on the needs. The simplest and initial action you can do with text data is to tokenize it. The method of tokenizing involves dividing the entire text into smaller units, such as words. Using the nltk.word tokenize() method, we tokenize the phrase in this case and attach each word from the words list after iterating over the patterns. For our tags, we also make a list of classes. We will now lemmatize each word and eliminate any repetitions from the list. A word is lemmatized by being changed into its lemma form, and then a pickle file is made to house the Python objects that will be used for prediction.
c. Create Training Data— the training data will now be created, with input and output being provided. Patterns will be our input, and the class to which those patterns belong will be our output. We will translate text into numbers because the machine cannot read text.
d. Building the Model— Now that we have our training data prepared, we will construct a three-layer deep neural network. For this, we employ the Keras functional API. The model was trained for 200 epochs, and after that, we had 100% accuracy.
e. Saving the Model— after the model is built, we save the model and export the generated dictionaries to be able to use in predicting the response of the user.
f. Predicting the Response— In order to forecast the agent's reaction, we will first load the trained model and then use a graphical user interface. The model will only reveal the class to which an answer belongs, therefore we will develop some functions that will determine the class and then obtain a random response from the list of replies. The dictionary files that we produced when we trained our model are loaded together with the relevant packages. In order to anticipate the class, we will develop several functions that conduct text preparation. The response we receive from the list of intentions will be at random once we have predicted the class.
g. Sending the Response to GUI— the next phase is sending the response to the graphical user interface. The user interface development for this agent was done using Tkinter (version 3.11.1), a library that comes with a ton of helpful GUI libraries. After sending the request to the model and receiving the predicted response, we will utilize the helper methods to obtain the bot's reply and show it on the GUI.
The performance of the developed conversational AI agent is defined based on two factors, accuracy and loss. Overall accuracy is the number of correct predictions vs. the total number of predictions. Loss is defined as the percentage of prediction error in the neural network model.
The proposed system works at 99.5% accuracy after training for 200 epochs. The accuracy is consistent till the last iteration while suffering a minimum loss of 0.0526%.
The results obtained from the proposed system are shown Fig 4, Fig 5 and Fig 6.
VI. FUTURE SCOPE
The future potential of conversational AI agent is quite large as consumers spend more time using messaging apps than any other applications. Some of the other potential areas for the proposed system are—
Conversation AI is one of the areas of artificial intelligence study that is expanding. Every field may use the conversational engine to provide the necessary client assistance. It is frequently used in the business world for customer assistance, the medical industry for scheduling doctor appointments, educational websites for inquiries regarding institutional details, etc. The suggested system is a retrieval-based conversational agent that utilises a deep learning idea for model-building process. The system operates best in a closed domain since it is retrieval-based. In this case, we created a dataset of Psychological medical condition, and the algorithm performs well in that field. The proposed system operates at 98.89% accuracy. Here, the system will produce the appropriate response for each inquiry a user submits that falls inside it’s domain and will help in analysing the user’s psychological conditions and in the long term help users in overcoming these issues. For the system to operate more effectively and to enable the system respond to the majority of the user\'s repetitive inquiries, manual dataset updates must be performed on a frequent basis. Moreover, special elements are included in the model to improve the system\'s usability.
 S. M. Metev and V. P. Veiko, Laser Assisted Microtechnology, 2nd ed., R. M. Osgood, Jr., Ed. Berlin, Germany: Springer-Verlag, 1998.  Survey on Medical Self-Diagnosis Chatbot for Accurate Analysis Using Artificial Intelligence.International, Journal of Trend in Research and Development, Volume 5(2), ISSN: 2394-9333 www.ijtrd.com  Mobile Based Healthcare Management using Artificial Intelligence. International Journal of Innovative Research in Computer and Communication Engineering (An ISO 3297: 2007 Certified Organization) Vol. 4, Issue 3, March 2016  A Self-Diagnosis Medical Chatbot Using Artificial Intelligence, Journal of Web Development and Web Designing Volume 3 Issue 1.  A Medical Chat Bot, International Journal of Computer Trends and Technology (IJCTT) – Volume 60 Issue 1- June 2018.  Text-based Healthcare Catboats Supporting Patient and Health Professional Teams: Preliminary Results of a Randomized Controlled Trial on Childhood Obesity. See discussions, stats, and author profiles for this publication at:https://www.researchgate.net/publication/320161507  Using Artificial Intelligence to Improve Hospital Inpatient Care. Editor: Daniel B. Neill, H.J. Heinz III College, Carnegie Mellon University, firstname.lastname@example.org  A Self-Diagnosis Medical Chatbot Using Artificial Intelligence, Journal of Web Development and Web Designing Volume 3 Issue 1  A Medical Chat Bot, International Journal of Computer Trends and Technology (IJCTT) – Volume 60 Issue 1- June 2018  Text-based Healthcare Catboats Supporting Patient and Health Professional Teams: Preliminary Results of a Randomized Controlled Trial on Childhood Obesity. See discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/320161507  Chatboats meet e Health: automatizing healthcare, DIETI - University of Naples Federico II, via Claudio 21, 80125 Napoli (Italy)  Pharmabot: A Pediatric Generic Medicine Consultant Chatbot, Journal of Automation and Control Engineering Vol. 3, No. 2, April 2015  Beyond Patient Monitoring: Conversational Agents Role in Telemedicine & Healthcare Support For Home-Living Elderly Individuals, Ahmed Fadhil University of Trento Trento, Italy  Aqua bot: A Diagnostic Chatbot for Achluophobia and Autism . (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 8, No. 9, 2017
Copyright © 2023 Farhanah Shah, Ravinder Pal Singh, Dr Satish. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.