Feature: Allow custom metrics via a configuration file#19
Open
fehret wants to merge 4 commits into
Open
Conversation
- changed metrics_factory and added custom_metrics_factory to read the file and add the specified metrics - moved optuna files to own subfolder and create metrics folder to differentiate more easily - added cli option for metric file path - added example config and tests for custom metrics - updated docs to reflect changes and metric specification
- remove argmax before metrics calculation, as per torchmetrics docs, the package inserts the argmax where necessary - AUROC e.g. does need logits and not class labels, so this does not change anything about current metrics but enables the usage of more
- refactored and unified the instantiation of Metrics classes to allow custom updates in classification as well - applied fix for ConfusionMatrix (argmax before update)
- some merge seems to have delted them automatically, add them again to allow for good contribution practices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is the current behavior? (You can also link to an open issue here)
Currently the metrics for the different tasks are hardcoded and not easily extendable
What is the new behavior (if this is a feature change)?
User can create a yaml-conf file that details the torchmetrics-class name, an alias, and possible parameters for training, validation and testing.
Conf file (if provided using the cli option) gets parsed and the metrics resolved and instantiated by a new
CustomMetricsFactoryclassCustom ones are added to the collection of the metrics without influencing the default metrics
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No. The default metrics are exactly the hardcoded ones from before the PR, so unless
--metric-confis given, the behavior stays the sameOther information:
Refactored
MetricsFactoryto no longer rely on Helper-functions but only on classes for both language and classification tasks, since some metrics require special handling when updated (i.e.ConfusionMatrix&Perplexity).Moved the optuna configs into their own folder & created metrics config folder.
Added tests for metric loading and correct updating of
ConfusionMatrix.