Enhancing TextClassificationEvaluator
to Support Averaged Metrics
#596
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.
Enhancing
TextClassificationEvaluator
to Support Averaged MetricsDescription
Previously, when creating an
Evaluator
object and using thecompute
method, it was not possible to specify theaverage
parameter for selected metrics.This limitation made the
compute
method ofTextClassificationEvaluator
applicable only for binary classification scenarios.To address this, we have reworked the
Evaluator
andTextClassificationEvaluator
classes to allow the inclusion of these parameters, with respect to the functionalities of the classes that inherit fromEvaluator
.Originally, in the
Evaluator
class, a staticMETRIC_KWARGS
attribute was initialized as empty and unpacked during thecompute_metric
usage, which was largely ineffective and did not allow for the control of metric configurations. Here is a snapshot of the previous implementation:Modifications
We introduced a new argument
metrics_kwargs
, utilized inprepare_metric
,compute_metric
, and finally incompute
.This enhancement allows for the dynamic specification of metric parameters in the
compute
method of anEvaluationModule
.Now, multi-class classification can be evaluated as follows:
The code has been reviewed and is fully functional, developed in compliance with the flake8 plugin, ensuring clean and maintainable code.
Contributors