karthikmn commited on
Commit
9bba82b
·
verified ·
1 Parent(s): bc9aa7d

Rename mock_model.py to scorer.py

Browse files
Files changed (2) hide show
  1. mock_model.py +0 -48
  2. scorer.py +35 -0
mock_model.py DELETED
@@ -1,48 +0,0 @@
1
- import random
2
-
3
- # New function: stage-based lead score generator
4
- def get_lead_score_for_stage(stage):
5
- stage_scores = {
6
- "Prospecting": (20, 40),
7
- "Proposal/Price Quote": (50, 70),
8
- "Negotiation": (70, 90),
9
- "Closed Won": (90, 100),
10
- "Closed Lost": (10, 30)
11
- }
12
- return random.randint(*stage_scores.get(stage, (30, 70)))
13
-
14
- def generate_recommendation(stage, emails, meetings):
15
- if stage == "Negotiation":
16
- return "Follow up with final pricing discussion."
17
- elif stage == "Proposal/Price Quote":
18
- return "Schedule one more meeting to present value."
19
- elif meetings == 0:
20
- return "Schedule a meeting to initiate engagement."
21
- elif emails < 2:
22
- return "Send follow-up email to re-engage."
23
- else:
24
- return "Continue monitoring engagement signals."
25
-
26
- def predict(data, model, tokenizer, summarizer):
27
- score = random.randint(50, 95)
28
- confidence = round(random.uniform(0.65, 0.95), 2)
29
-
30
- if score >= 75:
31
- risk = "Low"
32
- elif score >= 55:
33
- risk = "Medium"
34
- else:
35
- risk = "High"
36
-
37
- recommendation = generate_recommendation(
38
- data["stage"],
39
- data["emails_last_7_days"],
40
- data["meetings_last_30_days"]
41
- )
42
-
43
- return {
44
- "score": score,
45
- "confidence": confidence,
46
- "risk": risk,
47
- "recommendation": recommendation
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scorer.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+
3
+ def get_lead_score(stage, emails, meetings, close_gap):
4
+ base = {
5
+ "Prospecting": (20, 40),
6
+ "Proposal/Price Quote": (50, 70),
7
+ "Negotiation": (70, 90),
8
+ "Closed Won": (90, 100),
9
+ "Closed Lost": (10, 30)
10
+ }
11
+ low, high = base.get(stage, (30, 70))
12
+ engagement_bonus = min(emails + meetings, 5)
13
+ urgency_bonus = 5 if close_gap < 14 else 0
14
+ return min(100, random.randint(low, high) + engagement_bonus + urgency_bonus)
15
+
16
+ def calculate_score(lead_score, emails, meetings, close_gap):
17
+ activity_weight = min((emails * 2 + meetings * 3), 25)
18
+ deadline_weight = max(0, 10 - int(close_gap / 5))
19
+ return min(100, lead_score + activity_weight + deadline_weight - random.randint(5, 15))
20
+
21
+ def calculate_confidence(score):
22
+ if score > 85:
23
+ return round(random.uniform(0.90, 0.97), 2)
24
+ elif score > 65:
25
+ return round(random.uniform(0.80, 0.89), 2)
26
+ else:
27
+ return round(random.uniform(0.65, 0.79), 2)
28
+
29
+ def calculate_risk(score, confidence, emails, meetings):
30
+ if score > 80 and confidence > 0.9:
31
+ return "Low"
32
+ elif score > 60 or (emails + meetings) >= 4:
33
+ return "Medium"
34
+ else:
35
+ return "High"