Spaces:
Configuration error
Configuration error
Upload 9 files
Browse files- App.py +197 -0
- README.md +43 -12
- Symptom2Disease.csv +0 -0
- class_names.txt +24 -0
- model.py +17 -0
- new_symp2disease.ipynb +0 -0
- nltk_utils.py +24 -0
- preprocess_data.py +17 -0
- pretrained_symtom_to_disease_model.pth +3 -0
App.py
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import and class names setup
|
2 |
+
import gradio as gr
|
3 |
+
import os
|
4 |
+
import torch
|
5 |
+
import random
|
6 |
+
import nltk_utils
|
7 |
+
import pandas as pd
|
8 |
+
from sklearn.model_selection import train_test_split
|
9 |
+
import time
|
10 |
+
|
11 |
+
from model import RNN_model
|
12 |
+
from timeit import default_timer as timer
|
13 |
+
from typing import Tuple, Dict
|
14 |
+
|
15 |
+
# Import data
|
16 |
+
df= pd.read_csv('Symptom2Disease.csv')
|
17 |
+
df.drop('Unnamed: 0', axis= 1, inplace= True)
|
18 |
+
|
19 |
+
# Preprocess data
|
20 |
+
df.drop_duplicates(inplace= True)
|
21 |
+
train_data, test_data= train_test_split(df, test_size=0.15, random_state=42 )
|
22 |
+
|
23 |
+
# Setup class names
|
24 |
+
class_names= {0: 'Acne',
|
25 |
+
1: 'Arthritis',
|
26 |
+
2: 'Bronchial Asthma',
|
27 |
+
3: 'Cervical spondylosis',
|
28 |
+
4: 'Chicken pox',
|
29 |
+
5: 'Common Cold',
|
30 |
+
6: 'Dengue',
|
31 |
+
7: 'Dimorphic Hemorrhoids',
|
32 |
+
8: 'Fungal infection',
|
33 |
+
9: 'Hypertension',
|
34 |
+
10: 'Impetigo',
|
35 |
+
11: 'Jaundice',
|
36 |
+
12: 'Malaria',
|
37 |
+
13: 'Migraine',
|
38 |
+
14: 'Pneumonia',
|
39 |
+
15: 'Psoriasis',
|
40 |
+
16: 'Typhoid',
|
41 |
+
17: 'Varicose Veins',
|
42 |
+
18: 'allergy',
|
43 |
+
19: 'diabetes',
|
44 |
+
20: 'drug reaction',
|
45 |
+
21: 'gastroesophageal reflux disease',
|
46 |
+
22: 'peptic ulcer disease',
|
47 |
+
23: 'urinary tract infection'
|
48 |
+
}
|
49 |
+
|
50 |
+
vectorizer= nltk_utils.vectorizer()
|
51 |
+
vectorizer.fit(train_data.text)
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
# Model and transforms preparation
|
56 |
+
model= RNN_model()
|
57 |
+
# Load state dict
|
58 |
+
model.load_state_dict(torch.load(
|
59 |
+
f= 'pretrained_symtom_to_disease_model.pth',
|
60 |
+
map_location= torch.device('cpu')
|
61 |
+
)
|
62 |
+
)
|
63 |
+
# Disease Advice
|
64 |
+
disease_advice = {
|
65 |
+
'Acne': "Maintain a proper skincare routine, avoid excessive touching of the affected areas, and consider using over-the-counter topical treatments. If severe, consult a dermatologist.",
|
66 |
+
'Arthritis': "Stay active with gentle exercises, manage weight, and consider pain-relief strategies like hot/cold therapy. Consult a rheumatologist for tailored guidance.",
|
67 |
+
'Bronchial Asthma': "Follow prescribed inhaler and medication regimen, avoid triggers like smoke and allergens, and have an asthma action plan. Regular check-ups with a pulmonologist are important.",
|
68 |
+
'Cervical spondylosis': "Maintain good posture, do neck exercises, and use ergonomic support. Physical therapy and pain management techniques might be helpful.",
|
69 |
+
'Chicken pox': "Rest, maintain hygiene, and avoid scratching. Consult a doctor for appropriate antiviral treatment.",
|
70 |
+
'Common Cold': "Get plenty of rest, stay hydrated, and consider over-the-counter remedies for symptom relief. Seek medical attention if symptoms worsen or last long.",
|
71 |
+
'Dengue': "Stay hydrated, rest, and manage fever with acetaminophen. Seek medical care promptly, as dengue can escalate quickly.",
|
72 |
+
'Dimorphic Hemorrhoids': "Follow a high-fiber diet, maintain good hygiene, and consider stool softeners. Consult a doctor if symptoms persist.",
|
73 |
+
'Fungal infection': "Keep the affected area clean and dry, use antifungal creams, and avoid sharing personal items. Consult a dermatologist if it persists.",
|
74 |
+
'Hypertension': "Follow a balanced diet, exercise regularly, reduce salt intake, and take prescribed medications. Regular check-ups with a healthcare provider are important.",
|
75 |
+
'Impetigo': "Keep the affected area clean, use prescribed antibiotics, and avoid close contact. Consult a doctor for proper treatment.",
|
76 |
+
'Jaundice': "Get plenty of rest, maintain hydration, and follow a doctor's advice for diet and medications. Regular monitoring is important.",
|
77 |
+
'Malaria': "Take prescribed antimalarial medications, rest, and manage fever. Seek medical attention for severe cases.",
|
78 |
+
'Migraine': "Identify triggers, manage stress, and consider pain-relief medications. Consult a neurologist for personalized management.",
|
79 |
+
'Pneumonia': "Follow prescribed antibiotics, rest, stay hydrated, and monitor symptoms. Seek immediate medical attention for severe cases.",
|
80 |
+
'Psoriasis': "Moisturize, use prescribed creams, and avoid triggers. Consult a dermatologist for effective management.",
|
81 |
+
'Typhoid': "Take prescribed antibiotics, rest, and stay hydrated. Dietary precautions are important. Consult a doctor for proper treatment.",
|
82 |
+
'Varicose Veins': "Elevate legs, exercise regularly, and wear compression stockings. Consult a vascular specialist for evaluation and treatment options.",
|
83 |
+
'allergy': "Identify triggers, manage exposure, and consider antihistamines. Consult an allergist for comprehensive management.",
|
84 |
+
'diabetes': "Follow a balanced diet, exercise, monitor blood sugar levels, and take prescribed medications. Regular visits to an endocrinologist are essential.",
|
85 |
+
'drug reaction': "Discontinue the suspected medication, seek medical attention if symptoms are severe, and inform healthcare providers about the reaction.",
|
86 |
+
'gastroesophageal reflux disease': "Follow dietary changes, avoid large meals, and consider medications. Consult a doctor for personalized management.",
|
87 |
+
'peptic ulcer disease': "Avoid spicy and acidic foods, take prescribed medications, and manage stress. Consult a gastroenterologist for guidance.",
|
88 |
+
'urinary tract infection': "Stay hydrated, take prescribed antibiotics, and maintain good hygiene. Consult a doctor for appropriate treatment."
|
89 |
+
}
|
90 |
+
|
91 |
+
howto= """Welcome to the <b>Medical Chatbot</b>, powered by Gradio.
|
92 |
+
Currently, the chatbot can WELCOME YOU, PREDICT DISEASE based on your symptoms and SUGGEST POSSIBLE SOLUTIONS AND RECOMENDATIONS, and BID YOU FAREWELL.
|
93 |
+
<br><br>
|
94 |
+
Here's a quick guide to get you started:<br><br>
|
95 |
+
<b>How to Start:</b> Simply type your messages in the textbox to chat with the Chatbot and press enter!<br><br>
|
96 |
+
The bot will respond based on the best possible answers to your messages. For now, let's keep it SIMPLE as I'm working hard to enhance its capabilities in the future.
|
97 |
+
|
98 |
+
"""
|
99 |
+
|
100 |
+
|
101 |
+
# Create the gradio demo
|
102 |
+
with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;} #chatbot {height: 520px; overflow: auto;}""") as demo:
|
103 |
+
gr.HTML('<h1 align="center">Medical Chatbot: Your Virtual Health Guide 🌟🏥🤖"</h1>')
|
104 |
+
gr.HTML('<h3 align="center">To know more about this project click, <a href="https://github.com/Monsurat-Onabajo/Medical_chatbot" target="_blank">Here</a>')
|
105 |
+
with gr.Accordion("Follow these Steps to use the Gradio WebUI", open=True):
|
106 |
+
gr.HTML(howto)
|
107 |
+
chatbot = gr.Chatbot()
|
108 |
+
msg = gr.Textbox()
|
109 |
+
clear = gr.ClearButton([msg, chatbot])
|
110 |
+
|
111 |
+
def respond(message, chat_history):
|
112 |
+
# Random greetings in list format
|
113 |
+
greetings = [
|
114 |
+
"hello!",'hello', 'hii !', 'hi', "hi there!", "hi there!", "heyy", 'good morning', 'good afternoon', 'good evening'
|
115 |
+
"hey", "how are you", "how are you?", "how is it going", "how is it going?",
|
116 |
+
"what's up?", "how are you?",
|
117 |
+
"hey, how are you?", "what is popping"
|
118 |
+
"good to see you!", "howdy!",
|
119 |
+
"hi, nice to meet you.", "hiya!",
|
120 |
+
"hi", "hi, what's new?",
|
121 |
+
"hey, how's your day?", "hi, how have you been?", "greetings",
|
122 |
+
]
|
123 |
+
# Random Greetings responses
|
124 |
+
responses = [
|
125 |
+
"Thank you for using our medical chatbot. Please provide the symptoms you're experiencing, and I'll do my best to predict the possible disease.",
|
126 |
+
"Hello! I'm here to help you with medical predictions based on your symptoms. Please describe your symptoms in as much detail as possible.",
|
127 |
+
"Greetings! I am a specialized medical chatbot trained to predict potential diseases based on the symptoms you provide. Kindly list your symptoms explicitly.",
|
128 |
+
"Welcome to the medical chatbot. To assist you accurately, please share your symptoms in explicit detail.",
|
129 |
+
"Hi there! I'm a medical chatbot specialized in analyzing symptoms to suggest possible diseases. Please provide your symptoms explicitly.",
|
130 |
+
"Hey! I'm your medical chatbot. Describe your symptoms with as much detail as you can, and I'll generate potential disease predictions.",
|
131 |
+
"How can I assist you today? I'm a medical chatbot trained to predict diseases based on symptoms. Please be explicit while describing your symptoms.",
|
132 |
+
"Hello! I'm a medical chatbot capable of predicting diseases based on the symptoms you provide. Your explicit symptom description will help me assist you better.",
|
133 |
+
"Greetings! I'm here to help with medical predictions. Describe your symptoms explicitly, and I'll offer insights into potential diseases.",
|
134 |
+
"Hi, I'm the medical chatbot. I've been trained to predict diseases from symptoms. The more explicit you are about your symptoms, the better I can assist you.",
|
135 |
+
"Hi, I specialize in medical predictions based on symptoms. Kindly provide detailed symptoms for accurate disease predictions.",
|
136 |
+
"Hello! I'm a medical chatbot with expertise in predicting diseases from symptoms. Please describe your symptoms explicitly to receive accurate insights.",
|
137 |
+
]
|
138 |
+
# Random goodbyes
|
139 |
+
goodbyes = [
|
140 |
+
"farewell!",'bye', 'goodbye','good-bye', 'good bye', 'bye', 'thank you', 'later', "take care!",
|
141 |
+
"see you later!", 'see you', 'see ya', 'see-you', 'thanks', 'thank', 'bye bye', 'byebye'
|
142 |
+
"catch you on the flip side!", "adios!",
|
143 |
+
"goodbye for now!", "till we meet again!",
|
144 |
+
"so long!", "hasta la vista!",
|
145 |
+
"bye-bye!", "keep in touch!",
|
146 |
+
"toodles!", "ciao!",
|
147 |
+
"later, gator!", "stay safe and goodbye!",
|
148 |
+
"peace out!", "until next time!", "off I go!",
|
149 |
+
]
|
150 |
+
# Random Goodbyes responses
|
151 |
+
goodbye_replies = [
|
152 |
+
"Take care of yourself! If you have more questions, don't hesitate to reach out.",
|
153 |
+
"Stay well! Remember, I'm here if you need further medical advice.",
|
154 |
+
"Goodbye for now! Don't hesitate to return if you need more information in the future.",
|
155 |
+
"Wishing you good health ahead! Feel free to come back if you have more concerns.",
|
156 |
+
"Farewell! If you have more symptoms or questions, don't hesitate to consult again.",
|
157 |
+
"Take care and stay informed about your health. Feel free to chat anytime.",
|
158 |
+
"Bye for now! Remember, your well-being is a priority. Don't hesitate to ask if needed.",
|
159 |
+
"Have a great day ahead! If you need medical guidance later on, I'll be here.",
|
160 |
+
"Stay well and take it easy! Reach out if you need more medical insights.",
|
161 |
+
"Until next time! Prioritize your health and reach out if you need assistance.",
|
162 |
+
"Goodbye! Your health matters. Feel free to return if you have more health-related queries.",
|
163 |
+
"Stay healthy and stay curious about your health! If you need more info, just ask.",
|
164 |
+
"Wishing you wellness on your journey! If you have more questions, I'm here to help.",
|
165 |
+
"Take care and remember, your health is important. Don't hesitate to reach out if needed.",
|
166 |
+
"Goodbye for now! Stay informed and feel free to consult if you require medical advice.",
|
167 |
+
"Stay well and stay proactive about your health! If you have more queries, feel free to ask.",
|
168 |
+
"Farewell! Remember, I'm here whenever you need reliable medical information.",
|
169 |
+
"Bye for now! Stay vigilant about your health and don't hesitate to return if necessary.",
|
170 |
+
"Take care and keep your well-being a priority! Reach out if you have more health questions.",
|
171 |
+
"Wishing you good health ahead! Don't hesitate to chat if you need medical insights.",
|
172 |
+
"Goodbye! Stay well and remember, I'm here to assist you with medical queries.",
|
173 |
+
]
|
174 |
+
|
175 |
+
# Create couple of if-else statements to capture/mimick peoples's Interaction
|
176 |
+
if message.lower() in greetings:
|
177 |
+
bot_message= random.choice(responses)
|
178 |
+
elif message.lower() in goodbyes:
|
179 |
+
bot_message= random.choice(goodbye_replies)
|
180 |
+
else:
|
181 |
+
transform_text= vectorizer.transform([message])
|
182 |
+
transform_text= torch.tensor(transform_text.toarray()).to(torch.float32)
|
183 |
+
model.eval()
|
184 |
+
with torch.inference_mode():
|
185 |
+
y_logits=model(transform_text)
|
186 |
+
pred_prob= torch.argmax(torch.softmax(y_logits, dim=1), dim=1)
|
187 |
+
|
188 |
+
test_pred= class_names[pred_prob.item()]
|
189 |
+
bot_message = f' Based on your symptoms, I believe you are having {test_pred} and I would advice you {disease_advice[test_pred]}'
|
190 |
+
chat_history.append((message, bot_message))
|
191 |
+
time.sleep(2)
|
192 |
+
return "", chat_history
|
193 |
+
|
194 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
195 |
+
# Launch the demo
|
196 |
+
demo.launch()
|
197 |
+
|
README.md
CHANGED
@@ -1,12 +1,43 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Medical Chatbot Project
|
2 |
+
|
3 |
+
## Introduction
|
4 |
+
Welcome to the project overview for the Medical Chatbot project. This document outlines the purpose, scope, and key objectives of the project.
|
5 |
+
|
6 |
+
## Project Name
|
7 |
+
Medical Chatbot
|
8 |
+
|
9 |
+
## Project Description
|
10 |
+
The Medical Chatbot is an AI-powered platform designed to assist users in obtaining accurate and reliable medical information. It aims to provide instant responses to user queries, offer symptom analysis, suggest potential diagnoses, and recommend appropriate next steps for seeking medical care.
|
11 |
+
|
12 |
+
## Key Objectives
|
13 |
+
- **Deliver Accurate Information:** Provide users with up-to-date and trustworthy medical information.
|
14 |
+
- **Symptom Analysis:** Enable users to describe their symptoms and receive preliminary insights into potential health concerns.
|
15 |
+
- **Emergency Guidance:** Offer appropriate guidance for emergency situations and immediate medical attention.
|
16 |
+
- **User-Friendly Interaction:** Ensure a user-friendly and intuitive chatbot interface for easy interaction.
|
17 |
+
- **Referral to Professionals:** Direct users to consult medical professionals for accurate diagnosis and treatment plans.
|
18 |
+
|
19 |
+
## Scope
|
20 |
+
The project will cover the development of a conversational AI chatbot focused on providing medical information and initial assessments. It will not replace professional medical advice or diagnosis.
|
21 |
+
|
22 |
+
## Features
|
23 |
+
- **Real-time Responses:** Instantly respond to user queries and concerns with relevant medical information.
|
24 |
+
- **Symptom Checker:** Assist users in analyzing their symptoms and suggesting potential conditions.
|
25 |
+
- **Emergency Support:** Provide clear instructions for emergency situations and advise users to seek immediate medical help.
|
26 |
+
- **Interactive Interface:** Offer a user-friendly chat interface to engage users in meaningful health-related conversations.
|
27 |
+
|
28 |
+
## Technologies Used
|
29 |
+
- **Python:** The primary programming language for the project's development.
|
30 |
+
- **Natural Language Processing (NLP) Technologies (NLTK, ChatGPT):** Was used to understand and preprocess user input.
|
31 |
+
- **Machine Learning - (Pytorch):** Was used to enhance the accuracy and effectiveness of symptom analysis.
|
32 |
+
- **Backend Development (Python):** Was used to manage user data and responses.
|
33 |
+
- **Web Interface (Gradio):** Provided an intuitive platform for users to interact with the chatbot.
|
34 |
+
- **Deployment:** This model was deployed on hugging face space
|
35 |
+
|
36 |
+
## Deployment
|
37 |
+
To use the model Live: Click [Here](https://huggingface.co/spaces/OnabajoMonsurat/Medical_Diagnosis_Chatbot)
|
38 |
+
|
39 |
+
## Contact Information
|
40 |
+
For inquiries or more information about the Medical Chatbot project, please contact Onabajo Monsurat at [email protected].
|
41 |
+
|
42 |
+
|
43 |
+
|
Symptom2Disease.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
class_names.txt
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Acne
|
2 |
+
Arthritis
|
3 |
+
Bronchial Asthma
|
4 |
+
Cervical spondylosis
|
5 |
+
Chicken pox
|
6 |
+
Common Cold
|
7 |
+
Dengue
|
8 |
+
Dimorphic Hemorrhoids
|
9 |
+
Fungal infection
|
10 |
+
Hypertension
|
11 |
+
Impetigo
|
12 |
+
Jaundice
|
13 |
+
Malaria
|
14 |
+
Migraine
|
15 |
+
Pneumonia
|
16 |
+
Psoriasis
|
17 |
+
Typhoid
|
18 |
+
Varicose Veins
|
19 |
+
allergy
|
20 |
+
diabetes
|
21 |
+
drug reaction
|
22 |
+
gastroesophageal reflux disease
|
23 |
+
peptic ulcer disease
|
24 |
+
urinary tract infection
|
model.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from torch import nn
|
3 |
+
|
4 |
+
class RNN_model(nn.Module):
|
5 |
+
def __init__(self):
|
6 |
+
super().__init__()
|
7 |
+
|
8 |
+
self.rnn= nn.RNN(input_size=1080, hidden_size=240,num_layers=1, nonlinearity= 'relu', bias= True)
|
9 |
+
self.output= nn.Linear(in_features=240, out_features=24)
|
10 |
+
|
11 |
+
def forward(self, x):
|
12 |
+
y, hidden= self.rnn(x)
|
13 |
+
#print(y.shape)
|
14 |
+
#print(hidden.shape)
|
15 |
+
x= self.output(y)
|
16 |
+
|
17 |
+
return(x)
|
new_symp2disease.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
nltk_utils.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import Libraries
|
2 |
+
import nltk
|
3 |
+
from nltk.tokenize import word_tokenize
|
4 |
+
nltk.download('punkt')
|
5 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
6 |
+
from nltk.stem import SnowballStemmer
|
7 |
+
stemmer= SnowballStemmer(language= 'english')
|
8 |
+
from nltk.corpus import stopwords
|
9 |
+
nltk.download('stopwords')
|
10 |
+
|
11 |
+
# Tokenize text i.e make all text be in a list format e.g "I am sick" = ['i', 'am', 'sick']
|
12 |
+
def tokenize(text):
|
13 |
+
return [stemmer.stem(token) for token in word_tokenize(text)]
|
14 |
+
|
15 |
+
# Create stopwords to reduce noise in data
|
16 |
+
english_stopwords= stopwords.words('english')
|
17 |
+
|
18 |
+
# Create a vectosizer to learn all words in order to convert them into numbers
|
19 |
+
def vectorizer():
|
20 |
+
vectorizer= TfidfVectorizer(tokenizer=tokenize,
|
21 |
+
stop_words=english_stopwords,
|
22 |
+
)
|
23 |
+
return vectorizer
|
24 |
+
|
preprocess_data.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import Libaries
|
2 |
+
from torch.utils.data import DataLoader, TensorDataset
|
3 |
+
|
4 |
+
# Map target and label data together in a tuple format
|
5 |
+
def preprocess_data(label_X, target_y):
|
6 |
+
preprocessed= TensorDataset(label_X, target_y)
|
7 |
+
return preprocessed
|
8 |
+
|
9 |
+
# Create data loaders
|
10 |
+
def dataloader(dataset, batch_size, shuffle, num_workers):
|
11 |
+
dataloader= DataLoader(dataset=dataset,
|
12 |
+
batch_size=batch_size,
|
13 |
+
shuffle= shuffle,
|
14 |
+
num_workers=num_workers,
|
15 |
+
)
|
16 |
+
return (dataloader)
|
17 |
+
|
pretrained_symtom_to_disease_model.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d182949722a706bed0e7c6319bb893eccc31f8d2b502d023750e0beafd5da8fe
|
3 |
+
size 1294703
|