pub struct RandomClassifier { /* private fields */ }Expand description
Stateless weighted classifier used by random fall-through routing.
Implementations§
Source§impl RandomClassifier
impl RandomClassifier
Sourcepub fn new(weights: Option<Vec<f64>>, seed: Option<u64>) -> Result<Self>
pub fn new(weights: Option<Vec<f64>>, seed: Option<u64>) -> Result<Self>
Creates a classifier over ordered target names.
Missing weights default to one per target. Explicit weights are relative,
follow target order, and need not sum to one. Zero disables a target.
Missing seed uses entropy-backed randomness.
§Errors
Returns an error if explicit weights are negative or non-finite, or contain no positive value.
Trait Implementations§
Source§impl Classifier for RandomClassifier
impl Classifier for RandomClassifier
Source§fn score<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_state: &'life1 mut State,
_request: &'life2 mut Request,
driver: &'life3 Driver,
) -> Pin<Box<dyn Future<Output = Result<(Classification, Option<Response>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn score<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_state: &'life1 mut State,
_request: &'life2 mut Request,
driver: &'life3 Driver,
) -> Pin<Box<dyn Future<Output = Result<(Classification, Option<Response>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Score the classifier’s targets given the current state and request. Read more
Source§fn tracks_answers(&self) -> bool
fn tracks_answers(&self) -> bool
Whether a stateful composition should request served-answer reports.
Source§fn observe_answer(&self, _state: &mut State, _answer: AnswerSummary)
fn observe_answer(&self, _state: &mut State, _answer: AnswerSummary)
Folds the answer the host served for this session into the composition’s state.
Auto Trait Implementations§
impl !Freeze for RandomClassifier
impl !RefUnwindSafe for RandomClassifier
impl Send for RandomClassifier
impl Sync for RandomClassifier
impl Unpin for RandomClassifier
impl UnsafeUnpin for RandomClassifier
impl UnwindSafe for RandomClassifier
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