Skip to main content

nominal_api/conjure/objects/scout/compute/api/
curve_fit_result.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    conjure_object::private::DeriveWith
7)]
8#[serde(crate = "conjure_object::serde")]
9#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[conjure_object::private::staged_builder::staged_builder]
11#[builder(crate = conjure_object::private::staged_builder, update, inline)]
12pub struct CurveFitResult {
13    #[serde(rename = "r2")]
14    #[derive_with(with = conjure_object::private::DoubleWrapper)]
15    r2: f64,
16    #[serde(rename = "mae")]
17    #[derive_with(with = conjure_object::private::DoubleWrapper)]
18    mae: f64,
19    #[serde(rename = "mse")]
20    #[derive_with(with = conjure_object::private::DoubleWrapper)]
21    mse: f64,
22    #[serde(rename = "rmse")]
23    #[derive_with(with = conjure_object::private::DoubleWrapper)]
24    rmse: f64,
25    #[serde(rename = "maxAbsoluteError")]
26    #[derive_with(with = conjure_object::private::DoubleWrapper)]
27    max_absolute_error: f64,
28    #[serde(rename = "sampleCount")]
29    sample_count: i32,
30    #[builder(custom(type = super::CurveResultDetails, convert = Box::new))]
31    #[serde(rename = "curveResultDetails")]
32    curve_result_details: Box<super::CurveResultDetails>,
33}
34impl CurveFitResult {
35    /// R^2 (coefficient of determination) for the fit curve, a normalized measure of how well the curve fits the data.
36    /// Usually ranges from 0 to 1, with higher indicating better fit (points closer to fit line).
37    #[inline]
38    pub fn r2(&self) -> f64 {
39        self.r2
40    }
41    /// Mean Absolute Error (MAE) - the average of the absolute differences between predicted and actual values.
42    /// Measured in the same units as the y-values.
43    #[inline]
44    pub fn mae(&self) -> f64 {
45        self.mae
46    }
47    /// Mean Squared Error (MSE) - the average of the squared differences between predicted and actual values.
48    /// Measured in the squared units of the y-values.
49    #[inline]
50    pub fn mse(&self) -> f64 {
51        self.mse
52    }
53    /// Root Mean Squared Error (RMSE) - the square root of the mean squared error.
54    /// Measured in the same units as the y-values.
55    #[inline]
56    pub fn rmse(&self) -> f64 {
57        self.rmse
58    }
59    /// Maximum Absolute Error - the largest absolute difference between any predicted and actual value.
60    /// Measured in the same units as the y-values.
61    #[inline]
62    pub fn max_absolute_error(&self) -> f64 {
63        self.max_absolute_error
64    }
65    /// The number of data points used in the curve fitting calculation.
66    #[inline]
67    pub fn sample_count(&self) -> i32 {
68        self.sample_count
69    }
70    /// Description of the fit curve.
71    #[inline]
72    pub fn curve_result_details(&self) -> &super::CurveResultDetails {
73        &*self.curve_result_details
74    }
75}