pub struct PolynomialFeatures { /* private fields */ }Expand description
Polynomial Feature Generator
Generate polynomial and interaction features from input features. This transformer can be used to capture non-linear relationships by creating polynomial combinations of the original features.
§Parameters
degree- Maximum degree of polynomial featuresinteraction_only- If true, only interaction features are producedinclude_bias- If true, include a bias column of ones
§Examples
use sklears_feature_extraction::basic_features::PolynomialFeatures;
use sklears_core::traits::{Transform, Fit};
use scirs2_core::ndarray::array;
let X = array![[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]];
let poly = PolynomialFeatures::new()
.degree(2)
.include_bias(true);
let features = poly.transform(&X.view()).expect("valid input produces transform output");Implementations§
Source§impl PolynomialFeatures
impl PolynomialFeatures
Sourcepub fn interaction_only(self, interaction_only: bool) -> Self
pub fn interaction_only(self, interaction_only: bool) -> Self
Set whether to produce only interaction features
Sourcepub fn include_bias(self, include_bias: bool) -> Self
pub fn include_bias(self, include_bias: bool) -> Self
Set whether to include a bias column
Sourcepub fn transform(&self, X: &ArrayView2<'_, Float>) -> SklResult<Array2<Float>>
pub fn transform(&self, X: &ArrayView2<'_, Float>) -> SklResult<Array2<Float>>
Transform input features to polynomial features
Sourcepub fn get_feature_names(
&self,
input_features: Option<&[String]>,
) -> SklResult<Vec<String>>
pub fn get_feature_names( &self, input_features: Option<&[String]>, ) -> SklResult<Vec<String>>
Get feature names for the polynomial features
Sourcepub fn get_n_output_features(&self, n_input_features: usize) -> SklResult<usize>
pub fn get_n_output_features(&self, n_input_features: usize) -> SklResult<usize>
Get the number of output features
Trait Implementations§
Source§impl Clone for PolynomialFeatures
impl Clone for PolynomialFeatures
Source§impl Debug for PolynomialFeatures
impl Debug for PolynomialFeatures
Source§impl Default for PolynomialFeatures
impl Default for PolynomialFeatures
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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