Skip to content

Commit

Permalink
FIX: report and knowledge cache
Browse files Browse the repository at this point in the history
  • Loading branch information
maffettone committed Dec 13, 2023
1 parent a18b920 commit f4e15eb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pdf_agents/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit f4e15eb

Please sign in to comment.