0% found this document useful (0 votes)
17 views21 pages

Artificial Intelligence Project Sample Report

MediMate is an AI-powered healthcare chatbot designed to assist users in understanding symptoms, providing home remedies, diet advice, and preventive care guidance. The chatbot utilizes a Decision Tree Classifier trained on a dataset of over 500 medical conditions to deliver personalized responses and maintain user health history. It aims to enhance health awareness and promote self-care habits through an interactive and user-friendly interface.

Uploaded by

ankitasj009
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)
17 views21 pages

Artificial Intelligence Project Sample Report

MediMate is an AI-powered healthcare chatbot designed to assist users in understanding symptoms, providing home remedies, diet advice, and preventive care guidance. The chatbot utilizes a Decision Tree Classifier trained on a dataset of over 500 medical conditions to deliver personalized responses and maintain user health history. It aims to enhance health awareness and promote self-care habits through an interactive and user-friendly interface.

Uploaded by

ankitasj009
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
You are on page 1/ 21

Solanki Ankita J.

236140307130

Diploma Engineering

Micro Project
MediMate :AI - Powered Healthcare ChatBot
Fundamentals Of Artificial Intelligence
(4350705)

[Computer Engineering, Semester IV]

Enrolment No
Name
Branch
Academic Term
Institute

Directorate Of Technical Education


Gandhinagar – Gujarat

1
Solanki Ankita J. 236140307130

Project Title: MediMate — AI-Powered Health


Chatbot

1. Introduction
In the digital healthcare era, artificial intelligence (AI) has emerged as a powerful
tool to improve accessibility and awareness about health. MediMate is an AI-
powered virtual health assistant designed to help users quickly understand their
symptoms, receive home remedies, diet advice, preventive care guidance, and
know when to seek medical help.
Unlike typical chatbots, MediMate integrates a Machine Learning (ML) model
trained on a realistic dataset of 500+ medical conditions and symptoms,
providing personalized and data-driven responses.
It acts as a first-level health guide — not a doctor replacement — but a
supportive, informative tool for users to take better care of themselves.

2. Objectives
The main objectives of MediMate are:
1. To build an interactive and user-friendly AI chatbot for symptom-based
health assistance.
2. To utilize Machine Learning (Decision Tree Classifier) for predicting
possible health conditions.
3. To provide contextual responses such as:
o Home remedies
o Diet tips
o Prevention and doctor advice
4. To maintain user health history for future reference.
5. To raise health awareness and promote self-care habits using technology.

2
Solanki Ankita J. 236140307130

3. Methodology
MediMate’s functioning can be divided into the following stages:
1. Dataset Preparation
o A dataset of 500+ realistic medical entries containing symptoms,
conditions, home remedies, diet tips, and preventive advice is used.
o Each record maps symptom patterns to a particular condition.
2. Machine Learning Model
o Model used: Decision Tree Classifier
o Text data is vectorized using TF-IDF (Term Frequency–Inverse
Document Frequency) to convert symptoms into numeric features.
o The model is trained to predict the most likely condition based on
symptoms entered by the user.
3. System Workflow
o User interacts via chat interface (Streamlit UI).
o Chatbot sequentially asks for Name, Age, Duration, Symptoms,
Severity, etc.
o ML model predicts condition → displays advice, remedies, diet tips,
prevention, and doctor guidance.
o User feedback and conversation details are stored in user_data.csv.
4. Evaluation Metrics
o Model Accuracy: ≈ {ml_accuracy * 100:.2f}%
o Performance visualized using a Confusion Matrix (Seaborn
heatmap).

3
Solanki Ankita J. 236140307130

4. Technologies Used
Category Tools / Libraries

Programming
Python
Language

Framework Streamlit

Machine Learning scikit-learn (DecisionTreeClassifier, TF-IDF)

Data Handling pandas, numpy

Visualization seaborn, matplotlib

CSV-based logging (user_data.csv,


Storage
medi_dataset_500_realistic.csv)

5. Features and Functionalities


• AI-based conversation flow
• Symptom-to-condition prediction
• Home remedies and diet tips
• Preventive and wellness guidance
• When-to-see-a-doctor advice
• User history tracking and feedback saving
• Model accuracy and confusion matrix visualization

6. System Architecture
Input → TF-IDF Vectorization → Decision Tree Model → Predicted Condition →
Advice Generation → User Response
[User Symptoms]

4
Solanki Ankita J. 236140307130


[TF-IDF Vectorizer]

[Decision Tree Classifier]

[Predicted Condition]

[Display Remedies, Diet, Prevention, Doctor Advice]

7. Working Project Overview


Code:
import streamlit as st
import pandas as pd
import random
from datetime import datetime
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, confusion_matrix
import seaborn as sns
import matplotlib.pyplot as plt

# ------------------- Load Dataset -------------------


dataset_file = "medi_dataset_500_realistic.csv"
df_dataset = pd.read_csv(dataset_file)

# ------------------- Train ML Model -------------------


X = df_dataset["Symptoms"]
y = df_dataset["Condition"]

vectorizer = TfidfVectorizer()
X_vec = vectorizer.fit_transform(X)

clf = DecisionTreeClassifier()
clf.fit(X_vec, y)

5
Solanki Ankita J. 236140307130

# ------------------- Evaluate ML Model -------------------


X_train, X_test, y_train, y_test = train_test_split(X_vec, y, test_size=0.2, random_state=42)
clf.fit(X_train, y_train)
y_pred = clf.predict(X_test)

ml_accuracy = accuracy_score(y_test, y_pred)


ml_confusion_matrix = confusion_matrix(y_test, y_pred)

# ------------------- Initialize Session State -------------------


if "chat_history" not in st.session_state:
st.session_state.chat_history = []

if "user_info" not in st.session_state:


st.session_state.user_info = {}

if "dataset" not in st.session_state:


st.session_state.dataset = df_dataset

# ------------------- Helper Functions -------------------


def find_condition(symptoms_input):
"""Predict condition using ML model and return dataset row"""
vec = vectorizer.transform([symptoms_input])
predicted_condition = clf.predict(vec)[0]

# Get first matching row for that condition


match = st.session_state.dataset[st.session_state.dataset["Condition"] ==
predicted_condition].iloc[0]
return match

def append_user_data(user_data):
"""Append user data to CSV"""
try:
user_df = pd.read_csv("user_data.csv")
user_df = pd.concat([user_df, pd.DataFrame([user_data])], ignore_index=True)
except FileNotFoundError:
user_df = pd.DataFrame([user_data])
user_df.to_csv("user_data.csv", index=False)

# ------------------- Sidebar -------------------


# Sidebar styling
st.sidebar.markdown("""
<div style='
background: linear-gradient(135deg, #2C3E50, #4CA1AF);
padding: 10px 15px;

6
Solanki Ankita J. 236140307130

border-radius: 15px;
box-shadow: 0 2px 6px rgba(0,0,0,0.3);
text-align: center;
width: fit-content;
'>
<h4 style='color: #F7F7F7; font-family: "Segoe UI", sans-serif; margin: 0;'>🌿
MediMate</h4>
</div>
""", unsafe_allow_html=True)

# Navigation with styled labels


page = st.sidebar.radio("Navigate", ["Chatbot", "User History", "About Project"])

# ------------------- About Project -------------------


if page == "About Project":
st.title("🌿 About MediMate")

st.markdown("""
<div style='background-color: #1E1E1E; padding: 20px; border-radius: 15px; color:
#E0E0E0;'>
<h3 style='color:#4CAF50;'>✨ Welcome to MediMate!</h3>
<p>
**MediMate** is your friendly AI-powered health assistant designed to provide quick,
accurate, and personalized guidance for your health and wellness. It helps you understand
your symptoms, suggests home remedies, diet tips, preventive measures, and guides you on
when to consult a doctor.
</p>

<h4 style='color:#81C784;'>🩺 Features:</h4>


<ul>
<li>🔹 Symptom analysis & condition prediction</li>
<li>🔹 Home remedies for common ailments</li>
<li>🔹 Personalized diet tips</li>
<li>🔹 Prevention & wellness guidance</li>
<li>🔹 When to see a doctor advice</li>
<li>🔹 Interactive and conversational AI experience</li>
</ul>

<h4 style='color:#81C784;'>🛠 Technologies Used:</h4>


<ul>
<li>Python </li>

7
Solanki Ankita J. 236140307130

<li>Streamlit </li>
<li>pandas & numpy </li>
<li>Basic ML for condition prediction </li>
</ul>

<h4 style='color:#81C784;'>📂 Dataset:</h4>


<p>
MediMate uses a realistic dataset with <b>500+ health entries</b> covering common
conditions like:
Cold, Flu, Migraine, Indigestion, Food Poisoning, Respiratory Infection, Stress, and more.
Each entry includes:
<ul>
<li>Symptoms</li>
<li>Severity</li>
<li>General advice</li>
<li>Home remedies</li>
<li>Diet tips</li>
<li>Prevention tips</li>
<li>Doctor guidance</li>
</ul>
</p>

<h4 style='color:#81C784;'>💡 Why MediMate?</h4>


<p>
MediMate empowers you to take quick action for common health issues, reduce
unnecessary anxiety, and make informed decisions about your wellbeing. It's like having a
<b>health assistant in your pocket</b>! 🌟
</p>
</div>
""", unsafe_allow_html=True)
# ---------- Styled ML Metrics ----------
st.markdown("<hr style='border:1px solid #4CAF50'>", unsafe_allow_html=True)
st.markdown("<h3 style='color:#4CAF50;'>📊 ML Model Metrics</h3>",
unsafe_allow_html=True)

# Accuracy card
st.markdown(f"""
<div style='
background: linear-gradient(135deg, #81C784, #66BB6A);
padding: 15px 20px;
border-radius: 15px;
color: white;
font-weight: bold;

8
Solanki Ankita J. 236140307130

font-size: 18px;
text-align: center;
box-shadow: 2px 2px 12px rgba(0,0,0,0.3);
'>
Accuracy: {ml_accuracy * 100:.2f}%
</div>
""", unsafe_allow_html=True)

st.markdown("<br>", unsafe_allow_html=True)

# Confusion matrix in a card


st.markdown("<h4 style='color:#66BB6A;'>Confusion Matrix</h4>",
unsafe_allow_html=True)
fig, ax = plt.subplots(figsize=(5, 4))
sns.heatmap(ml_confusion_matrix, annot=True, fmt='d', cmap='YlGnBu', ax=ax,
cbar=True)
ax.set_xlabel("Predicted", fontsize=12)
ax.set_ylabel("Actual", fontsize=12)
st.pyplot(fig)

st.markdown("<br>", unsafe_allow_html=True)

# Model info card


st.markdown(f"""
<div style='
background: linear-gradient(135deg, #4CAF50, #388E3C);
padding: 15px 20px;
border-radius: 15px;
color: white;
font-weight: bold;
font-size: 16px;
text-align: left;
box-shadow: 2px 2px 12px rgba(0,0,0,0.3);
'>
Model: Decision Tree Classifier<br>
Vectorizer: TF-IDF with {len(vectorizer.get_feature_names_out())} features
</div>
""", unsafe_allow_html=True)

# ------------------- User History -------------------


elif page == "User History":
st.title("📜 User History")

9
Solanki Ankita J. 236140307130

try:
user_df = pd.read_csv("user_data.csv")

if user_df.empty:
st.info("No user history found. Interact with the chatbot to create history.")
else:
# Display each record as a card
for index, row in user_df.iterrows():
st.markdown(f"""
<div style='
background-color: #1E1E1E;
color: #E0E0E0;
padding: 15px 20px;
border-radius: 15px;
box-shadow: 2px 2px 12px rgba(0,0,0,0.4);
margin-bottom: 15px;
'>
<h4 style='color:#4CAF50;'>👤 {row['Name']} | Age: {row['Age']}</h4>
<p><b>Duration:</b> {row['Duration']} days</p>
<p><b>Symptoms:</b> {row['Symptoms']}</p>
<p><b>Severity:</b> {row['Severity'].capitalize()}</p>
<p><b>Condition:</b> {row['Condition']}</p>
<p><b>General Advice:</b> {row['GeneralAdvice']}</p>
<p><b>Home Remedy:</b> {row['HomeRemedy']}</p>
<p><b>Diet Tip:</b> {row['DietTip']}</p>
<p><b>Prevention Tips:</b> {row['PreventionTips']}</p>
<p><b>Doctor Advice:</b> {row['DoctorAdvice']}</p>
<p><b>Feedback:</b> {row['Feedback']}</p>
<p style='font-size:10px; color:#B0B0B0;'><i>Timestamp:
{row['Timestamp']}</i></p>
</div>
""", unsafe_allow_html=True)

except FileNotFoundError:
st.info("No user history found. Interact with the chatbot to create history.")

# ------------------- Chatbot -------------------


elif page == "Chatbot":
st.markdown("""
<div style='
background: linear-gradient(135deg, #2C3E50, #4CA1AF);
padding: 25px;
border-radius: 20px;

10
Solanki Ankita J. 236140307130

text-align: center;
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
'>
<h2 style='color: #F7F7F7; font-family: "Segoe UI", sans-serif; margin-bottom: 5px;'>🌿
MediMate : Your AI Health Buddy</h2>
</div>
""", unsafe_allow_html=True)

# ------------------- Display Chat at the Top -------------------


chat_container = st.container()
with chat_container:
for chat in st.session_state.chat_history:
if chat["role"] == "user":
st.markdown(f"""
<div style='text-align: right; margin: 8px 0;'>
<span style='
background: linear-gradient(135deg, #2C3E50, #4CA1AF);
color: white;
padding:12px 18px;
border-radius:25px;
display:inline-block;
max-width:70%;
word-wrap:break-word;
box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
'>{chat["message"]}</span>
</div>
""", unsafe_allow_html=True)
else:
st.markdown(f"""
<div style='text-align: left; margin: 8px 0;'>
<span style='
background: linear-gradient(135deg, #333, #1E1E1E);
color: white;
padding:12px 18px;
border-radius:25px;
display:inline-block;
max-width:70%;
word-wrap:break-word;
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
'>{chat["message"]}</span>
</div>
""", unsafe_allow_html=True)

# ------------------- User Input at the Bottom -------------------

11
Solanki Ankita J. 236140307130

with st.form("user_form", clear_on_submit=True):


user_input = st.text_input("Type your message here...")
submitted = st.form_submit_button("Send")

if submitted and user_input:


# Append user message to chat
st.session_state.chat_history.append({"role": "user", "message": user_input})

# ------------------- Conversation Flow -------------------


bot_reply = ""
# Step 1: Ask Name / Handle Greetings
if "name" not in st.session_state.user_info:
greetings = ["hi", "hello", "hey", "hii", "hy", "hola"]
user_text_lower = user_input.strip().lower()

if user_text_lower in greetings:
bot_reply = ("Hello! 👋 I’m MediMate, your AI Health Buddy 🌿. "
"I can help you understand your symptoms, suggest home remedies, "
"diet tips, prevention advice, and more.\n\n"
"What’s your name?")
else:
st.session_state.user_info["name"] = user_input
bot_reply = f"Nice to meet you, {user_input}! How old are you?"

# Step 2: Ask Age


elif "age" not in st.session_state.user_info:
if user_input.isdigit():
st.session_state.user_info["age"] = int(user_input)
bot_reply = "For how many days have you been feeling unwell?"
else:
bot_reply = "Please enter a valid age in numbers."
# Step 3: Ask Duration
elif "duration" not in st.session_state.user_info:
st.session_state.user_info["duration"] = user_input
bot_reply = "Please describe your symptoms (e.g., headache, fever)."
# Step 4: Ask Symptoms
elif "symptoms" not in st.session_state.user_info:
st.session_state.user_info["symptoms"] = user_input
bot_reply = "On a scale, are your symptoms mild, moderate, or severe?"
# Step 5: Ask Severity
elif "severity" not in st.session_state.user_info:
if user_input.lower() in ["mild", "moderate", "severe"]:
st.session_state.user_info["severity"] = user_input.lower()
# Find condition

12
Solanki Ankita J. 236140307130

condition_info = find_condition(st.session_state.user_info["symptoms"])
st.session_state.user_info["condition"] = condition_info["Condition"]
st.session_state.user_info["general_advice"] = condition_info["GeneralAdvice"]
st.session_state.user_info["home_remedy"] = condition_info["HomeRemedy"]
st.session_state.user_info["diet_tip"] = condition_info["DietTip"]
st.session_state.user_info["prevention"] = condition_info["PreventionTips"]
st.session_state.user_info["doctor_advice"] = condition_info["WhenToSeeDoctor"]
bot_reply = f"Based on your symptoms, it could be
**{condition_info['Condition']}**.\n\nGeneral Advice:
{condition_info['GeneralAdvice']}\n\nWould you like home remedies?"
else:
bot_reply = "Please choose: mild, moderate, or severe."
# Step 6: Home Remedies
elif "home_remedy_done" not in st.session_state.user_info:
if user_input.lower() in ["yes", "y"]:
bot_reply = f"Home Remedies:
{st.session_state.user_info['home_remedy']}\n\nWould you like diet tips?"
else:
bot_reply = "Okay, skipping home remedies.\nWould you like diet tips?"
st.session_state.user_info["home_remedy_done"] = True
# Step 7: Diet Tips
elif "diet_done" not in st.session_state.user_info:
if user_input.lower() in ["yes", "y"]:
bot_reply = f"Diet Tips: {st.session_state.user_info['diet_tip']}\n\nWould you like
prevention tips?"
else:
bot_reply = "Okay, skipping diet tips.\nWould you like prevention tips?"
st.session_state.user_info["diet_done"] = True
# Step 8: Prevention Tips
elif "prevention_done" not in st.session_state.user_info:
if user_input.lower() in ["yes", "y"]:
bot_reply = f"Prevention Tips: {st.session_state.user_info['prevention']}\n\nWould
you like doctor guidance?"
else:
bot_reply = "Okay, skipping prevention tips.\nWould you like doctor guidance?"
st.session_state.user_info["prevention_done"] = True
# Step 9: Doctor Advice
elif "doctor_done" not in st.session_state.user_info:
if user_input.lower() in ["yes", "y"]:
bot_reply = f"When to See Doctor:
{st.session_state.user_info['doctor_advice']}\n\nWas this advice helpful?"
else:
bot_reply = "Okay, skipping doctor advice.\nWas this advice helpful?"
st.session_state.user_info["doctor_done"] = True

13
Solanki Ankita J. 236140307130

# Step 10: Feedback


elif "feedback_done" not in st.session_state.user_info:
st.session_state.user_info["feedback"] = user_input
bot_reply = f"Thanks for your feedback, {st.session_state.user_info['name']}! 🌸 Take
care and stay healthy!"
st.session_state.user_info["feedback_done"] = True
# Save to CSV
user_record = {
"Name": st.session_state.user_info.get("name", ""),
"Age": st.session_state.user_info.get("age", ""),
"Duration": st.session_state.user_info.get("duration", ""),
"Symptoms": st.session_state.user_info.get("symptoms", ""),
"Severity": st.session_state.user_info.get("severity", ""),
"Condition": st.session_state.user_info.get("condition", ""),
"GeneralAdvice": st.session_state.user_info.get("general_advice", ""),
"HomeRemedy": st.session_state.user_info.get("home_remedy", ""),
"DietTip": st.session_state.user_info.get("diet_tip", ""),
"PreventionTips": st.session_state.user_info.get("prevention", ""),
"DoctorAdvice": st.session_state.user_info.get("doctor_advice", ""),
"Feedback": st.session_state.user_info.get("feedback", ""),
"Timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
}
append_user_data(user_record)
else:
bot_reply = "If you have new symptoms, you can restart by refreshing the page."

# Append bot reply


st.session_state.chat_history.append({"role": "bot", "message": bot_reply})

# ------------------- Refresh to scroll chat to bottom -------------------


st.rerun()

14
Solanki Ankita J. 236140307130

Output:

15
Solanki Ankita J. 236140307130

16
Solanki Ankita J. 236140307130

17
Solanki Ankita J. 236140307130

18
Solanki Ankita J. 236140307130

19
Solanki Ankita J. 236140307130

8. Expected Outcomes
• Users can get an instant idea about possible conditions based on their
symptoms.
• Model provides accurate and relevant suggestions derived from real-
world health data.
• Promotes self-care and awareness, reducing unnecessary panic or
confusion.
• Saves user interactions for trend analysis or improvement.

9. Future Enhancements
1. Integrate speech recognition for voice-based chat.
2. Include image analysis for skin conditions or rashes.
3. Deploy a Flask or FastAPI backend for real-time multi-user access.
4. Expand dataset with AI-based symptom generation.
5. Add emergency detection logic for critical symptoms.
6. Connect with Google Fit / wearable devices for real-time health metrics.

20
Solanki Ankita J. 236140307130

10. Conclusion
MediMate successfully demonstrates how AI and machine learning can enhance
accessibility to health information.
By offering a smart, conversational, and data-driven health assistant, MediMate
bridges the gap between users and healthcare awareness.
This project highlights the potential of combining data science, natural language
understanding, and user-centric design to deliver impactful real-world
applications.
MediMate is not just a chatbot — it’s a step toward digital healthcare
empowerment.

21

You might also like