Create model.py
Browse files
model.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def score_opportunity(data):
|
2 |
+
# Fake scoring logic based on weighted sum
|
3 |
+
raw_score = (
|
4 |
+
0.3 * (data['lead_score'] or 0) +
|
5 |
+
0.2 * (data['email_count'] or 0) +
|
6 |
+
0.2 * (data['meeting_count'] or 0) -
|
7 |
+
0.1 * (data['close_date_gap'] or 0)
|
8 |
+
)
|
9 |
+
raw_score += 0.1 * (1 if data['stage'] == "Negotiation" else 0)
|
10 |
+
raw_score = max(0, min(100, round(raw_score)))
|
11 |
+
|
12 |
+
# Risk classification
|
13 |
+
if raw_score >= 75:
|
14 |
+
risk = "Low"
|
15 |
+
recommendation = "High chance of closing. Prioritize this deal."
|
16 |
+
elif raw_score >= 50:
|
17 |
+
risk = "Medium"
|
18 |
+
recommendation = "Moderate potential. Consider a follow-up soon."
|
19 |
+
else:
|
20 |
+
risk = "High"
|
21 |
+
recommendation = "Low potential. Reassess engagement or de-prioritize."
|
22 |
+
|
23 |
+
return {
|
24 |
+
"score": raw_score,
|
25 |
+
"risk": risk,
|
26 |
+
"recommendation": recommendation
|
27 |
+
}
|