Regression Model Scoring#

Information Criterion#

#include <raft/stats/information_criterion.cuh>

namespace raft::stats

enum IC_Type#

Supported types of information criteria.

Values:

enumerator AIC#
enumerator AICc#
enumerator BIC#
template<typename value_t, typename idx_t>
void information_criterion_batched(raft::resources const &handle, raft::device_vector_view<const value_t, idx_t> d_loglikelihood, raft::device_vector_view<value_t, idx_t> d_ic, IC_Type ic_type, idx_t n_params, idx_t n_samples)#

Compute the given type of information criterion

Template Parameters:
  • value_t – data type

  • idx_t – index type

Parameters:
  • handle[in] the raft handle

  • d_loglikelihood[in] Log-likelihood for each series (device) length: batch_size

  • d_ic[out] Information criterion to be returned for each series (device) length: batch_size

  • ic_type[in] Type of criterion to compute. See IC_Type

  • n_params[in] Number of parameters in the model

  • n_samples[in] Number of samples in each series

R2 Score#

#include <raft/stats/r2_score.cuh>

namespace raft::stats

template<typename value_t, typename idx_t>
value_t r2_score(raft::resources const &handle, raft::device_vector_view<const value_t, idx_t> y, raft::device_vector_view<const value_t, idx_t> y_hat)#

Calculates the “Coefficient of Determination” (R-Squared) score normalizing the sum of squared errors by the total sum of squares.

This score indicates the proportionate amount of variation in an expected response variable is explained by the independent variables in a linear regression model. The larger the R-squared value, the more variability is explained by the linear regression model.

Note

The constness of y and y_hat is currently casted away.

Template Parameters:
  • value_t – the data type

  • idx_t – index type

Parameters:
  • handle[in] the raft handle

  • y[in] Array of ground-truth response variables

  • y_hat[in] Array of predicted response variables

Returns:

: The R-squared value.

Regression Metrics#

#include <raft/stats/regression_metrics.cuh>

namespace raft::stats

template<typename value_t, typename idx_t>
void regression_metrics(raft::resources const &handle, raft::device_vector_view<const value_t, idx_t> predictions, raft::device_vector_view<const value_t, idx_t> ref_predictions, raft::host_scalar_view<double> mean_abs_error, raft::host_scalar_view<double> mean_squared_error, raft::host_scalar_view<double> median_abs_error)#

Compute regression metrics mean absolute error, mean squared error, median absolute error.

Template Parameters:
  • value_t – the data type for predictions (e.g., float or double for regression).

  • idx_t – index type

Parameters:
  • handle[in] the raft handle

  • predictions[in] array of predictions.

  • ref_predictions[in] array of reference (ground-truth) predictions.

  • mean_abs_error[out] Mean Absolute Error. Sum over n of (|predictions[i] - ref_predictions[i]|) / n.

  • mean_squared_error[out] Mean Squared Error. Sum over n of ((predictions[i] - ref_predictions[i])^2) / n.

  • median_abs_error[out] Median Absolute Error. Median of |predictions[i] - ref_predictions[i]| for i in [0, n).