karthikmn commited on
Commit
acb9352
·
verified ·
1 Parent(s): 2d3dd8f

Update scorer.py

Browse files
Files changed (1) hide show
  1. scorer.py +18 -20
scorer.py CHANGED
@@ -1,35 +1,33 @@
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"
 
 
1
  import random
2
 
3
+ def get_lead_score(stage, emails, meetings, close_gap, amount):
4
+ score_ranges = {
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
+ base = random.randint(*score_ranges.get(stage, (30, 60)))
12
+ bonus = 0
13
+ if close_gap < 10: bonus += 5
14
+ if emails + meetings > 4: bonus += 3
15
+ if amount > 100000: bonus += 5
16
+ return min(100, base + bonus)
17
 
18
+ def calculate_score(lead_score, emails, meetings, close_gap, amount):
19
+ engagement_weight = (emails * 2 + meetings * 3)
20
+ urgency = max(0, 10 - int(close_gap / 5))
21
+ size_factor = 5 if amount > 75000 else 0
22
+ deduction = random.randint(5, 15)
23
+ return min(100, lead_score + engagement_weight + urgency + size_factor - deduction)
24
 
25
  def calculate_confidence(score):
26
+ return round(min(0.95, 0.6 + score / 200), 2)
 
 
 
 
 
27
 
28
  def calculate_risk(score, confidence, emails, meetings):
29
+ if score > 85 and confidence > 0.9:
30
  return "Low"
31
+ if score < 55 or (emails + meetings) <= 2:
 
 
32
  return "High"
33
+ return "Medium"