XCSF  1.4.7
XCSF learning classifier system
loss.c File Reference

Loss functions for calculating prediction error. More...

#include "loss.h"
#include "utils.h"
Include dependency graph for loss.c:

Go to the source code of this file.

Functions

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...
 
double loss_huber (const struct XCSF *xcsf, const double *pred, const double *y)
 Huber loss function. 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...
 

Detailed Description

Loss functions for calculating prediction error.

Author
Richard Preen rpree.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om
Date
2019–2022.

Definition in file loss.c.

Function Documentation

◆ loss_binary_log()

double loss_binary_log ( const struct XCSF xcsf,
const double *  pred,
const double *  y 
)

Binary logistic log loss for binary-class classification.

Parameters
[in]xcsfThe XCSF data structure.
[in]predThe predicted values.
[in]yThe true values.
Returns
The log error.

Definition at line 102 of file loss.c.

Referenced by loss_set_func().

Here is the caller graph for this function:

◆ loss_huber()

double loss_huber ( const struct XCSF xcsf,
const double *  pred,
const double *  y 
)

Huber loss function.

Parameters
[in]xcsfThe XCSF data structure.
[in]predThe predicted values.
[in]yThe true values.
Returns
The Huber loss.

Definition at line 137 of file loss.c.

Referenced by loss_set_func().

Here is the caller graph for this function:

◆ loss_log()

double loss_log ( const struct XCSF xcsf,
const double *  pred,
const double *  y 
)

Logistic log loss for multi-class classification.

Precondition
The sum of predictions = 1 and a single target y_i has a value of 1.
Parameters
[in]xcsfThe XCSF data structure.
[in]predThe predicted values.
[in]yThe true values.
Returns
The log error.

Definition at line 85 of file loss.c.

Referenced by loss_set_func().

Here is the caller graph for this function:

◆ loss_mae()

double loss_mae ( const struct XCSF xcsf,
const double *  pred,
const double *  y 
)

Mean absolute error loss function.

Parameters
[in]xcsfThe XCSF data structure.
[in]predThe predicted values.
[in]yThe true values.
Returns
The mean absolute error.

Definition at line 35 of file loss.c.

Referenced by loss_set_func().

Here is the caller graph for this function:

◆ loss_mse()

double loss_mse ( const struct XCSF xcsf,
const double *  pred,
const double *  y 
)

Mean squared error loss function.

Parameters
[in]xcsfThe XCSF data structure.
[in]predThe predicted values.
[in]yThe true values.
Returns
The mean squared error.

Definition at line 53 of file loss.c.

Referenced by loss_rmse(), and loss_set_func().

Here is the caller graph for this function:

◆ loss_onehot()

double loss_onehot ( const struct XCSF xcsf,
const double *  pred,
const double *  y 
)

One-hot classification error.

Parameters
[in]xcsfThe XCSF data structure.
[in]predThe predicted values.
[in]yThe true values.
Returns
The one-hot classification error.

Definition at line 120 of file loss.c.

References argmax().

Referenced by loss_set_func().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loss_rmse()

double loss_rmse ( const struct XCSF xcsf,
const double *  pred,
const double *  y 
)

Root mean squared error loss function.

Parameters
[in]xcsfThe XCSF data structure.
[in]predThe predicted values.
[in]yThe true values.
Returns
The root mean squared error.

Definition at line 71 of file loss.c.

References loss_mse().

Referenced by loss_set_func().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loss_set_func()

int loss_set_func ( struct XCSF xcsf)

Sets the XCSF error function to the implemented function.

Parameters
[in]xcsfThe XCSF data structure.
Returns
Integer representation of the loss function.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loss_type_as_int()

int loss_type_as_int ( const char *  type)

Returns the integer representation of a loss type given a name.

Parameters
[in]typeString representation of a loss function type.
Returns
Integer representing the 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().

Here is the caller graph for this function:

◆ loss_type_as_string()

const char* loss_type_as_string ( const int  type)

Returns a string representation of a loss type from the integer.

Parameters
[in]typeInteger representation of a loss function type.
Returns
String representing the name of the 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().

Here is the caller graph for this function: