pub struct ScoreAnswer<L> { /* private fields */ }Expand description
The answer to a Score: the score, and the probability of each level.
Each method that gives probabilities gives pairs of a value and its probability. A method
that borrows gives (&L, f64), and a method that consumes the answer gives (L, f64). It
serializes as {"score": s, "most_likely": level, "confidence": c, "levels": [level, …], "probabilities": [p, …]}, so a value needs no Serialize.
Implementations§
Source§impl<L> ScoreAnswer<L>
impl<L> ScoreAnswer<L>
Sourcepub fn into_question(self) -> Score<L>
pub fn into_question(self) -> Score<L>
Returns the question of the answer, with its values, so that code can ask it again.
Sourcepub fn score(&self) -> f64
pub fn score(&self) -> f64
Returns the mean level, from 0 for the lowest level, as the API gives it.
Sourcepub fn most_likely(&self) -> &L
pub fn most_likely(&self) -> &L
Returns the value of the level with the highest probability.
If two levels have equal probabilities, it is the lower level.
Sourcepub fn into_most_likely(self) -> L
pub fn into_most_likely(self) -> L
Returns the value of the level with the highest probability, owned.
If two levels have equal probabilities, it is the lower level.
Sourcepub fn confidence(&self) -> f64
pub fn confidence(&self) -> f64
Returns the confidence of the API in the score, from 0 to 1.
Sourcepub fn probabilities(&self) -> impl ExactSizeIterator<Item = (&L, f64)>
pub fn probabilities(&self) -> impl ExactSizeIterator<Item = (&L, f64)>
Returns each level and its probability, from the lowest level.
Sourcepub fn into_probabilities(self) -> Vec<(L, f64)>
pub fn into_probabilities(self) -> Vec<(L, f64)>
Returns each level and its probability, owned, from the lowest level.