File size: 889 Bytes
ef16f91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import numpy as np

class TemporalConsistencyModel:
    """

    Simple temporal smoothing model to capture flicker and irregular changes.

    Works as a moving average + penalty for inconsistent transitions.

    """
    def __init__(self, window=5, alpha=0.7):
        self.window = window
        self.alpha = alpha
        self.history = []

    def update(self, score):
        self.history.append(score)
        if len(self.history) > self.window:
            self.history.pop(0)
        smoothed = np.mean(self.history)
        # penalize high oscillations
        flicker_penalty = np.std(self.history)
        final = (self.alpha * smoothed) - (0.5 * flicker_penalty)
        return np.clip(final, 0, 1)


####################################################################################################################################################3