Sanjayraju30's picture
Update model.py
4f47b69 verified
raw
history blame
966 Bytes
# model.py
def score_opportunity(data):
# Weighted score calculation
raw_score = (
0.3 * (data['lead_score'] or 0) +
0.2 * (data['email_count'] or 0) +
0.2 * (data['meeting_count'] or 0) -
0.1 * (data['close_date_gap'] or 0)
)
# Extra points if at negotiation stage
if data['stage'] == "Negotiation":
raw_score += 10
# Clip score between 0–100
raw_score = max(0, min(100, round(raw_score)))
# Risk classification logic
if raw_score >= 75:
risk = "Low"
recommendation = "✅ High chance of closing. Prioritize this deal."
elif raw_score >= 50:
risk = "Medium"
recommendation = "🔁 Moderate potential. Consider a follow-up soon."
else:
risk = "High"
recommendation = "⚠️ Low potential. Reassess or de-prioritize."
return {
"score": raw_score,
"risk": risk,
"recommendation": recommendation
}