forked from tracel-ai/burn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add precision classification metric (tracel-ai#2293)
* Implement confusion matrix and precision, first draft * Implement confusion matrix * format :D * add agg type to cm, reformat debug representation add testing. improve dummy classification input. reformat precision and add test with dummy data. * formating and tiny refactor * add ClassificationMetric trait, rename variables and types, move test module to lib.rs make precision a classification metric. * change unwrap to expect * update book * remove unused code * changes to make reusing code easier * format :D * change to static data tests * remove classification metric trait, add auxiliary code for classification input, clarify descriptions, remove dead code, rename some objects * move classification objects to classification.rs, use rstest, remove approx lib and use tensordata asserts, move aggregate and average functions to ConfusionStats implementation * review docstring, add top_k for multiclass tasks. * move class averaging and metric computation to metric implementation, make dummy data more predictable and add tests for top_k > 1 * change struct and var names * rename params, enforce nonzero for top_k param, optimize one_hot for case num_class = 1, reformat dummy data, make use of derive(new) for metric init. * add adaptor por classification input, correct one hot function * define default for ClassReduction, derive new for Precision metric with class_reduction as default and new setter implementation, move NonZerousize boundary to confusion_stats * expose PrecisionMetric, change metric initialization * check one_hot input tensor has more than 1 classes and correct it's implementation, deal with classification output with 1 class, make macro average default, expose ClassReduction type and split precision implementations by classification type * implement adaptor for MultilabelClassificationOutput and ClassificationInput * change with_top_k to take usize * Add precision config for binary, multiclass and multilabel * Fix dummy_classification_input * make PrecisionMetric public --------- Co-authored-by: Tiago Sanona <[email protected]> Co-authored-by: Guillaume Lagrange <[email protected]>
- Loading branch information
1 parent
2132d47
commit 76e67bf
Showing
10 changed files
with
694 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// The reduction strategy for classification metrics. | ||
#[derive(Copy, Clone, Default)] | ||
pub enum ClassReduction { | ||
/// Computes the statistics over all classes before averaging | ||
Micro, | ||
/// Computes the statistics independently for each class before averaging | ||
#[default] | ||
Macro, | ||
} |
Oops, something went wrong.