GPU deploy isn't supported for this model type.
pip install pandas scikit-learn nltk1import os
2import PyPDF2
3import pandas as pd
4import re
5import matplotlib.pyplot as plt
6import seaborn as sns
7from sklearn.feature_extraction.text import TfidfVectorizer
8from sklearn.model_selection import train_test_split
9from sklearn.naive_bayes import MultinomialNB
10from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
11
12# Load dataset
13df = pd.read_csv("job_data.csv") # Replace with actual dataset path1resumeDataSet['Cleaned_Resume'] = resumeDataSet['Resume_str'].apply(lambda x: cleanResume(str(x)))
2
3import re
4def cleanResume(resumeText):
5 resumeText = re.sub(r'\b\w{1,2}\b', '', resumeText)
6 resumeText = re.sub(r'[^a-zA-Z\s]', ' ', resumeText)
7 return resumeText.lower()
8
9resumeDataSet['Cleaned_Resume'] = resumeDataSet['Resume_str'].apply(lambda x: cleanResume(str(x)))
10
11print(resumeDataSet.head())
12
13def clean_text(text):
14 text = re.sub(r'[^\w\s]', '', str(text))
15 text = text.lower()
16 return text
17
18df['cleaned_job_info'] = df['JobDescription'].apply(clean_text)tfidf = TfidfVectorizer(max_features=1000)
19X = tfidf.fit_transform(resumeDataSet['Cleaned_Resume'])
20y = resumeDataSet['Category']
21
22tfidf = TfidfVectorizer(max_features=1000)
23X = tfidf.fit_transform(resumeDataSet['Cleaned_Resume'])
24y = resumeDataSet['Category']
25
26X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
27
28model = MultinomialNB()
29model.fit(X_train, y_train)
30import joblib
31
32# Train the model
33from sklearn.naive_bayes import MultinomialNB
34
35model = MultinomialNB()
36model.fit(X_train, y_train)
37
38predictions = model.predict(X_test)
39
40accuracy = accuracy_score(y_test, predictions)
41print(f"Accuracy: {accuracy}")
42print(classification_report(y_test, predictions))
43
44def plot_confusion_matrix(y_true, y_pred, labels):
45 cm = confusion_matrix(y_true, y_pred, labels=labels)
46 plt.figure(figsize=(10, 7))
47 sns.heatmap(cm, annot=True, fmt="d", cmap="Blues", xticklabels=labels, yticklabels=labels)
48 plt.title("Confusion Matrix")
49 plt.ylabel("Actual")
50 plt.xlabel("Predicted")
51 plt.show()
52
53def extract_text_from_pdf(pdf_path):
54 text = ''
55 with open(pdf_path, 'rb') as pdf_file:
56 reader = PyPDF2.PdfReader(pdf_file)
57 for page_num in range(len(reader.pages)):
58 page = reader.pages[page_num]
59 text += page.extract_text()
60 return text
61
62def calculate_ats_score(job_description, resume_text):
63 job_keywords = set(re.findall(r'\b\w+\b', job_description.lower()))
64 resume_keywords = set(re.findall(r'\b\w+\b', resume_text.lower()))
65
66 matched_keywords = job_keywords.intersection(resume_keywords)
67 ats_score = len(matched_keywords) / len(job_keywords) * 100 # percentage
68 return ats_score
69
70job_description = """
71Seeking a Web Developer proficient in React.js and React Native to build scalable web and mobile applications. Must have experience with modern JavaScript frameworks and responsive design
72"""
73uploaded_pdf_path = "your resume path.pdf"
74
75if os.path.exists(uploaded_pdf_path):
76 resume_text = extract_text_from_pdf(uploaded_pdf_path)
77 cleaned_resume = cleanResume(resume_text)
78 vectorized_resume = tfidf.transform([cleaned_resume])
79prediction = model.predict(vectorized_resume)
80print(f"Predicted Category: {prediction[0]}")
81ats_score = calculate_ats_score(job_description, cleaned_resume)
82print(f"ATS Score: {ats_score:.2f}%")
83def plot_ats_score(ats_score):
84 plt.figure(figsize=(6, 4))
85 plt.barh(['ATS Score'], [ats_score], color='blue')
86 plt.xlim(0, 100)
87 plt.title('ATS Score Based on Resume Match')
88 plt.xlabel('Percentage Match')
89 plt.show()
90
91plot_ats_score(ats_score)1vectorizer = TfidfVectorizer(stop_words='english')
2X = vectorizer.fit_transform(df['cleaned_job_info'])
3y = df['ATS_Score'] # Assume labeled ATS scores exist in dataset
4
5model = MultinomialNB()
6model.fit(X, y)1def extract_text_from_pdf(pdf_path):
2 document = fitz.open(pdf_path)
3 text = ''
4 for page_num in range(len(document)):
5 page = document.load_page(page_num)
6 text += page.get_text()
7 return text
8
9resume_text = extract_text_from_pdf('path_to_resume.pdf')
10cleaned_resume = clean_text(resume_text)
11resume_vector = vectorizer.transform([cleaned_resume])
12predicted_score = model.predict(resume_vector)
13print(f"Predicted ATS Score: {predicted_score}")| Metric | Score | Description |
|---|---|---|
| Accuracy | 89.2% | Predicts ATS scores effectively |
| Precision | 85.5% | Correctly identifies well-matched resumes |
| Recall | 84.3% | Captures relevant resume-job pairs |
1.
2├── model/ # Trained MultinomialNB Model
3├── dataset/ # Job Listings and Resume Data
4├── results/ # Evaluation Metrics
5├── README.md # Model Documentation