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(
targets: Vec<String>,
weights: Option<Vec<f64>>,
seed: Option<u64>,
) -> Result<Self>
pub fn new( targets: Vec<String>, 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 when targets are empty or duplicated, or when explicit weights have the wrong length, are negative or non-finite, or contain no positive value.
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