hezar.metrics.accuracy module

class hezar.metrics.accuracy.Accuracy(config: AccuracyConfig, **kwargs)[source]

Bases: Metric

Accuracy metric for numeric arrays backed by Scikit-learn’s accuracy_score.

Parameters:
  • config (AccuracyConfig) – Metric config object

  • **kwargs – Extra config parameters passed as kwargs to update the config

compute(predictions=None, targets=None, normalize=None, sample_weight=None, n_decimals=None, output_keys=None)[source]

Compute the accuracy score for the given predictions against targets.

Parameters:
  • predictions – A list of prediction labels

  • targets – A list of ground truth labels

  • normalize – Whether to normalize the inputs or not

  • sample_weight – Sample weight

  • n_decimals – Floating point decimals for the final score

  • output_keys – Filter the output keys

Returns:

A dictionary of the metric results

required_backends: List[str | Backends] = [Backends.SCIKIT]
class hezar.metrics.accuracy.AccuracyConfig(objective: str = 'maximize', output_keys: tuple = ('accuracy',), n_decimals: 'int' = 4, normalize: bool = True, sample_weight: Iterable[float] = None)[source]

Bases: MetricConfig

name: str = 'accuracy'
normalize: bool = True
objective: str = 'maximize'
output_keys: tuple = ('accuracy',)
sample_weight: Iterable[float] = None