fix(bot-detector): make scoring functions public (remove underscore prefix)
compute_shap_top_features, build_reason, cluster_anomalies renamed from private (_prefixed) to public to match pipeline.py imports. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@ -186,7 +186,7 @@ def normalize_scores(scores: np.ndarray) -> np.ndarray:
|
||||
# A4 — EXPLAINABILITÉ SHAP
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
def _compute_shap_top_features(model, X: pd.DataFrame, features: list,
|
||||
def compute_shap_top_features(model, X: pd.DataFrame, features: list,
|
||||
n_top: int = 5) -> list:
|
||||
"""
|
||||
Calcule les valeurs SHAP pour chaque ligne de X et retourne les n_top features
|
||||
@ -216,7 +216,7 @@ def _compute_shap_top_features(model, X: pd.DataFrame, features: list,
|
||||
return [{}] * len(X)
|
||||
|
||||
|
||||
def _build_reason(name: str, row: pd.Series, shap_top: dict) -> str:
|
||||
def build_reason(name: str, row: pd.Series, shap_top: dict) -> str:
|
||||
"""Construit le champ reason enrichi avec le top SHAP ou les métriques clés."""
|
||||
# Utilise le score brut pour l'affichage (plus interprétable que le score normalisé)
|
||||
score = round(float(row.get('raw_anomaly_score', row.get('anomaly_score', 0))), 3)
|
||||
@ -233,7 +233,7 @@ def _build_reason(name: str, row: pd.Series, shap_top: dict) -> str:
|
||||
# A8 — CLUSTERING COMPORTEMENTAL DES ANOMALIES
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
def _cluster_anomalies(anomalies: pd.DataFrame, features: list,
|
||||
def cluster_anomalies(anomalies: pd.DataFrame, features: list,
|
||||
ae_model=None) -> pd.DataFrame:
|
||||
"""A8 : Applique HDBSCAN (ou DBSCAN en fallback) sur les features normalisées des anomalies.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user