pub struct ChoiceAnswer { /* private fields */ }Expand description
The option a choice question picked, with how likely each option was.
See the choice primitive.
Implementations§
Source§impl ChoiceAnswer
impl ChoiceAnswer
Sourcepub fn new<C, I, S>(choice: C, confidence: f64, probabilities: I) -> Self
pub fn new<C, I, S>(choice: C, confidence: f64, probabilities: I) -> Self
Builds an answer, for example to stand in for a real response in a test. The probabilities keep the order they are given in.
Sourcepub fn confidence(&self) -> f64
pub fn confidence(&self) -> f64
How sure the model is of the pick, from 0 to 1.
Sourcepub fn probabilities(
&self,
) -> impl ExactSizeIterator<Item = (&str, f64)> + DoubleEndedIterator
pub fn probabilities( &self, ) -> impl ExactSizeIterator<Item = (&str, f64)> + DoubleEndedIterator
Every option with its probability, in the order received.
Sourcepub fn probability(&self, name: &str) -> Option<f64>
pub fn probability(&self, name: &str) -> Option<f64>
The probability of the option called name.
Trait Implementations§
Source§impl Clone for ChoiceAnswer
impl Clone for ChoiceAnswer
Source§impl Debug for ChoiceAnswer
impl Debug for ChoiceAnswer
Source§impl<'de> Deserialize<'de> for ChoiceAnswer
impl<'de> Deserialize<'de> for ChoiceAnswer
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>,
Reads a choice answer object. Its type must be choice.
Reloading is supported through a JSON codec (sonic-rs, serde_json);
see ScoreAnswer for what a non-JSON serde format cannot read back.
Source§impl From<ChoiceAnswer> for Answer
impl From<ChoiceAnswer> for Answer
Source§fn from(answer: ChoiceAnswer) -> Self
fn from(answer: ChoiceAnswer) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ChoiceAnswer
impl PartialEq for ChoiceAnswer
Source§impl Serialize for ChoiceAnswer
impl Serialize for ChoiceAnswer
impl StructuralPartialEq for ChoiceAnswer
Auto Trait Implementations§
impl Freeze for ChoiceAnswer
impl RefUnwindSafe for ChoiceAnswer
impl Send for ChoiceAnswer
impl Sync for ChoiceAnswer
impl Unpin for ChoiceAnswer
impl UnsafeUnpin for ChoiceAnswer
impl UnwindSafe for ChoiceAnswer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more