Spaces:
Sleeping
Sleeping
Update
Browse files- app/core/engine.py +23 -31
app/core/engine.py
CHANGED
|
@@ -80,42 +80,34 @@ class DECI_Engine:
|
|
| 80 |
|
| 81 |
# === 2. SCORING POR SEÑAL ===
|
| 82 |
|
| 83 |
-
# 2.
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
# 2.2 CV Score (humanos > 0.30, ideal > 0.50)
|
| 92 |
-
if cv > 0.50:
|
| 93 |
-
s_cv = 1.0
|
| 94 |
-
elif cv > 0.30:
|
| 95 |
-
s_cv = 0.7
|
| 96 |
-
elif cv > 0.15:
|
| 97 |
-
s_cv = 0.3
|
| 98 |
-
else:
|
| 99 |
-
s_cv = 0.1
|
| 100 |
|
| 101 |
-
# 2.3 Mean IKL Score (
|
| 102 |
-
if
|
| 103 |
s_mean = 1.0
|
| 104 |
-
elif 40 <= mean_ikl <= 700:
|
| 105 |
-
s_mean = 0.5
|
| 106 |
else:
|
| 107 |
-
s_mean = 0.2
|
| 108 |
|
| 109 |
-
# 2.4 Correction Score (
|
| 110 |
-
if
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
| 114 |
else:
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
s_corrections = min(1.0, s_corrections)
|
| 119 |
|
| 120 |
# === 3. SCORE FINAL PONDERADO ===
|
| 121 |
final_score = (
|
|
|
|
| 80 |
|
| 81 |
# === 2. SCORING POR SEÑAL ===
|
| 82 |
|
| 83 |
+
# === 2. SCORING POR SEÑAL CONTINUO (Vertex Hardened Layer) ===
|
| 84 |
+
|
| 85 |
+
# 2.1 Entropy Score: Curva Gaussiana suave centrada en 0.70 (Evita saltos de hacha)
|
| 86 |
+
s_entropy = float(np.exp(-((entropy - 0.70) ** 2) / 0.12)))
|
| 87 |
+
s_entropy = max(0.05, min(1.0, s_entropy))
|
| 88 |
+
|
| 89 |
+
# 2.2 CV Score: Proporcional y continuo. Si el CV es robusto, el score escala orgánicamente
|
| 90 |
+
s_cv = float(np.clip(cv / 0.50, 0.1, 1.0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
+
# 2.3 Mean IKL Score: Penalización suave solo en los extremos (Demasiado rápido o lento)
|
| 93 |
+
if 80 <= mean_ikl <= 350:
|
| 94 |
s_mean = 1.0
|
|
|
|
|
|
|
| 95 |
else:
|
| 96 |
+
s_mean = float(np.clip(1.0 - abs(mean_ikl - 215) / 350, 0.2, 1.0))
|
| 97 |
|
| 98 |
+
# 2.4 Correction Score Dinámico (Mitigación de Falsos Positivos en Logins)
|
| 99 |
+
if corr_rate == 0:
|
| 100 |
+
if len(events) <= 20:
|
| 101 |
+
# Si la cadena es corta y no hay errores, evaluamos neutral (0.75) en vez de tratarlo como bot
|
| 102 |
+
s_corrections = 0.75
|
| 103 |
+
else:
|
| 104 |
+
# En textos largos, la ausencia total de errores sí es un patrón clásico de bot / LLM
|
| 105 |
+
s_corrections = 0.1
|
| 106 |
else:
|
| 107 |
+
# Si hay correcciones, aplicamos el mapeo continuo con el bonus de ráfaga de DeepSeek
|
| 108 |
+
s_corrections = 0.4 + (burst_ratio * 0.4) + (corr_rate * 2.0)
|
| 109 |
+
|
| 110 |
+
s_corrections = max(0.1, min(1.0, s_corrections))
|
| 111 |
|
| 112 |
# === 3. SCORE FINAL PONDERADO ===
|
| 113 |
final_score = (
|