Update scorer.py
Browse files
scorer.py
CHANGED
@@ -1,35 +1,33 @@
|
|
1 |
import random
|
2 |
|
3 |
-
def get_lead_score(stage, emails, meetings, close_gap):
|
4 |
-
|
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 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
|
16 |
-
def calculate_score(lead_score, emails, meetings, close_gap):
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
20 |
|
21 |
def calculate_confidence(score):
|
22 |
-
|
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 >
|
31 |
return "Low"
|
32 |
-
|
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"
|