|
CNum 0.2.1
CPU-optimized ML library for C++
|
Classes | |
| struct | LossProfile |
| The loss, gradient, and hessian functions associated with a loss function. More... | |
Typedefs | |
| using | GHFunction = std::function< double(double, double) > |
| using | LossFunction |
Functions | |
| double | MSE_loss (const CNum::DataStructs::Matrix< double > &y, const CNum::DataStructs::Matrix< double > &y_pred) |
| Mean squared error. | |
| double | MSE_gradient (double y, double y_pred) |
| Calculate the gradient value of the mean squared error. | |
| double | MSE_hessian (double y, double y_pred) |
| Calculate the hessian (second order derivative) value of the mean squared error. | |
| double | RMSE_loss (const CNum::DataStructs::Matrix< double > &y, const CNum::DataStructs::Matrix< double > &y_pred) |
| Root mean squared error. | |
| double | binary_crossentropy_loss (const CNum::DataStructs::Matrix< double > &y, const CNum::DataStructs::Matrix< double > &y_pred) |
| Binary crossentropy (log loss). | |
| double | binary_crossentropy_gradient (double y, double y_pred) |
| Calculate the gradient of the log loss. | |
| double | binary_crossentropy_hessian (double y, double y_pred) |
| Calculate the hessian (second order derivative) of the log loss. | |
| void | get_gradients_hessians (const CNum::DataStructs::Matrix< double > &y, const CNum::DataStructs::Matrix< double > &y_pred, arena_view_t &g_out, arena_view_t &h_out, const arena_view_t &position_array, GHFunction &grad_func, GHFunction &hess_func) |
| Get the Gradients and Hessians of a Matrix. | |
| double | get_loss (const CNum::DataStructs::Matrix< double > &y, const CNum::DataStructs::Matrix< double > &y_pred, LossFunction &loss_func) |
| Get the loss of a matrix of values. | |
| LossProfile | get_loss_profile (::std::string loss) |
| Get the LossProfile associated with a string (i.e. "MSE" -> mean squared error function). | |
Loss functions.
| using CNum::Model::Loss::GHFunction = std::function< double(double, double) > |
| double CNum::Model::Loss::binary_crossentropy_gradient | ( | double | y, |
| double | y_pred ) |
Calculate the gradient of the log loss.
| y | A true y sample |
| y_pred | A predicted y sample |
| double CNum::Model::Loss::binary_crossentropy_hessian | ( | double | y, |
| double | y_pred ) |
Calculate the hessian (second order derivative) of the log loss.
| y | A true y sample |
| y_pred | A predicted y sample |
| double CNum::Model::Loss::binary_crossentropy_loss | ( | const CNum::DataStructs::Matrix< double > & | y, |
| const CNum::DataStructs::Matrix< double > & | y_pred ) |
Binary crossentropy (log loss).
| y | List of true y values (shape=(n,1)) |
| y_pred | List of predicted values (shape=(n,1)) |
| void CNum::Model::Loss::get_gradients_hessians | ( | const CNum::DataStructs::Matrix< double > & | y, |
| const CNum::DataStructs::Matrix< double > & | y_pred, | ||
| arena_view_t & | g_out, | ||
| arena_view_t & | h_out, | ||
| const arena_view_t & | position_array, | ||
| GHFunction & | grad_func, | ||
| GHFunction & | hess_func ) |
Get the Gradients and Hessians of a Matrix.
| y | List of true y values (shape=(n,1)) |
| y_pred | List of predicted values (shape=(n,1)) |
| g_out | The arena_view_t to output the gradient values to |
| h_out | The arena_view_t to output the hessian values to |
| position_array | The arena_view_t containing the partitioned indeces of the data (partitions are for keeping track of which samples tree nodes have to work with) |
| grad_func | The GHFunction for the gradient of the loss |
| hess_func | The GHFunction for the hessian of the loss |
| double CNum::Model::Loss::get_loss | ( | const CNum::DataStructs::Matrix< double > & | y, |
| const CNum::DataStructs::Matrix< double > & | y_pred, | ||
| LossFunction & | loss_func ) |
Get the loss of a matrix of values.
| y | List of true y values (shape=(n,1)) |
| y_pred | List of predicted values (shape=(n,1)) |
| loss_func | The LossFunction to use |
| LossProfile CNum::Model::Loss::get_loss_profile | ( | ::std::string | loss | ) |
Get the LossProfile associated with a string (i.e. "MSE" -> mean squared error function).
| loss | The name of the loss function |
| double CNum::Model::Loss::MSE_gradient | ( | double | y, |
| double | y_pred ) |
Calculate the gradient value of the mean squared error.
| y | A true y sample |
| y_pred | A predicted y sample |
| double CNum::Model::Loss::MSE_hessian | ( | double | y, |
| double | y_pred ) |
Calculate the hessian (second order derivative) value of the mean squared error.
| y | A true y sample |
| y_pred | A predicted y sample |
| double CNum::Model::Loss::MSE_loss | ( | const CNum::DataStructs::Matrix< double > & | y, |
| const CNum::DataStructs::Matrix< double > & | y_pred ) |
Mean squared error.
| y | List of true y values (shape=(n,1)) |
| y_pred | List of predicted values (shape=(n,1)) |
| double CNum::Model::Loss::RMSE_loss | ( | const CNum::DataStructs::Matrix< double > & | y, |
| const CNum::DataStructs::Matrix< double > & | y_pred ) |
Root mean squared error.
| y | List of true y values (shape=(n,1)) |
| y_pred | List of predicted values (shape=(n,1)) |