From f4e15eb6e9ab9734954ccb339d55a551c08dc09e Mon Sep 17 00:00:00 2001 From: maffettone Date: Wed, 13 Dec 2023 13:55:08 -0800 Subject: [PATCH] FIX: report and knowledge cache --- pdf_agents/sklearn.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pdf_agents/sklearn.py b/pdf_agents/sklearn.py index e8cd0f5..e21822c 100644 --- a/pdf_agents/sklearn.py +++ b/pdf_agents/sklearn.py @@ -44,6 +44,15 @@ def tell(self, x, y): doc["absolute_position_offset"] = self._motor_origins return doc + def report(self, **kwargs): + arr = np.array(self.observable_cache) + self.model.fit(arr) + return dict( + cluster_centers=self.model.cluster_centers_, + cache_len=len(self.independent_cache), + latest_data=self.tell_cache[-1], + ) + @classmethod def hud_from_report( cls, @@ -151,8 +160,8 @@ def server_registrations(self) -> None: def tell(self, x, y): """A tell that adds to the local discrete knowledge cache, as well as the standard caches""" - self.knowledge_cache.add(make_hashable(discretize(x, self.motor_resolution))) doc = super().tell(x, y) + self.knowledge_cache.add(make_hashable(discretize(doc["independent_variable"], self.motor_resolution))) doc["background"] = self.background return doc