#[non_exhaustive]pub struct ScoreAnswer {
pub score: f64,
pub confidence: f64,
pub legend: IndexMap<String, Content>,
pub probabilities: IndexMap<String, f64>,
}Expand description
The answer to a ScoreQuestion.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.score: f64Probability-weighted level, from 0 to the top level; can land between levels.
confidence: f64How concentrated the distribution is, from 0 to 1.
legend: IndexMap<String, Content>Level number (as a string key) to the level’s description.
probabilities: IndexMap<String, f64>Level number (as a string key) to its probability.
Implementations§
Source§impl ScoreAnswer
impl ScoreAnswer
Sourcepub fn new(
score: f64,
confidence: f64,
levels: impl IntoIterator<Item = impl Into<Content>>,
probabilities: impl IntoIterator<Item = f64>,
) -> Self
pub fn new( score: f64, confidence: f64, levels: impl IntoIterator<Item = impl Into<Content>>, probabilities: impl IntoIterator<Item = f64>, ) -> Self
An answer over levels (in order) with one probability per level, for fixtures
and tests.
Sourcepub fn level_probabilities(&self) -> Vec<f64>
pub fn level_probabilities(&self) -> Vec<f64>
Probability of each level, indexed by level number. Levels the response has no probability for count as 0.
Sourcepub fn most_likely_level(&self) -> Option<usize>
pub fn most_likely_level(&self) -> Option<usize>
The single most probable level, or None when there are no levels.
Sourcepub fn nearest_level(&self) -> usize
pub fn nearest_level(&self) -> usize
The score rounded to the nearest level, for code that needs one outcome.
Sourcepub fn normalized(&self) -> f64
pub fn normalized(&self) -> f64
The score divided by the top level, from 0 to 1, so scores with different numbers of levels can be weighted and combined.
Sourcepub fn level_description(&self, level: usize) -> Option<&Content>
pub fn level_description(&self, level: usize) -> Option<&Content>
The description of level, as the question defined it.
Trait Implementations§
Source§impl Clone for ScoreAnswer
impl Clone for ScoreAnswer
Source§fn clone(&self) -> ScoreAnswer
fn clone(&self) -> ScoreAnswer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScoreAnswer
impl Debug for ScoreAnswer
Source§impl<'de> Deserialize<'de> for ScoreAnswer
impl<'de> Deserialize<'de> for ScoreAnswer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<ScoreAnswer> for Answer
impl From<ScoreAnswer> for Answer
Source§fn from(answer: ScoreAnswer) -> Self
fn from(answer: ScoreAnswer) -> Self
Source§impl PartialEq for ScoreAnswer
impl PartialEq for ScoreAnswer
Source§impl ReadAnswer for ScoreAnswer
impl ReadAnswer for ScoreAnswer
Source§type Output<'a> = &'a ScoreAnswer
type Output<'a> = &'a ScoreAnswer
SystemOneResponse::answer returns for this key.Source§fn read<'a>(
id: &str,
answer: &'a Answer,
) -> Result<&'a ScoreAnswer, AnswerError>
fn read<'a>( id: &str, answer: &'a Answer, ) -> Result<&'a ScoreAnswer, AnswerError>
id, failing when it has the wrong kind or content.