XCSF
1.4.7
XCSF learning classifier system
|
Loss functions for calculating prediction error. More...
#include "xcsf.h"
Go to the source code of this file.
Macros | |
#define | LOSS_INVALID (-1) |
Error code for invalid loss type. More... | |
#define | LOSS_MAE (0) |
Mean absolute error. More... | |
#define | LOSS_MSE (1) |
Mean squared error. More... | |
#define | LOSS_RMSE (2) |
Root mean squared error. More... | |
#define | LOSS_LOG (3) |
Log loss. More... | |
#define | LOSS_BINARY_LOG (4) |
Binary log loss. More... | |
#define | LOSS_ONEHOT (5) |
One-hot encoding classification error. More... | |
#define | LOSS_HUBER (6) |
Huber loss. More... | |
#define | LOSS_NUM (7) |
Total number of selectable loss functions. More... | |
#define | LOSS_STRING_MAE ("mae\0") |
Mean absolute error. More... | |
#define | LOSS_STRING_MSE ("mse\0") |
Mean squared error. More... | |
#define | LOSS_STRING_RMSE ("rmse\0") |
Root mean squared error. More... | |
#define | LOSS_STRING_LOG ("log\0") |
Log loss. More... | |
#define | LOSS_STRING_BINARY_LOG ("binary_log\0") |
Binary log loss. More... | |
#define | LOSS_STRING_ONEHOT ("onehot\0") |
One-hot classification error. More... | |
#define | LOSS_STRING_HUBER ("huber\0") |
Huber loss. More... | |
#define | LOSS_OPTIONS "mae, mse, rmse, log, binary_log, one_hot, huber" |
Functions | |
double | loss_huber (const struct XCSF *xcsf, const double *pred, const double *y) |
Huber loss function. More... | |
double | loss_mae (const struct XCSF *xcsf, const double *pred, const double *y) |
Mean absolute error loss function. More... | |
double | loss_mse (const struct XCSF *xcsf, const double *pred, const double *y) |
Mean squared error loss function. More... | |
double | loss_rmse (const struct XCSF *xcsf, const double *pred, const double *y) |
Root mean squared error loss function. More... | |
double | loss_log (const struct XCSF *xcsf, const double *pred, const double *y) |
Logistic log loss for multi-class classification. More... | |
double | loss_binary_log (const struct XCSF *xcsf, const double *pred, const double *y) |
Binary logistic log loss for binary-class classification. More... | |
double | loss_onehot (const struct XCSF *xcsf, const double *pred, const double *y) |
One-hot classification error. More... | |
int | loss_set_func (struct XCSF *xcsf) |
Sets the XCSF error function to the implemented function. More... | |
const char * | loss_type_as_string (const int type) |
Returns a string representation of a loss type from the integer. More... | |
int | loss_type_as_int (const char *type) |
Returns the integer representation of a loss type given a name. More... | |
Loss functions for calculating prediction error.
Definition in file loss.h.
#define LOSS_NUM (7) |
#define LOSS_ONEHOT (5) |
#define LOSS_OPTIONS "mae, mse, rmse, log, binary_log, one_hot, huber" |
#define LOSS_STRING_BINARY_LOG ("binary_log\0") |
#define LOSS_STRING_ONEHOT ("onehot\0") |
double loss_binary_log | ( | const struct XCSF * | xcsf, |
const double * | pred, | ||
const double * | y | ||
) |
Binary logistic log loss for binary-class classification.
[in] | xcsf | The XCSF data structure. |
[in] | pred | The predicted values. |
[in] | y | The true values. |
Definition at line 102 of file loss.c.
Referenced by loss_set_func().
double loss_huber | ( | const struct XCSF * | xcsf, |
const double * | pred, | ||
const double * | y | ||
) |
Huber loss function.
[in] | xcsf | The XCSF data structure. |
[in] | pred | The predicted values. |
[in] | y | The true values. |
Definition at line 137 of file loss.c.
Referenced by loss_set_func().
double loss_log | ( | const struct XCSF * | xcsf, |
const double * | pred, | ||
const double * | y | ||
) |
Logistic log loss for multi-class classification.
[in] | xcsf | The XCSF data structure. |
[in] | pred | The predicted values. |
[in] | y | The true values. |
Definition at line 85 of file loss.c.
Referenced by loss_set_func().
double loss_mae | ( | const struct XCSF * | xcsf, |
const double * | pred, | ||
const double * | y | ||
) |
Mean absolute error loss function.
[in] | xcsf | The XCSF data structure. |
[in] | pred | The predicted values. |
[in] | y | The true values. |
Definition at line 35 of file loss.c.
Referenced by loss_set_func().
double loss_mse | ( | const struct XCSF * | xcsf, |
const double * | pred, | ||
const double * | y | ||
) |
Mean squared error loss function.
[in] | xcsf | The XCSF data structure. |
[in] | pred | The predicted values. |
[in] | y | The true values. |
Definition at line 53 of file loss.c.
Referenced by loss_rmse(), and loss_set_func().
double loss_onehot | ( | const struct XCSF * | xcsf, |
const double * | pred, | ||
const double * | y | ||
) |
One-hot classification error.
[in] | xcsf | The XCSF data structure. |
[in] | pred | The predicted values. |
[in] | y | The true values. |
Definition at line 120 of file loss.c.
References argmax().
Referenced by loss_set_func().
double loss_rmse | ( | const struct XCSF * | xcsf, |
const double * | pred, | ||
const double * | y | ||
) |
Root mean squared error loss function.
[in] | xcsf | The XCSF data structure. |
[in] | pred | The predicted values. |
[in] | y | The true values. |
Definition at line 71 of file loss.c.
References loss_mse().
Referenced by loss_set_func().
int loss_set_func | ( | struct XCSF * | xcsf | ) |
Sets the XCSF error function to the implemented function.
[in] | xcsf | The XCSF data structure. |
Definition at line 159 of file loss.c.
References loss_binary_log(), LOSS_BINARY_LOG, loss_huber(), LOSS_HUBER, LOSS_INVALID, loss_log(), LOSS_LOG, loss_mae(), LOSS_MAE, loss_mse(), LOSS_MSE, loss_onehot(), LOSS_ONEHOT, loss_rmse(), and LOSS_RMSE.
Referenced by param_load(), param_set_loss_func(), and param_set_loss_func_string().
int loss_type_as_int | ( | const char * | type | ) |
Returns the integer representation of a loss type given a name.
[in] | type | String representation of a loss function type. |
Definition at line 223 of file loss.c.
References LOSS_BINARY_LOG, LOSS_HUBER, LOSS_INVALID, LOSS_LOG, LOSS_MAE, LOSS_MSE, LOSS_ONEHOT, LOSS_RMSE, LOSS_STRING_BINARY_LOG, LOSS_STRING_HUBER, LOSS_STRING_LOG, LOSS_STRING_MAE, LOSS_STRING_MSE, LOSS_STRING_ONEHOT, and LOSS_STRING_RMSE.
Referenced by param_set_loss_func_string().
const char* loss_type_as_string | ( | const int | type | ) |
Returns a string representation of a loss type from the integer.
[in] | type | Integer representation of a loss function type. |
Definition at line 194 of file loss.c.
References LOSS_BINARY_LOG, LOSS_HUBER, LOSS_LOG, LOSS_MAE, LOSS_MSE, LOSS_ONEHOT, LOSS_RMSE, LOSS_STRING_BINARY_LOG, LOSS_STRING_HUBER, LOSS_STRING_LOG, LOSS_STRING_MAE, LOSS_STRING_MSE, LOSS_STRING_ONEHOT, and LOSS_STRING_RMSE.
Referenced by param_json_export().