import random
from typing import List, Dict, Any, Tuple
# John's profile and job_opportunities remain the same as in the previous
# version
john = {
'name': 'John',
'skills': {
'Python': 7,
'JavaScript': 6,
'Machine Learning': 4,
'Data Analysis': 5,
'Web Development': 6
},
'experience': 2, # years
'education': "Bachelor's in Computer Science",
'interests': ['AI', 'Web Development', 'Data Science'],
'preferred_work_style': 'hybrid',
'career_goals': ['full-stack developer', 'AI specialist']
}
# Sample job opportunities
job_opportunities = [
{
'title': 'Junior Full Stack Developer',
'required_skills': {
'Python': 5,
'JavaScript': 6,
'Web Development': 7
},
'preferred_skills': {
'React': 4,
'Node.js': 4
},
'min_experience': 1,
'education': "Bachelor's in Computer Science or related field",
'work_style': 'hybrid',
'career_track': 'full-stack developer'
},
{
'title': 'Machine Learning Engineer Intern',
'required_skills': {
'Python': 6,
'Machine Learning': 5,
'Data Analysis': 5
},
'preferred_skills': {
'TensorFlow': 3,
'PyTorch': 3
},
'min_experience': 0,
'education': "Bachelor's or Master's in Computer Science, focus on AI/ML",
'work_style': 'onsite',
'career_track': 'AI specialist'
},
{
'title': 'Data Scientist',
'required_skills': {
'Python': 7,
'Data Analysis': 8,
'Machine Learning': 6
},
'preferred_skills': {
'SQL': 5,
'Data Visualization': 6
},
'min_experience': 3,
'education': "Master's in Data Science or related field",
'work_style': 'remote',
'career_track': 'data scientist'
}
]
def calculate_job_match_score(candidate: Dict[str, Any], job: Dict[str, Any]) -> Tuple[float, Dict[str, Any]]:
score = 0
max_score = 100
feedback = {}
# Skills match (0-40 points)
skills_score = 0
for skill, required_level in job['required_skills'].items():
if skill in candidate['skills']:
skills_score += min(10, (candidate['skills'][skill] / required_level) * 10)
for skill, preferred_level in job.get('preferred_skills', {}).items():
if skill in candidate['skills']:
skills_score += min(5, (candidate['skills'][skill] / preferred_level) * 5)
skills_score = min(40, skills_score)
score += skills_score
feedback['skills_match'] = f"{skills_score:.1f}/40"
# Experience match (0-15 points)
if job['min_experience'] == 0:
experience_score = 15 # Full points if no experience required
elif candidate['experience'] >= job['min_experience']:
experience_score = min(15, 10 + (candidate['experience'] - job['min_experience']))
else:
experience_score = (candidate['experience'] / job['min_experience']) * 15
score += experience_score
feedback['experience_match'] = f"{experience_score:.1f}/15"
# Education match (0-10 points)
if job['education'].lower() in candidate['education'].lower():
score += 10
feedback['education_match'] = "10/10"
else:
feedback['education_match'] = "0/10"
# Interest and career goal alignment (0-20 points)
interest_score = 0
if job['career_track'] in candidate['career_goals']:
interest_score += 10
if any(interest.lower() in job['title'].lower() for interest in candidate['interests']):
interest_score += 10
score += interest_score
feedback['interest_alignment'] = f"{interest_score:.1f}/20"
# Work style match (0-15 points)
if job['work_style'] == candidate['preferred_work_style']:
score += 15
feedback['work_style_match'] = "15/15"
else:
feedback['work_style_match'] = "0/15"
# Normalize score
final_score = (score / max_score) * 100
return final_score, feedback
def match_jobs(candidate: Dict[str, Any], jobs: List[Dict[str, Any]]) -> List[Tuple[Dict[str, Any], float, Dict[str, Any]]]:
job_matches = []
for job in jobs:
score, feedback = calculate_job_match_score(candidate, job)
job_matches.append((job, score, feedback))
# Sort jobs by score in descending order
job_matches.sort(key=lambda x: x[1], reverse=True)
return job_matches
# Run the job matching algorithm
matches = match_jobs(john, job_opportunities)
# Output results
print("Job Recommendations for John:")
for i, (job, score, feedback) in enumerate(matches, 1):
print(f"\nRecommendation {i}: {job['title']}")
print(f"Match Score: {score:.2f}%")
print("\nJob Details:")
print(f" Required Skills: {', '.join(job['required_skills'].keys())}")
print(f" Preferred Skills: {', '.join(job.get('preferred_skills', {}).keys())}")
print(f" Minimum Experience: {job['min_experience']} years")
print(f" Education: {job['education']}")
print(f" Work Style: {job['work_style']}")
print(f" Career Track: {job['career_track']}")
print("\nMatch Analysis:")
print(f" Skills Match: {feedback['skills_match']}")
print(f" Experience Match: {feedback['experience_match']}")
print(f" Education Match: {feedback['education_match']}")
print(f" Interest Alignment: {feedback['interest_alignment']}")
print(f" Work Style Match: {feedback['work_style_match']}")
print("\nStrengths:")
strengths = [k for k, v in feedback.items() if float(v.split('/')[0]) / float(v.split('/')[1]) > 0.7]
for strength in strengths:
print(f" - {strength.replace('_', ' ').title()}")
print("\nAreas for Improvement:")
improvements = [k for k, v in feedback.items() if float(v.split('/')[0]) / float(v.split('/')[1]) <= 0.7]
for improvement in improvements:
print(f" - {improvement.replace('_', ' ').title()}")
print("\nOverall Recommendation:")
if matches[0][1] > 80:
print(f"The {matches[0][0]['title']} position is an excellent match for John's skills and career goals.")
elif matches[0][1] > 60:
print(f"The {matches[0][0]['title']} position is a good match, but John might need to improve in some areas.")
else:
print("John might want to consider upskilling or exploring different roles that better align with his current skills and interests.")