Struct frame_benchmarking::RegressionModel[]

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert from a value of T into an equivalent instance of Option<Self>. Read more

Consume self to return Some equivalent value of Option<T>. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Cast reference.

Cast reference.

Cast mutable reference.

Cast mutable reference.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

Should always be Self

Convert from a value of T into an equivalent instance of Self. Read more

Consume self to return an equivalent value of T. Read more

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The counterpart to unchecked_from.

Consume self to return an equivalent value of T.