إنتقل إلى المحتوى الرئيسي

الفصل 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: اكتشاف الانحراف