pub struct SvmModel {
pub param: SvmParameter,
pub nr_class: usize,
pub sv: Vec<Vec<SvmNode>>,
pub sv_coef: Vec<Vec<f64>>,
pub rho: Vec<f64>,
pub prob_a: Vec<f64>,
pub prob_b: Vec<f64>,
pub prob_density_marks: Vec<f64>,
pub sv_indices: Vec<usize>,
pub label: Vec<i32>,
pub n_sv: Vec<usize>,
}Expand description
A trained SVM model.
Produced by training, or loaded from a LIBSVM model file.
load_model validates model-file shape contracts before returning this
type: class counts, support-vector counts, decision-function arrays, optional
probability metadata, and sparse support-vector rows must be internally
consistent. Manually constructed values bypass those checks, so callers that
accept external model text should prefer crate::io::load_model or
crate::io::load_model_from_reader.
Fields§
§param: SvmParameterParameters used during training.
nr_class: usizeNumber of classes (2 for binary, >2 for multiclass, 2 for regression).
sv: Vec<Vec<SvmNode>>Support vectors (sparse feature vectors).
sv_coef: Vec<Vec<f64>>Support vector coefficients. For k classes, this is a
(k-1) × num_sv matrix stored as Vec<Vec<f64>>.
rho: Vec<f64>Bias terms (rho). One per class pair: k*(k-1)/2 values.
prob_a: Vec<f64>Pairwise probability parameter A (Platt scaling). Empty if not trained with probability estimates.
prob_b: Vec<f64>Pairwise probability parameter B (Platt scaling). Empty if not trained with probability estimates.
prob_density_marks: Vec<f64>Probability density marks (for one-class SVM).
sv_indices: Vec<usize>Original indices of support vectors in the training set (1-based).
label: Vec<i32>Class labels (in the order used internally).
n_sv: Vec<usize>Number of support vectors per class.
Implementations§
Source§impl SvmModel
impl SvmModel
Sourcepub fn class_count(&self) -> usize
pub fn class_count(&self) -> usize
Return number of classes.
Sourcepub fn support_vector_indices(&self) -> &[usize]
pub fn support_vector_indices(&self) -> &[usize]
Return original 1-based support-vector indices.
Sourcepub fn support_vector_count(&self) -> usize
pub fn support_vector_count(&self) -> usize
Return total number of support vectors.
Sourcepub fn svr_probability(&self) -> Option<f64>
pub fn svr_probability(&self) -> Option<f64>
Return SVR sigma when a probability-capable SVR model is available.
Sourcepub fn has_probability_model(&self) -> bool
pub fn has_probability_model(&self) -> bool
Check whether the model contains probability metadata.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SvmModel
Available on crate feature serde only.
impl<'de> Deserialize<'de> for SvmModel
serde only.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>,
impl StructuralPartialEq for SvmModel
Auto Trait Implementations§
impl Freeze for SvmModel
impl RefUnwindSafe for SvmModel
impl Send for SvmModel
impl Sync for SvmModel
impl Unpin for SvmModel
impl UnsafeUnpin for SvmModel
impl UnwindSafe for SvmModel
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more