pub struct Terms { /* private fields */ }Expand description
The terms of a model, before any data is seen.
use prospicio_models::{Column, Frame, Terms};
let train = Frame::new(vec![
("age".into(), Column::Numeric(vec![30.0, 45.0, 60.0])),
("region".into(), Column::Categorical(vec!["N".into(), "S".into(), "W".into()])),
])
.unwrap();
let coding = Terms::new().intercept().numeric("age").factor("region").fit(&train).unwrap();
assert_eq!(coding.names(), ["(Intercept)", "age", "region[S]", "region[W]"]);
let d = coding.design(&train).unwrap();
assert_eq!(d.column(3), [0.0, 0.0, 1.0]);Implementations§
Source§impl Terms
impl Terms
Sourcepub fn factor_with_reference(self, name: &str, reference: &str) -> Self
pub fn factor_with_reference(self, name: &str, reference: &str) -> Self
Adds a factor with the given reference level.
Sourcepub fn interaction(self, a: &str, b: &str) -> Self
pub fn interaction(self, a: &str, b: &str) -> Self
Adds the interaction of two columns; see Term::Interaction.
Sourcepub fn poly(self, name: &str, degree: usize) -> Self
pub fn poly(self, name: &str, degree: usize) -> Self
Adds raw powers of a numeric column up to degree.
Sourcepub fn hinges(self, name: &str, knots: &[f64]) -> Self
pub fn hinges(self, name: &str, knots: &[f64]) -> Self
Adds hinge functions max(0, x − k) at knots.
Sourcepub fn bins(self, name: &str, cuts: &[f64]) -> Self
pub fn bins(self, name: &str, cuts: &[f64]) -> Self
Adds a numeric column cut into bins at cuts, the lowest bin as
reference.
Sourcepub fn ordinal(self, name: &str, levels: &[&str]) -> Self
pub fn ordinal(self, name: &str, levels: &[&str]) -> Self
Adds an ordered factor in cumulative coding, levels in levels’
order.
Sourcepub fn orthogonal_poly(self, name: &str, degree: usize) -> Self
pub fn orthogonal_poly(self, name: &str, degree: usize) -> Self
Adds orthogonal polynomials of a numeric column up to degree.
Sourcepub fn natural_spline(self, name: &str, knots: &[f64]) -> Self
pub fn natural_spline(self, name: &str, knots: &[f64]) -> Self
Adds a natural cubic spline with interior knots, its boundary
knots the training range.
Trait Implementations§
impl StructuralPartialEq for Terms
Auto Trait Implementations§
impl Freeze for Terms
impl RefUnwindSafe for Terms
impl Send for Terms
impl Sync for Terms
impl Unpin for Terms
impl UnsafeUnpin for Terms
impl UnwindSafe for Terms
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