-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProbabilistic_Reasoning.py
More file actions
70 lines (59 loc) · 3.06 KB
/
Probabilistic_Reasoning.py
File metadata and controls
70 lines (59 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class ProbabilisticReasoner:
def __init__(self, knowledge_base):
self.kb = knowledge_base
self.probability_tables = self._initialize_probability_tables()
def _initialize_probability_tables(self):
return {
"skill_match_prob": {
"AI Engineer": {"Python": 0.9, "Machine Learning": 0.85, "Deep Learning": 0.8, "Mathematics": 0.75},
"Data Scientist": {"Python": 0.9, "Statistics": 0.85, "Data Analysis": 0.8, "Machine Learning": 0.75},
"Web Developer": {"JavaScript": 0.9, "HTML/CSS": 0.85, "React": 0.8, "Node.js": 0.75},
"Research Scientist": {"Research Methodology": 0.9, "Mathematics": 0.85, "Publications": 0.8}
},
"marks_probability": {
"AI Engineer": {80: 0.9, 75: 0.8, 70: 0.6, 65: 0.4, 60: 0.2},
"Data Scientist": {75: 0.9, 70: 0.8, 65: 0.6, 60: 0.4, 55: 0.2},
"Web Developer": {70: 0.9, 65: 0.8, 60: 0.7, 55: 0.5, 50: 0.3},
"Research Scientist": {85: 0.9, 80: 0.7, 75: 0.5, 70: 0.3, 65: 0.1}
}
}
def calculate_career_probability(self, student: Student, career: Career) -> float:
# Calculate skill match probability
skill_match_prob = 1.0
matched_skills = 0
for skill in career.required_skills:
if skill in student.skills:
skill_prob = self.probability_tables["skill_match_prob"][career.name].get(
skill, 0.7)
skill_match_prob *= skill_prob
matched_skills += 1
# Adjust for number of matched skills
skill_ratio = matched_skills / len(career.required_skills)
skill_probability = skill_match_prob * skill_ratio
# Calculate marks probability
marks_prob = 0.0
for threshold, prob in self.probability_tables["marks_probability"][career.name].items():
if student.marks >= threshold:
marks_prob = prob
break
# Calculate interest match
interest_match = len(set(student.interests) & set(
career.required_interests)) / len(career.required_interests)
# Combined probability (weighted average)
final_probability = (
0.4 * skill_probability +
0.4 * marks_prob +
0.2 * interest_match
)
return min(1.0, max(0.0, final_probability))
def update_probability_with_new_skill(self, student: Student, new_skill: str, career: Career) -> float:
# Simulate Bayesian update
original_prob = self.calculate_career_probability(student, career)
if new_skill in career.required_skills:
skill_boost = self.probability_tables["skill_match_prob"][career.name].get(
new_skill, 0.7)
updated_prob = original_prob + \
(1 - original_prob) * skill_boost * 0.3
else:
updated_prob = original_prob * 0.95 # Slight penalty for irrelevant skill
return updated_prob