Create vendor_scoring.py
Browse files- vendor_scoring.py +37 -0
vendor_scoring.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def calculate_vendor_score(delay_percent, qa_incidents, safety_compliance, feedback_score):
|
| 2 |
+
# Weighted scoring logic (example weights as per PMO agreement)
|
| 3 |
+
quality_weight = 0.4
|
| 4 |
+
timeliness_weight = 0.3
|
| 5 |
+
safety_weight = 0.2
|
| 6 |
+
communication_weight = 0.1
|
| 7 |
+
|
| 8 |
+
# Calculate individual scores (scale to 100)
|
| 9 |
+
quality_score = (1 - qa_incidents / 10) * 100 # Example: Fewer incidents = higher score
|
| 10 |
+
timeliness_score = (1 - delay_percent / 100) * 100 # Example: Less delay = higher score
|
| 11 |
+
safety_score = safety_compliance * 100 # Compliance % directly maps to score
|
| 12 |
+
communication_score = feedback_score * 20 # Feedback (1-5 scale) to 100
|
| 13 |
+
|
| 14 |
+
# Final weighted score
|
| 15 |
+
final_score = (
|
| 16 |
+
quality_score * quality_weight +
|
| 17 |
+
timeliness_score * timeliness_weight +
|
| 18 |
+
safety_score * safety_weight +
|
| 19 |
+
communication_score * communication_weight
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
# Trend detection (dummy logic for now, can enhance later)
|
| 23 |
+
trend_deviation = 0 # Placeholder (compare with previous month if available)
|
| 24 |
+
|
| 25 |
+
# Alert flag (if final score < 60, flag as risk)
|
| 26 |
+
alert_flag = final_score < 60
|
| 27 |
+
|
| 28 |
+
# JSON response
|
| 29 |
+
return {
|
| 30 |
+
"quality_score": round(quality_score, 2),
|
| 31 |
+
"timeliness_score": round(timeliness_score, 2),
|
| 32 |
+
"safety_score": round(safety_score, 2),
|
| 33 |
+
"communication_score": round(communication_score, 2),
|
| 34 |
+
"final_score": round(final_score, 2),
|
| 35 |
+
"trend_deviation": trend_deviation,
|
| 36 |
+
"alert_flag": alert_flag
|
| 37 |
+
}
|