الفصل 1: مراقبة أداء النموذج
المقاييس الرئيسية للمراقبة
| الفئة | المقاييس |
|---|---|
| جودة النموذج | الدقة، AUC، F1، الدقة، الاسترجاع |
| زمن الاستجابة | أوقات الاستجابة P50، P95، P99 |
| معدل النقل | الطلبات في الثانية |
| الأخطاء | معدل الخطأ، أنواع الأخطاء |
| الأعمال | تأثير الإيرادات، معدلات التحويل |
مقاييس Prometheus
from prometheus_client import Counter, Histogram, Gauge
# عداد التنبؤات
predictions = Counter(
'model_predictions_total',
'Total predictions',
['model_version', 'prediction_class']
)
# مخطط زمني لزمن الاستجابة
latency = Histogram(
'model_prediction_latency_seconds',
'Prediction latency',
buckets=[0.01, 0.05, 0.1, 0.25, 0.5, 1.0]
)
# مقياس دقة النموذج (يتم تحديثه دورياً)
accuracy = Gauge(
'model_accuracy_current',
'Current model accuracy'
)
@app.post("/predict")
async def predict(request: PredictionRequest):
with latency.time():
result = model.predict(request.features)
predictions.labels(model_version="2.1.0", prediction_class=str(result)).inc()
return {"prediction": result}
التالي: الفصل 2: اكتشاف الانحراف