pub struct Model<'a> { /* private fields */ }Expand description
A loaded model, borrowing the file it was read from.
Implementations§
Source§impl<'a> Model<'a>
impl<'a> Model<'a>
Sourcepub fn from_bytes(bytes: &'a [u8]) -> Result<Self, ModelError>
pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, ModelError>
Read a model file. Checks the whole layout; the returned model borrows bytes.
Sourcepub fn meta(&self) -> &Value
pub fn meta(&self) -> &Value
Everything the trainer recorded about the model (name, version, threshold, …).
Sourcepub fn threshold(&self) -> Option<f64>
pub fn threshold(&self) -> Option<f64>
The confidence the trainer suggests acting on, if it recorded one.
Sourcepub fn probabilities(&self, text: &str) -> Vec<f64>
pub fn probabilities(&self, text: &str) -> Vec<f64>
The probability of every label for text, in Model::labels order.
Sourcepub fn predict(&self, text: &str) -> Prediction
pub fn predict(&self, text: &str) -> Prediction
The model’s answer for text.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Model<'a>
impl<'a> RefUnwindSafe for Model<'a>
impl<'a> Send for Model<'a>
impl<'a> Sync for Model<'a>
impl<'a> Unpin for Model<'a>
impl<'a> UnsafeUnpin for Model<'a>
impl<'a> UnwindSafe for Model<'a>
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