fix: enforce force reductions to add metrics in their own namespace #4506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4498
This pull request modifies the
set_persist_metrics()
function inlearner.h
to enforce that force reductions can only add metrics in their own namespace. The output dictionary for metrics is now a dictionary of dictionaries, where each sub-dictionary contains the metrics for a single learner. The key for each sub-dictionary is the learner's name.Here are the steps taken to enforce this:
std::map<std::string, std::map<std::string, float>> output_metrics; output_metrics[learner_name] = learner_metrics;
fn_ptr(*data, output_metrics);
Putting it all together, here's the full implementation:
This currently fails as
metrics
is not an iterable object (which makes sense from its definition). I am currently trying to figure out a workaround.@lalo Can you review this and suggest what I could do instead of Step 2? I would love to learn from you.