feat(tracker): ✨ Enhance AimTracker to support Distribution logging for numeric and categorical variables#145
Conversation
…or numeric and categorical variables This commit introduces significant improvements to the `AimTracker` class, enabling it to log agent variables as `Distribution` objects for numeric types and as frequency statistics for categorical types. The changes include new configuration options for `distribution_bin_count` and `log_categorical_stats`, enhancing flexibility in data tracking. Additionally, comprehensive tests are added to ensure correct functionality across various data types and configurations, improving the robustness of the tracking system.
📝 WalkthroughWalkthroughThe AimTracker is enhanced to support Aim Distribution objects with new configuration parameters (distribution_bin_count and log_categorical_stats) and significantly expanded agent variable logging that handles multiple data types including booleans, numerics, and categorical strings with specialized metrics. Changes
Sequence DiagramsequenceDiagram
participant Client as Client Code
participant Tracker as AimTracker
participant Processor as Data Processor
participant Aim as Aim (Run/Distribution)
Client->>Tracker: log_agent_vars(data_dict, step)
activate Tracker
Tracker->>Processor: Process each variable
activate Processor
alt Numeric Type
Processor->>Processor: Convert to Series/check length
alt Multiple Values
Processor->>Aim: Log as Distribution
else Single Value
Processor->>Aim: Log as scalar
end
else Boolean Type
Processor->>Processor: Convert to 0/1, compute stats
Processor->>Aim: Log Distribution + true_count, true_ratio
else Categorical Type
alt log_categorical_stats enabled
Processor->>Processor: value_counts, sanitize names
Processor->>Aim: Log unique_count, most_common_count, ratios, per-category counts
end
else Other Type
Processor->>Processor: Attempt numeric conversion
alt Conversion Success
Processor->>Aim: Log as Distribution or scalar
end
end
deactivate Processor
deactivate Tracker
Note over Aim: All metrics stored with step parameter
Estimated code review effort🎯 4 (Complex) | ⏱️ ~65 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This commit introduces significant improvements to the
AimTrackerclass, enabling it to log agent variables asDistributionobjects for numeric types and as frequency statistics for categorical types. The changes include new configuration options fordistribution_bin_countandlog_categorical_stats, enhancing flexibility in data tracking. Additionally, comprehensive tests are added to ensure correct functionality across various data types and configurations, improving the robustness of the tracking system.Summary by CodeRabbit
New Features
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.