XCSF  1.4.7
XCSF learning classifier system
prediction.c File Reference

Interface for classifier predictions. More...

#include "pred_constant.h"
#include "pred_neural.h"
#include "pred_nlms.h"
#include "pred_rls.h"
#include "utils.h"
Include dependency graph for prediction.c:

Go to the source code of this file.

Functions

void prediction_set (const struct XCSF *xcsf, struct Cl *c)
 Sets a classifier's prediction functions to the implementations. More...
 
const char * prediction_type_as_string (const int type)
 Returns a string representation of a prediction type from the integer. More...
 
int prediction_type_as_int (const char *type)
 Returns the integer representation of a prediction type given a name. More...
 
void pred_param_defaults (struct XCSF *xcsf)
 Initialises default prediction parameters. More...
 
char * pred_param_json_export (const struct XCSF *xcsf)
 Returns a json formatted string of the prediction parameters. More...
 
char * pred_param_json_import (struct XCSF *xcsf, cJSON *json)
 Sets the prediction parameters from a cJSON object. More...
 
size_t pred_param_save (const struct XCSF *xcsf, FILE *fp)
 Saves prediction parameters. More...
 
size_t pred_param_load (struct XCSF *xcsf, FILE *fp)
 Loads prediction parameters. More...
 
void pred_param_free (struct XCSF *xcsf)
 Frees prediction parameters. More...
 
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. More...
 
void pred_param_set_eta (struct XCSF *xcsf, const double a)
 
void pred_param_set_eta_min (struct XCSF *xcsf, const double a)
 
void pred_param_set_lambda (struct XCSF *xcsf, const double a)
 
void pred_param_set_scale_factor (struct XCSF *xcsf, const double a)
 
void pred_param_set_x0 (struct XCSF *xcsf, const double a)
 
void pred_param_set_evolve_eta (struct XCSF *xcsf, const bool a)
 
void pred_param_set_type (struct XCSF *xcsf, const int a)
 
int pred_param_set_type_string (struct XCSF *xcsf, const char *a)
 

Detailed Description

Interface for classifier predictions.

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

Definition in file prediction.c.

Function Documentation

◆ pred_param_defaults()

void pred_param_defaults ( struct XCSF xcsf)

Initialises default prediction parameters.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 120 of file prediction.c.

References pred_neural_param_defaults(), pred_param_set_eta(), pred_param_set_eta_min(), pred_param_set_evolve_eta(), pred_param_set_lambda(), pred_param_set_scale_factor(), pred_param_set_type(), pred_param_set_x0(), and PRED_TYPE_NLMS_LINEAR.

Referenced by param_init().

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

◆ pred_param_free()

void pred_param_free ( struct XCSF xcsf)

Frees prediction parameters.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 252 of file prediction.c.

References layer_args_free().

Referenced by param_free().

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

◆ pred_param_json_export()

char* pred_param_json_export ( const struct XCSF xcsf)

Returns a json formatted string of the prediction parameters.

Parameters
[in]xcsfXCSF data structure.
Returns
String encoded in json format.

Definition at line 138 of file prediction.c.

References layer_args_json_export(), pred_nlms_param_json_export(), pred_rls_param_json_export(), PRED_TYPE_NEURAL, PRED_TYPE_NLMS_LINEAR, PRED_TYPE_NLMS_QUADRATIC, PRED_TYPE_RLS_LINEAR, PRED_TYPE_RLS_QUADRATIC, prediction_type_as_string(), and ArgsPred::type.

Referenced by param_json_export().

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

◆ pred_param_json_import()

char* pred_param_json_import ( struct XCSF xcsf,
cJSON *  json 
)

Sets the prediction parameters from a cJSON object.

Parameters
[in,out]xcsfXCSF data structure.
[in]jsoncJSON object.
Returns
NULL if successful; or the name of parameter if not found.

Definition at line 179 of file prediction.c.

References pred_neural_param_json_import(), pred_nlms_param_json_import(), pred_rls_param_json_import(), PRED_TYPE_CONSTANT, PRED_TYPE_NEURAL, PRED_TYPE_NLMS_LINEAR, PRED_TYPE_NLMS_QUADRATIC, PRED_TYPE_RLS_LINEAR, and PRED_TYPE_RLS_QUADRATIC.

Referenced by param_json_import_prediction().

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

◆ pred_param_load()

size_t pred_param_load ( struct XCSF xcsf,
FILE *  fp 
)

Loads prediction parameters.

Parameters
[in]xcsfThe XCSF data structure.
[in]fpPointer to the output file.
Returns
The total number of elements written.

Definition at line 232 of file prediction.c.

References ArgsPred::eta, ArgsPred::eta_min, ArgsPred::evolve_eta, ArgsPred::lambda, ArgsPred::largs, layer_args_load(), ArgsPred::scale_factor, ArgsPred::type, and ArgsPred::x0.

Referenced by param_load().

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

◆ pred_param_save()

size_t pred_param_save ( const struct XCSF xcsf,
FILE *  fp 
)

Saves prediction parameters.

Parameters
[in]xcsfThe XCSF data structure.
[in]fpPointer to the output file.
Returns
The total number of elements written.

Definition at line 210 of file prediction.c.

References ArgsPred::eta, ArgsPred::eta_min, ArgsPred::evolve_eta, ArgsPred::lambda, ArgsPred::largs, layer_args_save(), ArgsPred::scale_factor, ArgsPred::type, and ArgsPred::x0.

Referenced by param_save().

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

◆ pred_param_set_eta()

void pred_param_set_eta ( struct XCSF xcsf,
const double  a 
)

Definition at line 291 of file prediction.c.

Referenced by pred_nlms_param_json_import(), and pred_param_defaults().

Here is the caller graph for this function:

◆ pred_param_set_eta_min()

void pred_param_set_eta_min ( struct XCSF xcsf,
const double  a 
)

Definition at line 305 of file prediction.c.

Referenced by pred_nlms_param_json_import(), and pred_param_defaults().

Here is the caller graph for this function:

◆ pred_param_set_evolve_eta()

void pred_param_set_evolve_eta ( struct XCSF xcsf,
const bool  a 
)

Definition at line 337 of file prediction.c.

Referenced by pred_nlms_param_json_import(), and pred_param_defaults().

Here is the caller graph for this function:

◆ pred_param_set_lambda()

void pred_param_set_lambda ( struct XCSF xcsf,
const double  a 
)

Definition at line 319 of file prediction.c.

Referenced by pred_param_defaults(), and pred_rls_param_json_import().

Here is the caller graph for this function:

◆ pred_param_set_scale_factor()

void pred_param_set_scale_factor ( struct XCSF xcsf,
const double  a 
)

Definition at line 325 of file prediction.c.

Referenced by pred_param_defaults(), and pred_rls_param_json_import().

Here is the caller graph for this function:

◆ pred_param_set_type()

void pred_param_set_type ( struct XCSF xcsf,
const int  a 
)

Definition at line 343 of file prediction.c.

Referenced by pred_param_defaults().

Here is the caller graph for this function:

◆ pred_param_set_type_string()

int pred_param_set_type_string ( struct XCSF xcsf,
const char *  a 
)

Definition at line 354 of file prediction.c.

References PRED_TYPE_INVALID, prediction_type_as_int(), and ArgsPred::type.

Referenced by param_json_import_prediction().

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

◆ pred_param_set_x0()

void pred_param_set_x0 ( struct XCSF xcsf,
const double  a 
)

Definition at line 331 of file prediction.c.

Referenced by pred_nlms_param_json_import(), pred_param_defaults(), and pred_rls_param_json_import().

Here is the caller graph for this function:

◆ pred_transform_input()

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.

Parameters
[in]xcsfThe XCSF data structure.
[in]xThe input state.
[in]X0Bias term.
[out]tmp_inputThe transformed input.

Definition at line 265 of file prediction.c.

References PRED_TYPE_NLMS_QUADRATIC, and PRED_TYPE_RLS_QUADRATIC.

Referenced by pred_nlms_compute(), and pred_rls_compute().

Here is the caller graph for this function:

◆ prediction_set()

void prediction_set ( const struct XCSF xcsf,
struct Cl c 
)

Sets a classifier's prediction functions to the implementations.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier to set.

Definition at line 36 of file prediction.c.

References pred_constant_vtbl, pred_neural_vtbl, pred_nlms_vtbl, pred_rls_vtbl, PRED_TYPE_CONSTANT, PRED_TYPE_NEURAL, PRED_TYPE_NLMS_LINEAR, PRED_TYPE_NLMS_QUADRATIC, PRED_TYPE_RLS_LINEAR, PRED_TYPE_RLS_QUADRATIC, and Cl::pred_vptr.

Referenced by cl_load(), and cl_rand().

Here is the caller graph for this function:

◆ prediction_type_as_int()

int prediction_type_as_int ( const char *  type)

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

Parameters
[in]typeString representation of a prediction type.
Returns
Integer representing the prediction type.

Definition at line 92 of file prediction.c.

References PRED_STRING_CONSTANT, PRED_STRING_NEURAL, PRED_STRING_NLMS_LINEAR, PRED_STRING_NLMS_QUADRATIC, PRED_STRING_RLS_LINEAR, PRED_STRING_RLS_QUADRATIC, PRED_TYPE_CONSTANT, PRED_TYPE_INVALID, PRED_TYPE_NEURAL, PRED_TYPE_NLMS_LINEAR, PRED_TYPE_NLMS_QUADRATIC, PRED_TYPE_RLS_LINEAR, and PRED_TYPE_RLS_QUADRATIC.

Referenced by pred_json_import(), and pred_param_set_type_string().

Here is the caller graph for this function:

◆ prediction_type_as_string()

const char* prediction_type_as_string ( const int  type)

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

Parameters
[in]typeInteger representation of a prediction type.
Returns
String representing the name of the prediction type.

Definition at line 65 of file prediction.c.

References PRED_STRING_CONSTANT, PRED_STRING_NEURAL, PRED_STRING_NLMS_LINEAR, PRED_STRING_NLMS_QUADRATIC, PRED_STRING_RLS_LINEAR, PRED_STRING_RLS_QUADRATIC, PRED_TYPE_CONSTANT, PRED_TYPE_NEURAL, PRED_TYPE_NLMS_LINEAR, PRED_TYPE_NLMS_QUADRATIC, PRED_TYPE_RLS_LINEAR, and PRED_TYPE_RLS_QUADRATIC.

Referenced by pred_json_import(), and pred_param_json_export().

Here is the caller graph for this function: