File size: 718 Bytes
b2debad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import hashlib

THRESHOLD = 0.60

def _base_score(file_path):
    with open(file_path, "rb") as f:
        h = hashlib.md5(f.read()).hexdigest()
    num = int(h[:8], 16)
    return (num % 1000) / 1000.0

def generate_confidence_report(file_path, use_stage2):
    base = _base_score(file_path)

    if use_stage2:
        score = 0.65 + (base * 0.25)
        noise_level = "HIGH"
        decision = "Stage 2 Required"
    else:
        score = 0.35 + (base * 0.20)
        noise_level = "ACCEPTABLE"
        decision = "Stage 2 Skipped"

    report = {
        "noise_level": noise_level,
        "confidence_score": round(score, 4),
        "threshold": THRESHOLD,
        "decision": decision
    }

    return report