$darkmode
vstat
Regression metrics

Functions

template<std::floating_point T, std::input_iterator I, std::input_iterator J>
auto r2_score (I first1, std::sentinel_for< I > auto last1, J first2) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J, std::input_iterator K>
auto r2_score (I first1, std::sentinel_for< I > auto last1, J first2, K first3) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J>
auto mean_squared_error (I first1, std::sentinel_for< I > auto last1, J first2) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J, std::input_iterator K>
auto mean_squared_error (I first1, std::sentinel_for< I > auto last1, J first2, K first3) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J>
auto mean_squared_log_error (I first1, std::sentinel_for< I > auto last1, J first2) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J, std::input_iterator K>
auto mean_squared_log_error (I first1, std::sentinel_for< I > auto last1, J first2, K first3) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J>
auto mean_absolute_error (I first1, std::sentinel_for< I > auto last1, J first2) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J, std::input_iterator K>
auto mean_absolute_error (I first1, std::sentinel_for< I > auto last1, J first2, K first3) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J>
auto mean_absolute_percentage_error (I first1, std::sentinel_for< I > auto last1, J first2) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J, std::input_iterator K>
auto mean_absolute_percentage_error (I first1, std::sentinel_for< I > auto last1, J first2, K first3) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J>
auto poisson_neg_likelihood_loss (I first1, std::sentinel_for< I > auto last1, J first2) noexcept -> double
 
template<std::floating_point T, std::input_iterator I, std::input_iterator J, std::input_iterator K>
auto poisson_neg_likelihood_loss (I first1, std::sentinel_for< I > auto last1, J first2, K first3) noexcept -> double
 

Detailed Description

Regression metrics (R2, MSE, MLSE, MAE).

Function Documentation

◆ mean_absolute_error() [1/2]

auto VSTAT_NAMESPACE::metrics::mean_absolute_error ( first1,
std::sentinel_for< I > auto  last1,
first2 
) -> double
inlinenoexcept

Computes the mean absolute error.

\[ \text{MAE}(y, \hat{y}) = \displaystyle \frac{1}{n} {\sum_{i=1}^n |y-\hat{y}|} \]

◆ mean_absolute_error() [2/2]

auto VSTAT_NAMESPACE::metrics::mean_absolute_error ( first1,
std::sentinel_for< I > auto  last1,
first2,
first3 
) -> double
inlinenoexcept

Weighted mean absolute error.

\[ \text{MAE}(y, \hat{y}) = \displaystyle \frac{1}{\sum_{i=1}^n w_i} \sum_{i=1}^n w_i |y-\hat{y}| \]

◆ mean_absolute_percentage_error() [1/2]

auto VSTAT_NAMESPACE::metrics::mean_absolute_percentage_error ( first1,
std::sentinel_for< I > auto  last1,
first2 
) -> double
inlinenoexcept

Computes the mean absolute error.

Template Parameters
T

\[ \text{MAPE}(y, \hat{y}) = \frac{1}{n} \sum_{i=1}^{n} \frac{{}\left| y_i - \hat{y}_i \right|}{\max(\epsilon, \left| y_i \right|)} \]

where \(\epsilon\) = std::numeric_limits<T>::epsilon() is an arbitrarily small constant to prevent division by zero.

◆ mean_absolute_percentage_error() [2/2]

auto VSTAT_NAMESPACE::metrics::mean_absolute_percentage_error ( first1,
std::sentinel_for< I > auto  last1,
first2,
first3 
) -> double
inlinenoexcept

Weighted mean absolute percentage error.

\[ \text{WMAPE}(y, \hat{y}) = \displaystyle \frac{1}{\sum_i^n w_i} \frac{\sum_{i=1}^n w_i |y-\hat{y}|}{\max(\epsilon, \left| y_i \right|)} \]

◆ mean_squared_error() [1/2]

auto VSTAT_NAMESPACE::metrics::mean_squared_error ( first1,
std::sentinel_for< I > auto  last1,
first2 
) -> double
inlinenoexcept

Computes the mean squared error.

\[ \text{MSE}(y, \hat{y}) = \displaystyle \frac{1}{n} {\sum_{i=1}^n \left(y-\hat{y}\right)^2} \]

◆ mean_squared_error() [2/2]

auto VSTAT_NAMESPACE::metrics::mean_squared_error ( first1,
std::sentinel_for< I > auto  last1,
first2,
first3 
) -> double
inlinenoexcept

Computes the weighted mean squared error.

\[ \text{MSE}(y, \hat{y}) = {\displaystyle \frac{1}{\sum_{i=1}^n w_i}} \sum_{i=1}^n w_i \left(y-\hat{y}\right)^2 \]

◆ mean_squared_log_error() [1/2]

auto VSTAT_NAMESPACE::metrics::mean_squared_log_error ( first1,
std::sentinel_for< I > auto  last1,
first2 
) -> double
inlinenoexcept

Computes the mean squared logarithmic error.

\[ \text{MSLE}(y, \hat{y}) = \frac{1}{n} \sum_{i=1}^{n} (\log_e (1 + y_i) - \log_e (1 + \hat{y}_i) )^2 \]

◆ mean_squared_log_error() [2/2]

auto VSTAT_NAMESPACE::metrics::mean_squared_log_error ( first1,
std::sentinel_for< I > auto  last1,
first2,
first3 
) -> double
inlinenoexcept

Computes the weighted mean squared logarithmic error.

\[ \text{MSLE}(y, \hat{y}) = \frac{1}{\sum_{i=1}^n w_i} \sum_{i=1}^{n} w_i (\log_e (1 + y_i) - \log_e (1 + \hat{y}_i) )^2 \]

◆ poisson_neg_likelihood_loss() [1/2]

auto VSTAT_NAMESPACE::metrics::poisson_neg_likelihood_loss ( first1,
std::sentinel_for< I > auto  last1,
first2 
) -> double
inlinenoexcept

Negative log likelihood loss with Poisson distribution of target.

\[ -\log\mathcal{L}_\text{poisson}(y, \hat{y}) = \hat{y} - y \cdot \log(\hat{y}) + \ln(|\Gamma(y)|) \]

where \(\Gamma(y)\) is returned by eve::gamma_p.

◆ poisson_neg_likelihood_loss() [2/2]

auto VSTAT_NAMESPACE::metrics::poisson_neg_likelihood_loss ( first1,
std::sentinel_for< I > auto  last1,
first2,
first3 
) -> double
inlinenoexcept

Negative log likelihood loss with Poisson distribution of target. The mean in each bin is multiplied by a weight before the Poisson likelihood is applied.

\[ -\log\mathcal{L}_\text{poisson}(y, w \cdot \hat{y}) = \hat{y} - y \cdot \log(\hat{y}) + \ln(|\Gamma(y)|) \]

where \(\Gamma(y)\) is returned by eve::gamma_p.

◆ r2_score() [1/2]

auto VSTAT_NAMESPACE::metrics::r2_score ( first1,
std::sentinel_for< I > auto  last1,
first2 
) -> double
inlinenoexcept

Computes the coefficient of determination \(R^2\).

Template Parameters
TThe scalar value type underlying the eve::wide<T> SIMD type used to compute the stats

\begin{align} R^2(y, \hat{y}) &= 1 - \frac{\text{RSS}}{\text{TSS}}\text{, where}\\ \text{RSS} &= \sum_{i=1}^n \left( y - \hat{y} \right)^2\\ \text{TSS} &= \sum_{i=1}^n \left( y - \bar{y} \right)^2\\ \end{align}

◆ r2_score() [2/2]

auto VSTAT_NAMESPACE::metrics::r2_score ( first1,
std::sentinel_for< I > auto  last1,
first2,
first3 
) -> double
inlinenoexcept

Computes the weighted coefficient of determination \(R^2\).

\begin{align} R^2(y, \hat{y}) &= 1 - \frac{\text{RSS}}{\text{TSS}}\text{, where}\\ \text{RSS} &= \sum_{i=1}^n w_i \left( y - \hat{y} \right)^2\\ \text{TSS} &= \sum_{i=1}^n w_i \left( y - \bar{y} \right)^2\\ \end{align}