pub struct LRClassifier { /* private fields */ }Expand description
A classifier that uses a trained LR model for prediction.
Implementations§
Source§impl LRClassifier
impl LRClassifier
Sourcepub fn from_model(model: LRModel) -> Self
pub fn from_model(model: LRModel) -> Self
Create a classifier from an existing model.
Sourcepub fn predict(&self, features: &[String]) -> String
pub fn predict(&self, features: &[String]) -> String
Predict the most likely class for the given features.
Returns the class label with the highest probability.
Sourcepub fn predict_with_prob(&self, features: &[String]) -> (String, f64)
pub fn predict_with_prob(&self, features: &[String]) -> (String, f64)
Predict with probability for the most likely class.
Returns (class_label, probability).
Sourcepub fn predict_proba(&self, features: &[String]) -> Vec<(String, f64)>
pub fn predict_proba(&self, features: &[String]) -> Vec<(String, f64)>
Get probability distribution over all classes.
Returns a list of (class_label, probability) tuples, sorted by probability descending.
Sourcepub fn predict_top_k(&self, features: &[String], k: usize) -> Vec<(String, f64)>
pub fn predict_top_k(&self, features: &[String], k: usize) -> Vec<(String, f64)>
Get top-k most likely classes with probabilities.
Returns a list of (class_label, probability) tuples for the top-k classes.
Sourcepub fn num_classes(&self) -> usize
pub fn num_classes(&self) -> usize
Get the number of classes.
Trait Implementations§
Source§impl Clone for LRClassifier
impl Clone for LRClassifier
Source§fn clone(&self) -> LRClassifier
fn clone(&self) -> LRClassifier
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LRClassifier
impl Debug for LRClassifier
Auto Trait Implementations§
impl Freeze for LRClassifier
impl RefUnwindSafe for LRClassifier
impl Send for LRClassifier
impl Sync for LRClassifier
impl Unpin for LRClassifier
impl UnsafeUnpin for LRClassifier
impl UnwindSafe for LRClassifier
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 more