NumericMetric class

An EvaluationMetric with a numeric value.

Commonly used for scores in a defined range, such as 0.0–1.0 or 1–5.

Inheritance
Available extensions
Annotations
  • @Source(name: 'NumericMetric.cs', namespace: 'Microsoft.Extensions.AI.Evaluation', repository: 'dotnet/extensions', path: 'src/Libraries/Microsoft.Extensions.AI.Evaluation/')

Constructors

NumericMetric(String name, {double? value, String? reason})
Creates a NumericMetric with the given name, optional value, and optional reason.

Properties

context Map<String, EvaluationContext>?
Contexts considered by the evaluator when producing this metric.
getter/setter pairinherited
diagnostics List<EvaluationDiagnostic>?
Diagnostic messages associated with this metric.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
interpretation EvaluationMetricInterpretation?
Interpretation of whether this result is good or bad, passed or failed.
getter/setter pairinherited
metadata Map<String, String>?
Arbitrary string metadata associated with this metric.
getter/setter pairinherited
name String
The name of this metric.
getter/setter pairinherited
reason String?
Optional commentary on the metric result.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value double?
The numeric value of this metric.
getter/setter pair

Methods

addDiagnostic(EvaluationDiagnostic diagnostic) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Adds diagnostic to EvaluationMetric.diagnostics.
addDiagnostics(Iterable<EvaluationDiagnostic> newDiagnostics) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Adds all newDiagnostics to EvaluationMetric.diagnostics.
addOrUpdateChatMetadata(ChatResponse response, {Duration? duration}) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Records model ID and token counts from a ChatResponse as metadata.
addOrUpdateContext(EvaluationContext ctx) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Adds or replaces ctx in EvaluationMetric.context by name.
addOrUpdateContextAll(Iterable<EvaluationContext> contexts) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Adds or replaces multiple contexts by name.
addOrUpdateDurationMetadata(Duration duration) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Records the evaluation duration in milliseconds as metadata.
addOrUpdateMetadata(String name, String value) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Sets a metadata entry.
interpret() EvaluationMetricInterpretation

Available on NumericMetric, provided by the NumericMetricInterpretationExtensions extension

Interprets a 0.0–1.0 score (NLP metrics like BLEU/F1/GLEU).
interpretContentHarmScore() EvaluationMetricInterpretation

Available on NumericMetric, provided by the NumericMetricInterpretationExtensions extension

Interprets a 0–7 severity scale used by content safety evaluators.
interpretScore() EvaluationMetricInterpretation

Available on NumericMetric, provided by the NumericMetricInterpretationExtensions extension

Interprets a 1–5 score (quality evaluators like Coherence, Fluency).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
tryParseEvaluationResponseWithTags(ChatResponse response, Duration duration) bool

Available on NumericMetric, provided by the NumericMetricInterpretationExtensions extension

Parses a tagged evaluation response (XML <S0>, <S1>, <S2> format).

Operators

operator ==(Object other) bool
The equality operator.
inherited