Denisijcu commited on
Commit
f2b86aa
·
verified ·
1 Parent(s): b092d11
Files changed (1) hide show
  1. 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.1 Entropy Score (zona Goldilocks 0.50-0.85)
84
- if 0.50 <= entropy <= 0.85:
85
- s_entropy = 1.0
86
- elif 0.35 <= entropy <= 0.95:
87
- s_entropy = 0.5
88
- else:
89
- s_entropy = max(0.05, min(0.5, entropy))
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 (velocidad)
102
- if 60 <= mean_ikl <= 500:
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 (con bonus por ráfaga)
110
- if 0.02 <= corr_rate <= 0.15:
111
- s_corrections = 0.5 + (burst_ratio * 0.5)
112
- elif corr_rate > 0:
113
- s_corrections = 0.3 + (burst_ratio * 0.2)
 
 
 
114
  else:
115
- s_corrections = 0.05 # Sin correcciones = bot
116
-
117
- # Limitar el score de correcciones
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 = (