XCSF  1.4.7
XCSF learning classifier system
loss.h
Go to the documentation of this file.
1 /*
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
24 #pragma once
25 
26 #include "xcsf.h"
27 
28 #define LOSS_INVALID (-1)
29 #define LOSS_MAE (0)
30 #define LOSS_MSE (1)
31 #define LOSS_RMSE (2)
32 #define LOSS_LOG (3)
33 #define LOSS_BINARY_LOG (4)
34 #define LOSS_ONEHOT (5)
35 #define LOSS_HUBER (6)
36 #define LOSS_NUM (7)
37 
38 #define LOSS_STRING_MAE ("mae\0")
39 #define LOSS_STRING_MSE ("mse\0")
40 #define LOSS_STRING_RMSE ("rmse\0")
41 #define LOSS_STRING_LOG ("log\0")
42 #define LOSS_STRING_BINARY_LOG ("binary_log\0")
43 #define LOSS_STRING_ONEHOT ("onehot\0")
44 #define LOSS_STRING_HUBER ("huber\0")
45 
46 #define LOSS_OPTIONS "mae, mse, rmse, log, binary_log, one_hot, huber"
47 
48 double
49 loss_huber(const struct XCSF *xcsf, const double *pred, const double *y);
50 
51 double
52 loss_mae(const struct XCSF *xcsf, const double *pred, const double *y);
53 
54 double
55 loss_mse(const struct XCSF *xcsf, const double *pred, const double *y);
56 
57 double
58 loss_rmse(const struct XCSF *xcsf, const double *pred, const double *y);
59 
60 double
61 loss_log(const struct XCSF *xcsf, const double *pred, const double *y);
62 
63 double
64 loss_binary_log(const struct XCSF *xcsf, const double *pred, const double *y);
65 
66 double
67 loss_onehot(const struct XCSF *xcsf, const double *pred, const double *y);
68 
69 int
70 loss_set_func(struct XCSF *xcsf);
71 
72 const char *
73 loss_type_as_string(const int type);
74 
75 int
76 loss_type_as_int(const char *type);
double loss_binary_log(const struct XCSF *xcsf, const double *pred, const double *y)
Binary logistic log loss for binary-class classification.
Definition: loss.c:102
double loss_rmse(const struct XCSF *xcsf, const double *pred, const double *y)
Root mean squared error loss function.
Definition: loss.c:71
double loss_onehot(const struct XCSF *xcsf, const double *pred, const double *y)
One-hot classification error.
Definition: loss.c:120
double loss_log(const struct XCSF *xcsf, const double *pred, const double *y)
Logistic log loss for multi-class classification.
Definition: loss.c:85
int loss_type_as_int(const char *type)
Returns the integer representation of a loss type given a name.
Definition: loss.c:223
double loss_mae(const struct XCSF *xcsf, const double *pred, const double *y)
Mean absolute error loss function.
Definition: loss.c:35
double loss_mse(const struct XCSF *xcsf, const double *pred, const double *y)
Mean squared error loss function.
Definition: loss.c:53
int loss_set_func(struct XCSF *xcsf)
Sets the XCSF error function to the implemented function.
Definition: loss.c:159
double loss_huber(const struct XCSF *xcsf, const double *pred, const double *y)
Huber loss function.
Definition: loss.c:137
const char * loss_type_as_string(const int type)
Returns a string representation of a loss type from the integer.
Definition: loss.c:194
Definition: __init__.py:1
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.