Class Scale<E extends Enum<E>>
java.lang.Object
dev.langchain4j.service.decision.Scale<E>
- Type Parameters:
E- the enum whose constants are the levels
The answer to a question of a decision service that places the input on an ordered scale: the mean level, the
probability of each level and, if the model reports one, a confidence. It is the typed counterpart of
ScaleAnswer.
The levels are the constants of the enum, from the lowest (the first declared constant) to the highest.
- Since:
- 1.21.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends Enum<E>>
Scale.Builder<E> Creates a builder for a scale whose levels are the constants of the given enum.How confident the model is inmean(), from 0 to 1, ornullif the model does not report a confidence.booleaninthashCode()doublemean()The probability-weighted mean of the level indexes, from 0 (the first constant) ton - 1(the last constant).The level with the highest probability or, if the model does not report probabilities, the level closest tomean().The probability of each level, from the lowest to the highest.doubleprobabilityAtLeast(E level) The probability of the given level or any higher level, for example the probability that an incident is at least of high severity.doubleprobabilityOf(E level) The probability of the given level, or 0 if the model reported probabilities but none for this level.toString()
-
Method Details
-
builder
Creates a builder for a scale whose levels are the constants of the given enum. -
mean
public double mean()The probability-weighted mean of the level indexes, from 0 (the first constant) ton - 1(the last constant). It can fall between two levels: with the levelsLOW,MEDIUMandHIGH, a mean of 1.4 means "between medium and high, closer to medium". -
mostLikely
-
probabilities
-
probabilityOf
The probability of the given level, or 0 if the model reported probabilities but none for this level.- Throws:
IllegalStateException- if the model did not report probabilities.
-
probabilityAtLeast
The probability of the given level or any higher level, for example the probability that an incident is at least of high severity.- Throws:
IllegalStateException- if the model did not report probabilities.
-
confidence
How confident the model is inmean(), from 0 to 1, ornullif the model does not report a confidence. The formula is defined by each model, so preferprobabilities()for thresholds. -
equals
-
hashCode
-
toString
-