MCPcopy Index your code
hub / github.com/benfred/implicit / test_fit_callback

Function test_fit_callback

tests/bpr_test.py:42–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40
41
42def test_fit_callback():
43 num_called = 0
44
45 def callback(epoch, elapsed, correct, skipped):
46 nonlocal num_called
47 num_called += 1
48
49 raw = [
50 [1, 1, 0, 1, 0, 0],
51 [0, 1, 1, 1, 0, 0],
52 [1, 0, 1, 0, 0, 0],
53 [1, 1, 0, 0, 0, 0],
54 [0, 0, 1, 1, 0, 1],
55 [0, 1, 0, 0, 0, 1],
56 [0, 0, 0, 0, 1, 1],
57 ]
58 model = BayesianPersonalizedRanking(iterations=5, use_gpu=False)
59
60 model.fit(csr_matrix(raw), show_progress=False, callback=callback)
61 assert num_called == model.iterations

Callers

nothing calls this directly

Calls 2

fitMethod · 0.95

Tested by

no test coverage detected