shibinashraf commited on
Commit
ad646a4
Β·
1 Parent(s): ce15187

Upload 7 files

Browse files
.gitattributes CHANGED
@@ -32,3 +32,5 @@ 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/drugsComTest_raw.csv filter=lfs diff=lfs merge=lfs -text
36
+ data/drugsComTrain_raw.csv filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import joblib
3
+ import pandas as pd
4
+ import re
5
+ import nltk
6
+ import streamlit as st
7
+ import numpy as np
8
+ from nltk.stem import WordNetLemmatizer
9
+ from nltk.corpus import stopwords
10
+ from bs4 import BeautifulSoup
11
+
12
+ # Model saved with Keras model.save()
13
+ MODEL_PATH = 'model/passmodel.pkl'
14
+ TOKENIZER_PATH ='model/tfidfvectorizer.pkl'
15
+ DATA_PATH ='data/drugsComTrain_raw.csv'
16
+
17
+ # loading vectorizer
18
+ vectorizer = joblib.load(TOKENIZER_PATH)
19
+ # loading model
20
+ model = joblib.load(MODEL_PATH)
21
+ #getting stopwords
22
+ stop = stopwords.words('english')
23
+ lemmatizer = WordNetLemmatizer()
24
+
25
+
26
+ st.set_page_config(page_title='PDDRS', page_icon='πŸ‘¨β€βš•οΈ')
27
+ st.title("πŸ’‰ Patient Diagnosis and Drug Recommendation System πŸ’‰")
28
+ st.header("Enter Patient Condition:")
29
+ raw_text = st.text_input('')
30
+
31
+
32
+ def predict(raw_text):
33
+ global predicted_cond
34
+ global top_drugs
35
+ if raw_text != "":
36
+ clean_text = cleanText(raw_text)
37
+ clean_lst = [clean_text]
38
+ tfidf_vect = vectorizer.transform(clean_lst)
39
+ prediction = model.predict(tfidf_vect)
40
+ predicted_cond = prediction[0]
41
+ df = pd.read_csv(DATA_PATH)
42
+ top_drugs = top_drugs_extractor(predicted_cond,df)
43
+
44
+ def cleanText(raw_review):
45
+ # 1. Delete HTML
46
+ review_text = BeautifulSoup(raw_review, 'html.parser').get_text()
47
+ # 2. Make a space
48
+ letters_only = re.sub('[^a-zA-Z]', ' ', review_text)
49
+ # 3. lower letters
50
+ words = letters_only.lower().split()
51
+ # 5. Stopwords
52
+ meaningful_words = [w for w in words if not w in stop]
53
+ # 6. lemmitization
54
+ lemmitize_words = [lemmatizer.lemmatize(w) for w in meaningful_words]
55
+ # 7. space join words
56
+ return( ' '.join(lemmitize_words))
57
+
58
+
59
+ def top_drugs_extractor(condition,df):
60
+ df_top = df[(df['rating']>=9)&(df['usefulCount']>=100)].sort_values(by = ['rating', 'usefulCount'], ascending = [False, False])
61
+ drug_lst = df_top[df_top['condition']==condition]['drugName'].head(3).tolist()
62
+ return drug_lst
63
+
64
+
65
+ predict_button = st.button("Predict")
66
+
67
+ if predict_button:
68
+ predict(raw_text)
69
+ st.header('Condition Predicted')
70
+ st.subheader(predicted_cond)
71
+ st.header('Top 3 Drugs Recommended')
72
+ if top_drugs[0] == top_drugs[1]:
73
+ st.subheader(top_drugs[0])
74
+ else:
75
+ st.subheader(top_drugs[0])
76
+ st.subheader(top_drugs[1])
77
+ st.subheader(top_drugs[2])
78
+
79
+
80
+ with open('style.css')as f:
81
+ st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html = True)
data/drugsComTest_raw.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1953e81451b3a43f162e3d438dc1f9c2ee83c9283968a19fce4d3736fdb03eac
3
+ size 28071166
data/drugsComTrain_raw.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc0902b21af0db5b99568a7639ed5f7dad3494a8186a20d05c5b4016c6caedf4
3
+ size 82990470
model/passmodel.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f22688277f5420d94a9be0b56cfca1b898013a96cbdd417cfe80cd51310e7110
3
+ size 74845516
model/tfidfvectorizer.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6caaf578520a735219f0ec253fca79d9c56603b63566388e3f1343226dbd20fd
3
+ size 48320680
requirements.txt ADDED
Binary file (726 Bytes). View file
 
style.css ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #patient-diagnosis-and-drug-recommendation-system{
2
+ font-size: 40px;
3
+ text-align: center;
4
+ }