MCPcopy Create free account
hub / github.com/Luce-Org/lucebox-hub / eval_hit_rate

Function eval_hit_rate

scripts/train_predictor.py:555–563  ·  view source on GitHub ↗
(logits_np, E, k)

Source from the content-addressed store, hash-verified

553 print(f"Training for {epochs} epochs...\n")
554
555 def eval_hit_rate(logits_np, E, k):
556 preds = np.argsort(-logits_np, axis=1)[:, :k]
557 hits = 0
558 total = 0
559 for i in range(len(E)):
560 actual = set(int(x) for x in E[i] if x >= 0) # drop -1 padding
561 hits += len(actual & set(preds[i].tolist()))
562 total += len(actual) # real experts only, not padded K
563 return hits, total
564
565 def run_eval():
566 model.eval()

Callers 1

train_and_evaluateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected