class_docstr: Renders customizable statistics on top of event logs.
  
  This renderer provides a central rendering functionality for event log data. Elementary customizability
  is offered (e.g. simple aggregation etc.). For more complex operations with the data, it is advised
  to work with the TSV event logs directly.
class_docstr_tok: ["Renders","customizable","statistics","on","top","of","event","logs",".","This","renderer","provides","a","central","rendering","functionality","for","event","log","data",".","Elementary","customizability","is","offered","(","e.g",".","simple","aggregation","etc.",")",".","For","more","complex","operations","with","the","data",",","it","is","advised","to","work","with","the","TSV","event","logs","directly","."]
docstr: Render event stats from episode log of currently running episode.
  
  Creates a new figure if needed.
  
  :param episode_event_log: Episode event log to render events from
  :param event_name: Name of the even the even log corresponds to
  :param metric_name: Metric to use (one of the event attributes, e.g. "n_items" -- depends on the event type)
  :param aggregation_func: Optionally, specifies how to aggregate the metric on step level, i.e. when there
                           are multiple same events dispatched during the same step.
  :param group_by: Optionally, another of event attributes to group by on the step level (e.g. "product_id")
  :param post_processing_func: Optionally, a function to post-process the data ("cumsum" is often used)
docstr_tok: ["Render","event","stats","from","episode","log","of","currently","running","episode",".","Creates","a","new","figure","if","needed",".",":","param","episode_event_log",":","Episode","event","log","to","render","events","from",":","param","event_name",":","Name","of","the","even","the","even","log","corresponds","to",":","param","metric_name",":","Metric","to","use","(","one","of","the","event","attributes",",","e.g",".","``","n_items","''","--","depends","on","the","event","type",")",":","param","aggregation_func",":","Optionally",",","specifies","how","to","aggregate","the","metric","on","step","level",",","i.e",".","when","there","are","multiple","same","events","dispatched","during","the","same","step",".",":","param","group_by",":","Optionally",",","another","of","event","attributes","to","group","by","on","the","step","level","(","e.g",".","``","product_id","''",")",":","param","post_processing_func",":","Optionally",",","a","function","to","post-process","the","data","(","``","cumsum","''","is","often","used",")"]
code: def render_current_episode_stats(
      self,
      episode_event_log: EpisodeEventLog,
      event_name: str = "BaseEnvEvents.reward",
      metric_name: str = "value",
      aggregation_func: Optional[Union[str, Callable]] = None,
      group_by: str = None,
      post_processing_func: Optional[Union[str, Callable]] = "cumsum",
  ):
      """
      Render event stats from episode log of currently running episode.
  
      Creates a new figure if needed.
  
      :param episode_event_log: Episode event log to render events from
      :param event_name: Name of the even the even log corresponds to
      :param metric_name: Metric to use (one of the event attributes, e.g. "n_items" -- depends on the event type)
      :param aggregation_func: Optionally, specifies how to aggregate the metric on step level, i.e. when there
                               are multiple same events dispatched during the same step.
      :param group_by: Optionally, another of event attributes to group by on the step level (e.g. "product_id")
      :param post_processing_func: Optionally, a function to post-process the data ("cumsum" is often used)
      """
  
      assert (
          len(episode_event_log.step_event_logs) > 0
      ), "rendered episode log cannot be empty"
  
      events = []
      for step_event_log in episode_event_log.step_event_logs:
          for event_record in step_event_log.events:
              if (
                  event_name
                  != event_record.interface_method.__qualname__
              ):
                  continue
              assert (
                  metric_name in event_record.attributes.keys()
              ), "metric by must be present in event attributes"
              assert (
                  group_by is None
                  or group_by in event_record.attributes.keys()
              ), "group by must be none or present in event attributes"
  
              events.append(
                  [
                      episode_event_log.episode_id,
                      step_event_log.env_time,
                      event_record.attributes[metric_name],
                  ]
              )
  
      df = pd.DataFrame(
          events, columns=["episode_id", "env_time", metric_name]
      )
  
      if self.figure is None:
          self.figure = plt.figure()
      else:
          plt.figure(self.figure.number)
          plt.clf()
      self.render_timeline_stat(
          df,
          event_name,
          metric_name,
          aggregation_func,
          group_by,
          post_processing_func,
      )
      plt.draw()
      plt.pause(0.1)
  
file_path: maze/maze/core/rendering/events_stats_renderer.py
imports: import re
  from typing import Optional, Callable, Union
  import matplotlib.pyplot
  import pandas
  import seaborn
  from maze.core.log_events.episode_event_log import EpisodeEventLog
label_desc: Use image node_id 3 for calling the EventStatsRenderer obj's underlying member method code with example usage: obj.render_current_episode_stats(episode_event_log, event_name, metric_name, aggregation_func, group_by, post_processing_func) without return types