Update statistics for a feature dimension Args: feature_name: Name of the feature dimension value: New value to incorporate into stats
(self, feature_name: str, value: float)
| 2170 | logger.debug("Diversity cache invalidated") |
| 2171 | |
| 2172 | def _update_feature_stats(self, feature_name: str, value: float) -> None: |
| 2173 | """ |
| 2174 | Update statistics for a feature dimension |
| 2175 | |
| 2176 | Args: |
| 2177 | feature_name: Name of the feature dimension |
| 2178 | value: New value to incorporate into stats |
| 2179 | """ |
| 2180 | if feature_name not in self.feature_stats: |
| 2181 | self.feature_stats[feature_name] = { |
| 2182 | "min": value, |
| 2183 | "max": value, |
| 2184 | "values": [], # Keep recent values for percentile calculation if needed |
| 2185 | } |
| 2186 | |
| 2187 | stats = self.feature_stats[feature_name] |
| 2188 | stats["min"] = min(stats["min"], value) |
| 2189 | stats["max"] = max(stats["max"], value) |
| 2190 | |
| 2191 | # Keep recent values for more sophisticated scaling methods |
| 2192 | stats["values"].append(value) |
| 2193 | if len(stats["values"]) > 1000: # Limit memory usage |
| 2194 | stats["values"] = stats["values"][-1000:] |
| 2195 | |
| 2196 | def _scale_feature_value(self, feature_name: str, value: float) -> float: |
| 2197 | """ |
no outgoing calls
no test coverage detected