Struct frame_benchmarking::RegressionModel
source · [−]pub struct RegressionModel {
pub parameters: RegressionParameters,
pub se: RegressionParameters,
pub ssr: f64,
pub rsquared: f64,
pub rsquared_adj: f64,
pub pvalues: RegressionParameters,
pub residuals: RegressionParameters,
pub scale: f64,
}
Expand description
A fitted regression model.
Is the result of FormulaRegressionBuilder.fit()
.
If a field has only one value for the model it is given as f64
.
Otherwise it is given as a RegressionParameters
struct.
Fields
parameters: RegressionParameters
The model’s intercept and slopes (also known as betas).
se: RegressionParameters
The standard errors of the parameter estimates.
ssr: f64
Sum of squared residuals.
rsquared: f64
R-squared of the model.
rsquared_adj: f64
Adjusted R-squared of the model.
pvalues: RegressionParameters
The two-tailed p-values for the t-statistics of the params.
residuals: RegressionParameters
The residuals of the model.
scale: f64
A scale factor for the covariance matrix.
Note that the square root of scale
is often
called the standard error of the regression.
Implementations
sourceimpl RegressionModel
impl RegressionModel
sourcepub fn predict<'a, I, S>(&self, new_data: I) -> Result<Vec<f64, Global>, Error> where
I: IntoIterator<Item = (S, Vec<f64, Global>)>,
S: Into<Cow<'a, str>>,
pub fn predict<'a, I, S>(&self, new_data: I) -> Result<Vec<f64, Global>, Error> where
I: IntoIterator<Item = (S, Vec<f64, Global>)>,
S: Into<Cow<'a, str>>,
Evaluates the model on given new input data and returns the predicted values.
The new data is expected to have the same columns as the original data.
See RegressionDataBuilder.build
for details on the type of the new_data
parameter.
Note
This function does no special handling of non real values (NaN or infinity or negative infinity).
Such a value in new_data
will result in a corresponding meaningless prediction.
Example
let y = vec![1., 2., 3., 4., 5.];
let x1 = vec![5., 4., 3., 2., 1.];
let x2 = vec![729.53, 439.0367, 42.054, 1., 0.];
let x3 = vec![258.589, 616.297, 215.061, 498.361, 0.];
let data = vec![("Y", y), ("X1", x1), ("X2", x2), ("X3", x3)];
let data = RegressionDataBuilder::new().build_from(data).unwrap();
let formula = "Y ~ X1 + X2 + X3";
let model = FormulaRegressionBuilder::new()
.data(&data)
.formula(formula)
.fit()?;
let new_data = vec![
("X1", vec![2.5, 3.5]),
("X2", vec![2.0, 8.0]),
("X3", vec![2.0, 1.0]),
];
let prediction: Vec<f64> = model.predict(new_data)?;
assert_eq!(prediction, vec![3.5000000000000275, 2.5000000000000533]);
Trait Implementations
sourceimpl Clone for RegressionModel
impl Clone for RegressionModel
sourcepub fn clone(&self) -> RegressionModel
pub fn clone(&self) -> RegressionModel
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for RegressionModel
impl Send for RegressionModel
impl Sync for RegressionModel
impl Unpin for RegressionModel
impl UnwindSafe for RegressionModel
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedConversion for T
impl<T> CheckedConversion for T
sourcefn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
Convert from a value of T
into an equivalent instance of Option<Self>
. Read more
sourcefn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
Consume self to return Some
equivalent value of Option<T>
. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
sourcefn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
Convert from a value of T
into an equivalent instance of Self
. Read more
sourcefn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of T
. Read more
sourceimpl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
sourcepub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
sourcepub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
sourcepub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
sourcepub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.
sourceimpl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
sourcepub fn unique_saturated_into(self) -> T
pub fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of T
.