MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / update

Method update

uncommon_route/learning/weights.py:18–33  ·  view source on GitHub ↗
(
        self,
        predictions: list[int | None],
        abstained: list[bool],
        actual_tier: int,
    )

Source from the content-addressed store, hash-verified

16 return list(self._weights)
17
18 def update(
19 self,
20 predictions: list[int | None],
21 abstained: list[bool],
22 actual_tier: int,
23 ) -> None:
24 lr = max(0.01, 0.1 / (1 + self._update_count * 0.001))
25 self._update_count += 1
26 for i in range(len(self._weights)):
27 if abstained[i]:
28 continue
29 if predictions[i] == actual_tier:
30 self._weights[i] *= (1 + lr)
31 else:
32 self._weights[i] *= (1 - lr)
33 self._normalize()
34
35 def _normalize(self) -> None:
36 total = sum(self._weights)

Callers 15

test_update_count_tracksFunction · 0.95
userFunction · 0.45
run_cliFunction · 0.45
_rowFunction · 0.45
_empty_snapshotMethod · 0.45
keyed_modelsMethod · 0.45
_on_eventMethod · 0.45
model_countMethod · 0.45

Calls 1

_normalizeMethod · 0.95

Tested by 7

test_update_count_tracksFunction · 0.76
run_cliFunction · 0.36
_rowFunction · 0.36