Count rejected samples and poll outcomes; pin rollback contract
Status showed accepted sample counts but not why learning was slow. Each room's model now counts samples it rejected (outliers, implausible inputs), persisted as an optional rejected_count key and shown as models.<room>.rejected_samples. Status also counts every poll outcome since start (sample_results_since_start). Add tests that a model in the exact shape 0.2.1 wrote restores with its coefficients, and that today's saved model still has the keys and types 0.2.1's restore code reads, so rolling back keeps the learned model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ace6d0061b
commit
43915ba810
4 files changed
+69
-14
No files matched your search
@@ -85,13 +85,17 @@ class ModelTests(unittest.TestCase):
|
||||
for a, b in zip(nominal.theta, delayed.theta):
|
||||
self.assertAlmostEqual(a, b)
|
||||
self.assertFalse(delayed.learn(20, 25, 5, .5, command=False))
|
||||
self.assertEqual((delayed.count, delayed.on_count, delayed.off_count), (1, 1, 0))
|
||||
self.assertFalse(delayed.learn(20, 20.1, 5, 1.5, command=False))
|
||||
self.assertEqual((delayed.count, delayed.on_count, delayed.off_count, delayed.rejected_count),
|
||||
(1, 1, 0, 2))
|
||||
self.assertEqual(m.Learner.from_dict(delayed.as_dict()).rejected_count, 2)
|
||||
|
||||
def test_corrupt_model_restore_is_atomic(self):
|
||||
for changes in ({'theta': [-1, .1, 0]}, {'p': [[-1, 0, 0], [0, 1, 0], [0, 0, 1]]},
|
||||
{'count': float('inf')}, {'count': '5'}, {'error_sum': float('nan')},
|
||||
{'off_count': 1}, {'theta': [float('nan'), 0, 0]}, {'p': None},
|
||||
{'p': [[1, .5, 0], [0, 1, 0], [0, 0, 1]]}):
|
||||
{'p': [[1, .5, 0], [0, 1, 0], [0, 0, 1]]}, {'rejected_count': -1},
|
||||
{'rejected_count': '3'}):
|
||||
with self.subTest(changes=changes):
|
||||
data = m.Learner().as_dict()
|
||||
data.update(changes)
|
||||
|
||||
Reference in new issue
Block a user