AI Based Chatbot for
Providing Health
Related Information
Agenda
• Introduction about chatbot
• Objective
• Component of the chatbot
• Flow of data in this application
• Tools and technology
• Code snippet and output
• Flask, chatterbot, spacy
• Applications
• Conclusion
Introduction
• Chatbot providing health related information of problem given by user as a
patient.
• Chatbot providing information related to disease based on the symptoms given.
• Chatbot providing diagnosis for the symptoms.
• It will also provide the details of the doctor specialized in the treatment of said
medical issue.
• Chat bot are available 24 X 7, can be an effective first aid guiding tool.
Objective
• The idea is to create a medical chatbot that can diagnose the disease and provide
basic details about the disease before consulting a doctor.
• This will help to reduce healthcare costs and improve accessibility to medical
knowledge through medical chatbot.
• The Project focuses on providing the users immediate and approximately accurate
prediction of the diseases based on their symptoms.
• The bot will get experienced by getting trained by the given information priorly.
Components of the Chatbot
• GUI (Frontend)
- HTML , CSS & jQuery with Flask as framework
• Training Data (Backend)
- spaCy library of python
• Chatbot 0.8.4 (Middleware for communication).
- chatterbot library of python
Design Flow
System Flow
Tools and Technologies
Tools
• Python Language 3.7.0
• Flask 2.2.2
• VS code editor
Libraries
• Chatterbot 0.8.4
• spaCy 2.1.9
• SQLite
Code snippet
Run.py
.
from flask import Flask, render_template, request
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
import os
import spacy.cli
spacy.cli.download("en_core_web_md")
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
filenumber=int(os.listdir('saved_conversations')[-1])
filenumber=filenumber+1
file= open('saved_conversations/'+str(filenumber),"w+")
file.write('bot : Hi There! I am a medical chatbot. You can begin conversation by
typing in a message and pressing enter.n')
file.close()
app = Flask(__name__)
english_bot = ChatBot('Bot',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch'
},
],
trainer='chatterbot.trainers.ListTrainer')
english_bot.set_trainer(ListTrainer)
@app.route("/")
def home():
return render_template("index.html")
@app.route("/get")
def get_bot_response():
userText = request.args.get('msg')
response = str(english_bot.get_response(userText))
appendfile=os.listdir('saved_conversations')[-1]
appendfile= open('saved_conversations/'+str(filenumber),"a")
appendfile.write('user : '+userText+'n')
appendfile.write('bot : '+response+'n')
appendfile.close()
return response
if __name__ == "__main__":
app.run()
Code snippet and Output
Training.py
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import os
try:
os.remove("db.sqlite3")
print("Old database removed. Training new database")
except:
print('No database found. Creating new database.')
finally:
print("exit")
eng_med_bot = ChatBot('Bot')
eng_med_bot.set_trainer(ListTrainer)
for file in os.listdir('data'):
print('Training using '+file)
convData = open('data/' + file).readlines()
eng_med_bot.train(convData)
print("Training completed for "+file)
•
Flask
What is flask ?
• It is a small and lightweight web application framework.
• Provides useful tools and features for making a web application
• It is a set of functions and predefined classes used to connect with the system software and handle inputs
and outputs.
• Flask is very much a "do it yourself" web framework. This means there's no built-in database interaction,
but the flask-sqlalchemy package will connect a SQL database to a Flask application.
chatterbot
What is chatterbot?
• ChatterBot is a Python library
• It makes it easy to generate automated responses to a user’s input.
• It uses a selection of machine learning algorithms to produce different types of responses.
• This makes it easy for developers to create chat bots and automate conversations with users.
• ChatterBot receives more input the number of responses that it can reply and the accuracy of each response in relation to the
input statement increase.
spaCy
What is spaCy?
• spaCy is a free and open-source library for Natural Language Processing (NLP)
• spaCy is a mature and batteries-included framework that comes with prebuilt models for
common NLP tasks like classification, named entity recognition, and part-of-speech tagging.
• spaCy is designed specifically for production use and helps you build applications that process
and “understand” large volumes of text.
• It can be used to build information extraction or natural language understanding systems, or to
pre-process text for deep learning.
Applications
• Easy and interactive GUI based
• Quick medical assistance
• Immediate and approximately accurate prediction of the diseases based on their
symptoms
• information related to disease based on the symptoms
• Getting better and trained with increase in number of conversation
• Providing primary medical help and also guide to doctor for consultancy.
• Available 24 X 7, making it a best guiding tool for first aid for any medical issue.
Conclusion
• The proposed system is an efficient, cheap, easy and a quick way to help patients to have a one-to-one
conversation with the Chatbot that helps and assists them to take care of their health effectively.
• Chatbots are the easy and interactive GUI’s which are simple and effective in nature while serving the purpose
of displaying the result.
• With the chat bot help of Chat bot users can post their symptoms and get the solutions from the bot. The
system can be accessed from anywhere and at any time conveniently. The chat bot is available 24/7.
• The medical chatbot provides medical help to the patients for a few general diseases like fever, cold, headache
etc. we tend to area unit inventing the system owing to the requirement for the increasing population of our
country.
• Chatbots can reach out to a large audience on messaging apps and be more effective than humans.
Thank You

AI CHATBOOT.pptx

  • 1.
    AI Based Chatbotfor Providing Health Related Information
  • 2.
    Agenda • Introduction aboutchatbot • Objective • Component of the chatbot • Flow of data in this application • Tools and technology • Code snippet and output • Flask, chatterbot, spacy • Applications • Conclusion
  • 3.
    Introduction • Chatbot providinghealth related information of problem given by user as a patient. • Chatbot providing information related to disease based on the symptoms given. • Chatbot providing diagnosis for the symptoms. • It will also provide the details of the doctor specialized in the treatment of said medical issue. • Chat bot are available 24 X 7, can be an effective first aid guiding tool.
  • 4.
    Objective • The ideais to create a medical chatbot that can diagnose the disease and provide basic details about the disease before consulting a doctor. • This will help to reduce healthcare costs and improve accessibility to medical knowledge through medical chatbot. • The Project focuses on providing the users immediate and approximately accurate prediction of the diseases based on their symptoms. • The bot will get experienced by getting trained by the given information priorly.
  • 5.
    Components of theChatbot • GUI (Frontend) - HTML , CSS & jQuery with Flask as framework • Training Data (Backend) - spaCy library of python • Chatbot 0.8.4 (Middleware for communication). - chatterbot library of python
  • 6.
  • 7.
    Tools and Technologies Tools •Python Language 3.7.0 • Flask 2.2.2 • VS code editor Libraries • Chatterbot 0.8.4 • spaCy 2.1.9 • SQLite
  • 8.
    Code snippet Run.py . from flaskimport Flask, render_template, request from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer import os import spacy.cli spacy.cli.download("en_core_web_md") from chatterbot import ChatBot from chatterbot.trainers import ListTrainer filenumber=int(os.listdir('saved_conversations')[-1]) filenumber=filenumber+1 file= open('saved_conversations/'+str(filenumber),"w+") file.write('bot : Hi There! I am a medical chatbot. You can begin conversation by typing in a message and pressing enter.n') file.close() app = Flask(__name__) english_bot = ChatBot('Bot', storage_adapter='chatterbot.storage.SQLStorageAdapter', logic_adapters=[ { 'import_path': 'chatterbot.logic.BestMatch' }, ], trainer='chatterbot.trainers.ListTrainer') english_bot.set_trainer(ListTrainer) @app.route("/") def home(): return render_template("index.html") @app.route("/get") def get_bot_response(): userText = request.args.get('msg') response = str(english_bot.get_response(userText)) appendfile=os.listdir('saved_conversations')[-1] appendfile= open('saved_conversations/'+str(filenumber),"a") appendfile.write('user : '+userText+'n') appendfile.write('bot : '+response+'n') appendfile.close() return response if __name__ == "__main__": app.run()
  • 9.
    Code snippet andOutput Training.py from chatterbot import ChatBot from chatterbot.trainers import ListTrainer import os try: os.remove("db.sqlite3") print("Old database removed. Training new database") except: print('No database found. Creating new database.') finally: print("exit") eng_med_bot = ChatBot('Bot') eng_med_bot.set_trainer(ListTrainer) for file in os.listdir('data'): print('Training using '+file) convData = open('data/' + file).readlines() eng_med_bot.train(convData) print("Training completed for "+file) •
  • 10.
    Flask What is flask? • It is a small and lightweight web application framework. • Provides useful tools and features for making a web application • It is a set of functions and predefined classes used to connect with the system software and handle inputs and outputs. • Flask is very much a "do it yourself" web framework. This means there's no built-in database interaction, but the flask-sqlalchemy package will connect a SQL database to a Flask application.
  • 11.
    chatterbot What is chatterbot? •ChatterBot is a Python library • It makes it easy to generate automated responses to a user’s input. • It uses a selection of machine learning algorithms to produce different types of responses. • This makes it easy for developers to create chat bots and automate conversations with users. • ChatterBot receives more input the number of responses that it can reply and the accuracy of each response in relation to the input statement increase.
  • 12.
    spaCy What is spaCy? •spaCy is a free and open-source library for Natural Language Processing (NLP) • spaCy is a mature and batteries-included framework that comes with prebuilt models for common NLP tasks like classification, named entity recognition, and part-of-speech tagging. • spaCy is designed specifically for production use and helps you build applications that process and “understand” large volumes of text. • It can be used to build information extraction or natural language understanding systems, or to pre-process text for deep learning.
  • 13.
    Applications • Easy andinteractive GUI based • Quick medical assistance • Immediate and approximately accurate prediction of the diseases based on their symptoms • information related to disease based on the symptoms • Getting better and trained with increase in number of conversation • Providing primary medical help and also guide to doctor for consultancy. • Available 24 X 7, making it a best guiding tool for first aid for any medical issue.
  • 14.
    Conclusion • The proposedsystem is an efficient, cheap, easy and a quick way to help patients to have a one-to-one conversation with the Chatbot that helps and assists them to take care of their health effectively. • Chatbots are the easy and interactive GUI’s which are simple and effective in nature while serving the purpose of displaying the result. • With the chat bot help of Chat bot users can post their symptoms and get the solutions from the bot. The system can be accessed from anywhere and at any time conveniently. The chat bot is available 24/7. • The medical chatbot provides medical help to the patients for a few general diseases like fever, cold, headache etc. we tend to area unit inventing the system owing to the requirement for the increasing population of our country. • Chatbots can reach out to a large audience on messaging apps and be more effective than humans.
  • 15.