Skip to main content

PolynomialFeatures

Struct PolynomialFeatures 

Source
pub struct PolynomialFeatures {
    pub degree: usize,
    pub interaction_only: bool,
    pub include_bias: bool,
    /* private fields */
}
Expand description

Polynomial-feature expansion.

See the module docs for the column ordering and complexity.

Fields§

§degree: usize

Total polynomial degree.

§interaction_only: bool

If true, only produce monomials in which every exponent is 0 or 1 (no x_j² etc.).

§include_bias: bool

If true, prepend the all-ones bias column.

Implementations§

Source§

impl PolynomialFeatures

Source

pub fn new(degree: usize) -> Self

New expansion at the given degree (include_bias = true, interaction_only = false).

Source

pub fn interaction_only(self, flag: bool) -> Self

Set interaction_only.

Source

pub fn include_bias(self, flag: bool) -> Self

Set include_bias.

Source

pub fn fit(&mut self, x: ArrayView2<'_, f64>) -> Result<()>

Cache the monomial list.

Source

pub fn output_columns(&self, d: usize) -> usize

Number of output columns for a d-column input.

Source

pub fn transform(&self, x: ArrayView2<'_, f64>) -> Result<Array2<f64>>

Apply the expansion.

Source

pub fn fit_transform(&self, x: ArrayView2<'_, f64>) -> Result<Array2<f64>>

One-call fit + transform.

Source

pub fn exponents(&self) -> Option<&[Vec<u32>]>

Exponent vectors, one per output column.

Returned only when fit has run; otherwise use PolynomialFeatures::exponents_for.

Source

pub fn exponents_for(&self, d: usize) -> Vec<Vec<u32>>

Compute the exponent vectors for a d-column input without consuming state.

Trait Implementations§

Source§

impl Clone for PolynomialFeatures

Source§

fn clone(&self) -> PolynomialFeatures

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PolynomialFeatures

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PolynomialFeatures

Source§

fn eq(&self, other: &PolynomialFeatures) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PolynomialFeatures

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.