Class LabelSequenceEvaluation

java.lang.Object
org.tribuo.classification.sequence.LabelSequenceEvaluation
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.provenance.Provenancable<EvaluationProvenance>, SequenceEvaluation<Label>

public class LabelSequenceEvaluation extends Object implements SequenceEvaluation<Label>
A class that can be used to evaluate a sequence label classification model element wise on a given set of data.
  • Constructor Details

    • LabelSequenceEvaluation

      protected LabelSequenceEvaluation(Map<MetricID<Label>,Double> results, LabelMetric.Context ctx, EvaluationProvenance provenance)
      Constructs a LabelSequenceEvaluation using the supplied parameters.
      Parameters:
      results - The metric values.
      ctx - The context.
      provenance - The evaluation provenance.
  • Method Details

    • getPredictions

      public List<Prediction<Label>> getPredictions()
      Gets the flattened predictions.
      Returns:
      The flattened predictions.
    • getConfusionMatrix

      public ConfusionMatrix<Label> getConfusionMatrix()
      Gets the confusion matrix backing this evaluation.
      Returns:
      The confusion matrix.
    • asMap

      public Map<MetricID<Label>,Double> asMap()
      Description copied from interface: SequenceEvaluation
      Get a map of all the metrics stored in this evaluation. The keys are metric id's and the values are their corresponding computed results.
      Specified by:
      asMap in interface SequenceEvaluation<Label>
      Returns:
      a map of all stored results
    • confusion

      public double confusion(Label predictedLabel, Label trueLabel)
      Note: confusion is not stored in the underlying map, so it won't show up in aggregation.
      Parameters:
      predictedLabel - The predicted label.
      trueLabel - The true label.
      Returns:
      The number of times that predictedLabel was predicted for trueLabel.
    • tp

      public double tp(Label label)
      Gets the true positive count for that label.
      Parameters:
      label - The label.
      Returns:
      The true positive count.
    • tp

      public double tp()
      Gets the micro averaged true positive count.
      Returns:
      The micro averaged true positive count.
    • macroTP

      public double macroTP()
      Gets the macro averaged true positive count.
      Returns:
      The macro averaged true positive count.
    • fp

      public double fp(Label label)
      The false positive count for this label.
      Parameters:
      label - The label.
      Returns:
      The false positive count.
    • fp

      public double fp()
      Gets the micro averaged false positive count.
      Returns:
      The micro averaged false positive count.
    • macroFP

      public double macroFP()
      Gets the macro averaged false positive count.
      Returns:
      The macro averaged false positive count.
    • tn

      public double tn(Label label)
      The true negative count for this label.
      Parameters:
      label - The label.
      Returns:
      The true negative count.
    • tn

      public double tn()
      Gets the micro averaged true negative count.
      Returns:
      The micro averaged true negative count.
    • macroTN

      public double macroTN()
      Gets the macro averaged true negative count.
      Returns:
      The macro averaged true negative count.
    • fn

      public double fn(Label label)
      The false negative count for this label.
      Parameters:
      label - The label.
      Returns:
      The false negative count.
    • fn

      public double fn()
      Gets the micro averaged false negative count.
      Returns:
      The micro averaged false negative count.
    • macroFN

      public double macroFN()
      Gets the macro averaged false negative count.
      Returns:
      The macro averaged false negative count.
    • precision

      public double precision(Label label)
      The precision for this label.
      Parameters:
      label - The label.
      Returns:
      The precision.
    • microAveragedPrecision

      public double microAveragedPrecision()
      The micro averaged precision.
      Returns:
      The micro averaged precision.
    • macroAveragedPrecision

      public double macroAveragedPrecision()
      The macro averaged precision.
      Returns:
      The macro averaged precision.
    • recall

      public double recall(Label label)
      The recall for this label.
      Parameters:
      label - The label.
      Returns:
      The recall.
    • microAveragedRecall

      public double microAveragedRecall()
      The micro averaged recall.
      Returns:
      The micro averaged recall.
    • macroAveragedRecall

      public double macroAveragedRecall()
      The macro averaged recall.
      Returns:
      The macro averaged recall.
    • f1

      public double f1(Label label)
      The F1 for this label.
      Parameters:
      label - The label.
      Returns:
      The F1.
    • microAveragedF1

      public double microAveragedF1()
      The micro averaged F1.
      Returns:
      The micro averaged F1.
    • macroAveragedF1

      public double macroAveragedF1()
      The macro averaged F1.
      Returns:
      The macro averaged F1.
    • accuracy

      public double accuracy()
      The accuracy.
      Returns:
      The accuracy.
    • accuracy

      public double accuracy(Label label)
      Gets the accuracy for this label.
      Parameters:
      label - The label.
      Returns:
      The accuracy.
    • balancedErrorRate

      public double balancedErrorRate()
      Gets the balanced error rate.

      Also known as 1 - the macro averaged recall.

      Returns:
      The balanced error rate.
    • getProvenance

      public EvaluationProvenance getProvenance()
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<EvaluationProvenance>
    • toString

      public String toString()
      Overrides:
      toString in class Object