fix: graphe calculation
This commit is contained in:
@@ -903,6 +903,8 @@ def analyze_event(body: AnalyzeRequest):
|
||||
inputs[input_id] = round(raw, 4)
|
||||
elif src == "surprise" and event.get("surprise_pct") is not None:
|
||||
raw = float(event["surprise_pct"])
|
||||
if cfg.get("normalize"):
|
||||
raw = raw / 100
|
||||
node_range = cfg.get("range")
|
||||
if node_range and len(node_range) == 2:
|
||||
lo, hi = float(node_range[0]), float(node_range[1])
|
||||
@@ -1224,19 +1226,15 @@ def _run_auto_analysis(event: dict, template_id: int) -> dict:
|
||||
pass
|
||||
if sp is not None:
|
||||
raw = float(sp)
|
||||
# normalize:true in node cfg → divide by 100 (coefficients calibrated for fraction)
|
||||
if cfg.get("normalize"):
|
||||
raw = raw / 100
|
||||
node_range = cfg.get("range")
|
||||
if src == "surprise_bps":
|
||||
if node_range and len(node_range) == 2:
|
||||
lo, hi = float(node_range[0]), float(node_range[1])
|
||||
inputs[input_id] = round(max(lo, min(hi, raw)), 4)
|
||||
else:
|
||||
inputs[input_id] = round(raw, 4)
|
||||
if node_range and len(node_range) == 2:
|
||||
lo, hi = float(node_range[0]), float(node_range[1])
|
||||
inputs[input_id] = round(max(lo, min(hi, raw)), 4)
|
||||
else:
|
||||
if node_range and len(node_range) == 2:
|
||||
lo, hi = float(node_range[0]), float(node_range[1])
|
||||
inputs[input_id] = round(max(lo, min(hi, raw)), 4)
|
||||
else:
|
||||
inputs[input_id] = round(raw, 4)
|
||||
inputs[input_id] = round(raw, 4)
|
||||
|
||||
elif src == "impact_score_scaled" and event.get("impact_score") is not None:
|
||||
inputs[input_id] = float(event["impact_score"]) / 10.0
|
||||
|
||||
@@ -34,6 +34,7 @@ interface InputMapping {
|
||||
field?: string
|
||||
unit?: string
|
||||
range?: number[]
|
||||
normalize?: boolean
|
||||
}
|
||||
interface DataSources {
|
||||
prices: { key: string; label: string }[]
|
||||
@@ -1598,6 +1599,15 @@ function TabEditor({ initialId }: { initialId?: number | null }) {
|
||||
</select>
|
||||
</div>
|
||||
</>)}
|
||||
{/* Normalisation /100 — visible uniquement pour sources surprise */}
|
||||
{mapping.source === 'surprise' && (
|
||||
<label className="flex items-center gap-2 cursor-pointer mt-1">
|
||||
<input type="checkbox" checked={!!mapping.normalize}
|
||||
onChange={e => updateMapping({ normalize: e.target.checked })}
|
||||
className="accent-cyan-500" />
|
||||
<span className="text-xs text-slate-400">Normaliser ÷100 <span className="text-slate-600">(coefs calibrés en fraction, pas en %)</span></span>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
})()}
|
||||
|
||||
Reference in New Issue
Block a user