pub struct SparseCoefficient {
pub feature_indices: Vec<usize>,
pub powers: Vec<usize>,
pub coefficient: Float,
}Expand description
Sparse representation of polynomial feature coefficient
Fields§
§feature_indices: Vec<usize>Feature indices involved in this term
powers: Vec<usize>Powers of each feature in this term
coefficient: FloatThe coefficient value (typically 1.0 for polynomial features)
Implementations§
Source§impl SparseCoefficient
impl SparseCoefficient
Sourcepub fn new(
feature_indices: Vec<usize>,
powers: Vec<usize>,
coefficient: Float,
) -> Self
pub fn new( feature_indices: Vec<usize>, powers: Vec<usize>, coefficient: Float, ) -> Self
Create a new sparse coefficient
Sourcepub fn evaluate(&self, sample: &Array1<Float>) -> Float
pub fn evaluate(&self, sample: &Array1<Float>) -> Float
Evaluate this term for a given input sample
Sourcepub fn total_degree(&self) -> usize
pub fn total_degree(&self) -> usize
Get the total degree of this term
Sourcepub fn is_interaction(&self) -> bool
pub fn is_interaction(&self) -> bool
Check if this is an interaction term (all powers <= 1)
Trait Implementations§
Source§impl Clone for SparseCoefficient
impl Clone for SparseCoefficient
Source§fn clone(&self) -> SparseCoefficient
fn clone(&self) -> SparseCoefficient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SparseCoefficient
impl RefUnwindSafe for SparseCoefficient
impl Send for SparseCoefficient
impl Sync for SparseCoefficient
impl Unpin for SparseCoefficient
impl UnwindSafe for SparseCoefficient
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