28 #define PRED_TYPE_INVALID (-1)
29 #define PRED_TYPE_CONSTANT (0)
30 #define PRED_TYPE_NLMS_LINEAR (1)
31 #define PRED_TYPE_NLMS_QUADRATIC (2)
32 #define PRED_TYPE_RLS_LINEAR (3)
33 #define PRED_TYPE_RLS_QUADRATIC (4)
34 #define PRED_TYPE_NEURAL (5)
36 #define PRED_STRING_CONSTANT ("constant\0")
37 #define PRED_STRING_NLMS_LINEAR ("nlms_linear\0")
38 #define PRED_STRING_NLMS_QUADRATIC ("nlms_quadratic\0")
39 #define PRED_STRING_RLS_LINEAR ("rls_linear\0")
40 #define PRED_STRING_RLS_QUADRATIC ("rls_quadratic\0")
41 #define PRED_STRING_NEURAL ("neural\0")
43 #define PRED_TYPE_OPTIONS \
44 "constant, nlms_linear, nlms_quadratic, rls_linear, rls_quadratic, " \
103 const struct Cl *src);
108 const double *x,
const double *y);
113 char *(*pred_impl_json_export)(
const struct XCSF *
xcsf,
const struct Cl *c);
275 const cJSON *item = cJSON_GetObjectItem(json,
"type");
276 if (item == NULL || !cJSON_IsString(item)) {
277 printf(
"pred_json_import(): missing type\n");
280 const char *type = item->valuestring;
282 printf(
"pred_json_import(): mismatched type\n");
283 printf(
"XCSF type = %s, but imported type = %s\n",
size_t pred_param_load(struct XCSF *xcsf, FILE *fp)
Loads prediction parameters.
void pred_param_free(struct XCSF *xcsf)
Frees prediction parameters.
const char * prediction_type_as_string(const int type)
Returns a string representation of a prediction type from the integer.
static double pred_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of the classifier prediction.
static char * pred_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a prediction.
static void pred_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a prediction from a cJSON object.
static bool pred_mutate(const struct XCSF *xcsf, const struct Cl *c)
Performs classifier prediction mutation.
size_t pred_param_save(const struct XCSF *xcsf, FILE *fp)
Saves prediction parameters.
int prediction_type_as_int(const char *type)
Returns the integer representation of a prediction type given a name.
void pred_param_set_x0(struct XCSF *xcsf, const double a)
static void pred_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Computes the current classifier prediction using the input.
static size_t pred_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes the prediction to a file.
int pred_param_set_type_string(struct XCSF *xcsf, const char *a)
void pred_param_set_lambda(struct XCSF *xcsf, const double a)
char * pred_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the prediction parameters from a cJSON object.
static void pred_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Updates the classifier's prediction.
void prediction_set(const struct XCSF *xcsf, struct Cl *c)
Sets a classifier's prediction functions to the implementations.
static void pred_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies the prediction from one classifier to another.
static bool pred_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Performs classifier prediction crossover.
void pred_param_set_type(struct XCSF *xcsf, const int a)
void pred_param_set_eta_min(struct XCSF *xcsf, const double a)
void pred_param_set_evolve_eta(struct XCSF *xcsf, const bool a)
void pred_param_set_eta(struct XCSF *xcsf, const double a)
static void pred_init(const struct XCSF *xcsf, struct Cl *c)
Initialises a classifier's prediction.
static void pred_print(const struct XCSF *xcsf, const struct Cl *c)
Prints the classifier prediction.
static size_t pred_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads the prediction from a file.
void pred_param_set_scale_factor(struct XCSF *xcsf, const double a)
void pred_transform_input(const struct XCSF *xcsf, const double *x, const double X0, double *tmp_input)
Prepares the input state for least squares computation.
static void pred_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by the classifier prediction.
void pred_param_defaults(struct XCSF *xcsf)
Initialises default prediction parameters.
char * pred_param_json_export(const struct XCSF *xcsf)
Returns a json formatted string of the prediction parameters.
Parameters for initialising a neural network layer.
int type
Layer type: CONNECTED, DROPOUT, etc.
Parameters for initialising and operating predictions.
double eta_min
Minimum gradient descent rate.
bool evolve_eta
Whether to evolve the gradient descent rate.
double scale_factor
Initial values for the RLS gain-matrix.
double x0
Prediction weight vector offset value.
struct ArgsLayer * largs
Linked-list of layer parameters.
int type
Classifier prediction type: least squares, etc.
double lambda
RLS forget rate.
double eta
Gradient descent rate.
Classifier data structure.
struct PredVtbl const * pred_vptr
Functions acting on predictions.
Prediction interface data structure.
bool(* pred_impl_mutate)(const struct XCSF *xcsf, const struct Cl *c)
void(* pred_impl_update)(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
void(* pred_impl_print)(const struct XCSF *xcsf, const struct Cl *c)
void(* pred_impl_init)(const struct XCSF *xcsf, struct Cl *c)
bool(* pred_impl_crossover)(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
char *(* pred_impl_json_export)(const struct XCSF *xcsf, const struct Cl *c)
double(* pred_impl_size)(const struct XCSF *xcsf, const struct Cl *c)
void(* pred_impl_copy)(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
void(* pred_impl_json_import)(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
size_t(* pred_impl_save)(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
void(* pred_impl_free)(const struct XCSF *xcsf, const struct Cl *c)
void(* pred_impl_compute)(const struct XCSF *xcsf, const struct Cl *c, const double *x)
size_t(* pred_impl_load)(const struct XCSF *xcsf, struct Cl *c, FILE *fp)