Class Prediction

java.lang.Object
org.apache.tika.ml.Prediction

public final class Prediction extends Object
The result of a single-label classification from a LinearModel.

Two scores are exposed:

  • getProbability() — softmax probability of this label relative to all other labels (0–1). Reflects the model's relative preference for this label over alternatives. Higher is better, but the magnitude is N-dependent: 0.60 in an 80-class model is very strong.
  • getConfidence() — a calibration-independent signal (0–1) computed as sigmoid(logit) × probability. The sigmoid factor captures absolute model activation: a large negative logit (the model has no evidence for this class) suppresses confidence even when the label happens to win the softmax race by a slim margin.

Use getProbability() when comparing candidates from the same prediction run. Use getConfidence() when deciding whether to trust a prediction at all (e.g. as a threshold gate).

  • Constructor Details

    • Prediction

      public Prediction(String label, float logit, float probability)
      Construct a prediction from a raw logit and its softmax probability.
      Parameters:
      label - the class label (e.g. language tag or charset name)
      logit - raw pre-softmax score for this class
      probability - softmax probability for this class (0–1)
  • Method Details

    • getLabel

      public String getLabel()
      The predicted class label (e.g. "eng", "UTF-8").
    • getProbability

      public double getProbability()
      Softmax probability of this label (0–1), relative to all other labels. Suitable for ranking candidates within a single prediction run.
    • getConfidence

      public double getConfidence()
      Calibration-independent confidence (0–1). Computed as sigmoid(logit) × probability.

      Accounts for absolute model activation: if the winning logit is very negative (the model has no strong evidence for any class), confidence is suppressed even when the softmax winner has a comfortable margin. Suitable as a threshold gate for deciding whether to trust the result.

    • toString

      public String toString()
      Overrides:
      toString in class Object