pub struct PolynomialFeatures { /* private fields */ }Expand description
Degree-2 polynomial feature generator.
Generates original features plus all degree-2 combinations (squared terms
and pairwise interactions). When interaction_only
is constructed, squared terms (x_i * x_i) are excluded, leaving only
cross-interactions (x_i * x_j where i < j).
Because the transform is purely deterministic and stateless, both
update_and_transform and
transform behave identically, and
reset clears only the cached input
dimensionality.
Implementations§
Source§impl PolynomialFeatures
impl PolynomialFeatures
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a polynomial feature generator with full degree-2 expansion.
Includes original features, squared terms, and pairwise interactions.
use irithyll::preprocessing::PolynomialFeatures;
use irithyll::pipeline::StreamingPreprocessor;
let poly = PolynomialFeatures::new();
let out = poly.transform(&[2.0, 3.0]);
// [a, b, a², ab, b²] = [2, 3, 4, 6, 9]
assert_eq!(out, vec![2.0, 3.0, 4.0, 6.0, 9.0]);Sourcepub fn interaction_only() -> Self
pub fn interaction_only() -> Self
Create a polynomial feature generator that only includes cross-interactions.
Squared terms (x_i * x_i) are excluded; only x_i * x_j where i < j are generated.
use irithyll::preprocessing::PolynomialFeatures;
use irithyll::pipeline::StreamingPreprocessor;
let poly = PolynomialFeatures::interaction_only();
let out = poly.transform(&[2.0, 3.0]);
// [a, b, ab] = [2, 3, 6]
assert_eq!(out, vec![2.0, 3.0, 6.0]);Sourcepub fn is_interaction_only(&self) -> bool
pub fn is_interaction_only(&self) -> bool
Returns true if this generator excludes squared terms.
Trait Implementations§
Source§impl Clone for PolynomialFeatures
impl Clone for PolynomialFeatures
Source§fn clone(&self) -> PolynomialFeatures
fn clone(&self) -> PolynomialFeatures
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PolynomialFeatures
impl Debug for PolynomialFeatures
Source§impl Default for PolynomialFeatures
impl Default for PolynomialFeatures
Source§impl StreamingPreprocessor for PolynomialFeatures
impl StreamingPreprocessor for PolynomialFeatures
Source§fn update_and_transform(&mut self, features: &[f64]) -> Vec<f64>
fn update_and_transform(&mut self, features: &[f64]) -> Vec<f64>
Source§fn transform(&self, features: &[f64]) -> Vec<f64>
fn transform(&self, features: &[f64]) -> Vec<f64>
Source§fn output_dim(&self) -> Option<usize>
fn output_dim(&self) -> Option<usize>
None if unknown until the first sample.Auto Trait Implementations§
impl Freeze for PolynomialFeatures
impl RefUnwindSafe for PolynomialFeatures
impl Send for PolynomialFeatures
impl Sync for PolynomialFeatures
impl Unpin for PolynomialFeatures
impl UnsafeUnpin for PolynomialFeatures
impl UnwindSafe for PolynomialFeatures
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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