Sanjayraju30's picture
Create model.py
579b95c verified
raw
history blame contribute delete
885 Bytes
def score_opportunity(data):
# Fake scoring logic based on weighted sum
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)
)
raw_score += 0.1 * (1 if data['stage'] == "Negotiation" else 0)
raw_score = max(0, min(100, round(raw_score)))
# Risk classification
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 engagement or de-prioritize."
return {
"score": raw_score,
"risk": risk,
"recommendation": recommendation
}