amaanadeen commited on
Commit
46130d2
·
1 Parent(s): c4b177b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -17
app.py CHANGED
@@ -1,25 +1,68 @@
1
- import numpy as np
2
- from flask import Flask, request, render_template
3
  import pickle
 
 
4
 
5
- flask_app = Flask(__name__)
 
6
 
7
- model = pickle.load(open("model.pkl", "rb"))
 
8
 
9
- @flask_app.route("/")
10
- def Home():
11
- return render_template("index.html")
 
 
 
 
 
12
 
13
- @flask_app.route("/predict", methods=["POST"])
14
- def predict():
15
- float_features = [float(x) for x in request.form.values()]
16
- features = [np.array(float_features)]
17
- prediction = model.predict(features)
18
- if prediction=='B':
19
- return render_template("index.html", prediction_text="the person was not classified with cancer")
20
- else:
21
- return render_template("index.html", prediction_text="the Cancer was detected in the patient ")
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  if __name__ == '__main__':
25
- flask_app.run(debug=True)
 
1
+ import streamlit as st
 
2
  import pickle
3
+ import re
4
+ import nltk
5
 
6
+ nltk.download('punkt')
7
+ nltk.stopwords('stopwords')
8
 
9
+ model = pickle.load(open('model.pkl','rb'))
10
+ tfidf = pickle.load(open('tfidf.pkl','rb'))
11
 
12
+ def clean_resume(resume_text):
13
+ cleanText = re.sub('http\S+\s', " ", txt)
14
+ cleanText = re.sub('RT|cc', ' ', cleanText)
15
+ cleanText = re.sub("#\S+\s", ' ', cleanText)
16
+ cleanText = re.sub('@\S+\s', ' ', cleanText)
17
+ cleanText = re.sub('[%s]' % re.escape("""!#$%&'()*+-,":/\;<=>?_[]^{}~`"""), ' ', cleanText)
18
+ cleanText = re.sub(r'[^\x00-\x7f]', " ", cleanText)
19
+ return cleanText
20
 
21
+ def main():
22
+ st.title("Resume Screening Application")
23
+ uploaded_file = st.file_uploader("Upload Resume Here",type=['txt','pdf'])
24
+ if uploaded_file is not None:
25
+ try:
26
+ resume_bytes = uploaded_file.read()
27
+ resume_text = resume_bytes.decode('utf-8')
28
+ except:
29
+ resume_text = resume_bytes.decode('latin-1')
30
 
31
+ cleaned_resume = clean_resume(resume_text)
32
+ input_features = tfidf.transform([cleaned_resume])
33
+ prediction_id = model.predict(input_features)[0]
34
+ st.write(prediction_id)
35
+
36
+ category_mapping = {
37
+ 15: "Java Developer",
38
+ 23: "Testing",
39
+ 8: "DevOps Engineer",
40
+ 20: "Python Developer",
41
+ 24: "Web Designing",
42
+ 12: "HR",
43
+ 13: "Hadoop",
44
+ 3: "Blockchain",
45
+ 10: "ETL Developer",
46
+ 18: "Operations Manager",
47
+ 6: "Data Science",
48
+ 22: "Sales",
49
+ 16: "Mechanical Engineer",
50
+ 1: "Arts",
51
+ 7: "Database",
52
+ 11: "Electrical Engineering",
53
+ 14: "Health and fitness",
54
+ 19: "PMO",
55
+ 4: "Business Analyst",
56
+ 9: "DotNet Developer",
57
+ 2: "Automation Testing",
58
+ 17: "Network Security Engineer",
59
+ 21: "SAP Developer",
60
+ 5: "Civil Engineer",
61
+ 0: "Advocate",
62
+ }
63
+
64
+ category_name = category_mapping.get(prediction_id,'Unknown')
65
+ st.write("THE PREDICTED CATEGORY IS: ",category_name)
66
 
67
  if __name__ == '__main__':
68
+ main()