Commit
·
504dcc1
1
Parent(s):
975247d
Upload 5 files
Browse files- .gitattributes +1 -0
- app.py +80 -0
- data/custom_dataset.csv +3 -0
- model/passmodel.pkl +3 -0
- model/tfidfvectorizer.pkl +3 -0
- requirements.txt +17 -0
.gitattributes
CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
data/custom_dataset.csv filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import joblib
|
3 |
+
import pandas as pd
|
4 |
+
import re
|
5 |
+
import nltk
|
6 |
+
nltk.download('wordnet')
|
7 |
+
nltk.download('stopwords')
|
8 |
+
|
9 |
+
import streamlit as st
|
10 |
+
import numpy as np
|
11 |
+
from nltk.stem import WordNetLemmatizer
|
12 |
+
from nltk.corpus import stopwords
|
13 |
+
from bs4 import BeautifulSoup
|
14 |
+
|
15 |
+
|
16 |
+
# Model saved with Keras model.save()
|
17 |
+
MODEL_PATH = 'model/passmodel.pkl'
|
18 |
+
TOKENIZER_PATH ='model/tfidfvectorizer.pkl'
|
19 |
+
DATA_PATH ='data/custom_dataset.csv'
|
20 |
+
|
21 |
+
# loading vectorizer
|
22 |
+
vectorizer = joblib.load(TOKENIZER_PATH)
|
23 |
+
# loading model
|
24 |
+
model = joblib.load(MODEL_PATH)
|
25 |
+
#getting stopwords
|
26 |
+
stop = stopwords.words('english')
|
27 |
+
lemmatizer = WordNetLemmatizer()
|
28 |
+
|
29 |
+
|
30 |
+
st.set_page_config(page_title='PDDRS', page_icon='👨⚕️',layout = 'wide')
|
31 |
+
st.title("💉 Patient Diagnosis and Drug Recommendation System 💉")
|
32 |
+
st.header("Enter Patient Condition:")
|
33 |
+
raw_text = st.text_input('')
|
34 |
+
|
35 |
+
|
36 |
+
def predict(raw_text):
|
37 |
+
global predicted_cond
|
38 |
+
global top_drugs
|
39 |
+
if raw_text != "":
|
40 |
+
clean_text = cleanText(raw_text)
|
41 |
+
clean_lst = [clean_text]
|
42 |
+
tfidf_vect = vectorizer.transform(clean_lst)
|
43 |
+
prediction = model.predict(tfidf_vect)
|
44 |
+
predicted_cond = prediction[0]
|
45 |
+
df = pd.read_csv(DATA_PATH)
|
46 |
+
top_drugs = top_drugs_extractor(predicted_cond,df)
|
47 |
+
|
48 |
+
def cleanText(raw_review):
|
49 |
+
# 1. Delete HTML
|
50 |
+
review_text = BeautifulSoup(raw_review, 'html.parser').get_text()
|
51 |
+
# 2. Make a space
|
52 |
+
letters_only = re.sub('[^a-zA-Z]', ' ', review_text)
|
53 |
+
# 3. lower letters
|
54 |
+
words = letters_only.lower().split()
|
55 |
+
# 5. Stopwords
|
56 |
+
meaningful_words = [w for w in words if not w in stop]
|
57 |
+
# 6. lemmitization
|
58 |
+
lemmitize_words = [lemmatizer.lemmatize(w) for w in meaningful_words]
|
59 |
+
# 7. space join words
|
60 |
+
return( ' '.join(lemmitize_words))
|
61 |
+
|
62 |
+
|
63 |
+
def top_drugs_extractor(condition,df):
|
64 |
+
df_top = df[(df['rating']>=9)&(df['usefulCount']>=90)].sort_values(by = ['rating', 'usefulCount'], ascending = [False, False])
|
65 |
+
drug_lst = df_top[df_top['condition']==condition]['drugName'].head(4).tolist()
|
66 |
+
drug_lst =[*set(drug_lst)]
|
67 |
+
return drug_lst
|
68 |
+
|
69 |
+
|
70 |
+
predict_button = st.button("Predict")
|
71 |
+
|
72 |
+
if predict_button:
|
73 |
+
predict(raw_text)
|
74 |
+
st.header('Condition Predicted')
|
75 |
+
st.subheader(predicted_cond)
|
76 |
+
st.header('Top Recommended Drugs')
|
77 |
+
for i in range(0,len(top_drugs)):
|
78 |
+
st.subheader(top_drugs[i])
|
79 |
+
|
80 |
+
|
data/custom_dataset.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:39bdc6a910fbfef9b506524047861166c3cf184fa4a3275b8ba958833f3bdbd7
|
3 |
+
size 12230423
|
model/passmodel.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c149cb32e7f154571527d3744e940277d3446e657dc0202b04df3afc54a8e9a0
|
3 |
+
size 32354028
|
model/tfidfvectorizer.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:65ffa88aa305ae86fb683d58b397a9260ac1153d3fb381412d4575ac5b14e5e5
|
3 |
+
size 27603137
|
requirements.txt
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
beautifulsoup4==4.11.2
|
2 |
+
bokeh==3.0.3
|
3 |
+
bs4==0.0.1
|
4 |
+
GitPython==3.1.30
|
5 |
+
joblib==1.2.0
|
6 |
+
nltk==3.8.1
|
7 |
+
numpy==1.24.2
|
8 |
+
pandas==1.5.3
|
9 |
+
regex==2022.10.31
|
10 |
+
scikit-learn==1.2.1
|
11 |
+
scipy==1.10.0
|
12 |
+
SpeechRecognition==1.2.3
|
13 |
+
streamlit==1.18.1
|
14 |
+
streamlit-bokeh-events==0.1.2
|
15 |
+
toml==0.10.2
|
16 |
+
tqdm==4.64.1
|
17 |
+
|