pub enum UncertainPrediction {
Single {
entity_type: EntityType,
confidence: f64,
},
Distributed(TypeDistribution),
Abstained(Abstention),
}Expand description
A prediction that may include uncertainty or abstention.
This is the core type for selective prediction, replacing simple (EntityType, confidence) pairs with richer uncertainty information.
§Variants
- Single: A single type prediction with confidence (traditional)
- Distributed: Probabilities over multiple types (soft prediction)
- Abstained: Explicit refusal to predict with reason
Variants§
Single
Single type prediction (traditional NER output).
Distributed(TypeDistribution)
Distribution over types (soft prediction).
Abstained(Abstention)
Explicit abstention with reason.
Implementations§
Source§impl UncertainPrediction
impl UncertainPrediction
Sourcepub fn from_type(entity_type: EntityType, confidence: f64) -> Self
pub fn from_type(entity_type: EntityType, confidence: f64) -> Self
Create a single-type prediction.
Sourcepub fn distributed(dist: TypeDistribution) -> Self
pub fn distributed(dist: TypeDistribution) -> Self
Create a distributed prediction.
Sourcepub fn abstain(reason: Abstention) -> Self
pub fn abstain(reason: Abstention) -> Self
Create an abstention.
Sourcepub fn abstain_low_confidence(max_score: f64) -> Self
pub fn abstain_low_confidence(max_score: f64) -> Self
Create abstention due to low confidence.
Sourcepub fn abstain_ambiguous(top_types: Vec<EntityType>, margin: f64) -> Self
pub fn abstain_ambiguous(top_types: Vec<EntityType>, margin: f64) -> Self
Create abstention due to ambiguity.
Sourcepub fn is_abstention(&self) -> bool
pub fn is_abstention(&self) -> bool
Check if this is an abstention.
Sourcepub fn is_confident(&self, threshold: f64) -> bool
pub fn is_confident(&self, threshold: f64) -> bool
Check if this prediction is confident (above threshold).
Sourcepub fn best(&self) -> Option<(&EntityType, f64)>
pub fn best(&self) -> Option<(&EntityType, f64)>
Get the best prediction type and confidence.
Returns None if abstained or distribution is empty.
Sourcepub fn get_type(&self) -> Option<&EntityType>
pub fn get_type(&self) -> Option<&EntityType>
Get the entity type if prediction is confident.
Returns None if abstained, distributed, or below threshold.
Sourcepub fn confidence(&self) -> f64
pub fn confidence(&self) -> f64
Get confidence score.
Returns 0.0 for abstentions, max prob for distributions.
Sourcepub fn distribution(&self) -> Option<&TypeDistribution>
pub fn distribution(&self) -> Option<&TypeDistribution>
Get the type distribution if available.
Sourcepub fn abstention_reason(&self) -> Option<&Abstention>
pub fn abstention_reason(&self) -> Option<&Abstention>
Get the abstention reason if abstained.
Sourcepub fn with_threshold(self, threshold: f64) -> Self
pub fn with_threshold(self, threshold: f64) -> Self
Convert to a single prediction, applying threshold for abstention.
If the prediction is below threshold, converts to abstention.
Trait Implementations§
Source§impl Clone for UncertainPrediction
impl Clone for UncertainPrediction
Source§fn clone(&self) -> UncertainPrediction
fn clone(&self) -> UncertainPrediction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UncertainPrediction
impl Debug for UncertainPrediction
Source§impl<'de> Deserialize<'de> for UncertainPrediction
impl<'de> Deserialize<'de> for UncertainPrediction
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 Display for UncertainPrediction
impl Display for UncertainPrediction
Source§impl PartialEq for UncertainPrediction
impl PartialEq for UncertainPrediction
Source§impl Serialize for UncertainPrediction
impl Serialize for UncertainPrediction
impl StructuralPartialEq for UncertainPrediction
Auto Trait Implementations§
impl Freeze for UncertainPrediction
impl RefUnwindSafe for UncertainPrediction
impl Send for UncertainPrediction
impl Sync for UncertainPrediction
impl Unpin for UncertainPrediction
impl UnsafeUnpin for UncertainPrediction
impl UnwindSafe for UncertainPrediction
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.