75 const double *x,
const double *y)
79 for (
int i = 0; i <
xcsf->y_dim; ++i) {
84 for (
int i = 0; i <
xcsf->y_dim; ++i) {
114 printf(
"%s\n", json_str);
203 cJSON *json = cJSON_CreateObject();
204 cJSON_AddStringToObject(json,
"type",
"constant");
205 cJSON *prediction = cJSON_CreateDoubleArray(c->
prediction,
xcsf->y_dim);
206 cJSON_AddItemToObject(json,
"prediction", prediction);
207 char *
string = cJSON_Print(json);
222 const cJSON *item = cJSON_GetObjectItem(json,
"prediction");
223 if (item != NULL && cJSON_IsArray(item)) {
224 if (cJSON_GetArraySize(item) ==
xcsf->y_dim) {
225 for (
int i = 0; i <
xcsf->y_dim; ++i) {
226 const cJSON *item_i = cJSON_GetArrayItem(item, i);
230 printf(
"Import error: prediction length mismatch\n");
size_t pred_constant_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Dummy function since constant predictions have no data structure.
void pred_constant_init(const struct XCSF *xcsf, struct Cl *c)
Dummy function since constant predictions have no data structure.
void pred_constant_free(const struct XCSF *xcsf, const struct Cl *c)
Dummy function since constant predictions have no data structure.
void pred_constant_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Dummy function since constant predictions are not computed.
void pred_constant_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a constant prediction from a cJSON object.
bool pred_constant_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy function since constant predictions do not perform crossover.
double pred_constant_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a constant prediction.
void pred_constant_print(const struct XCSF *xcsf, const struct Cl *c)
Prints a constant prediction.
void pred_constant_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Updates a constant prediction for a given input and truth sample.
bool pred_constant_mutate(const struct XCSF *xcsf, const struct Cl *c)
Dummy function since constant predictions do not perform mutation.
void pred_constant_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Dummy function since constant predictions have no data structure.
char * pred_constant_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a prediction.
size_t pred_constant_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Dummy function since constant predictions have no data structure.
Piece-wise constant prediction functions.
Classifier data structure.
double * prediction
Current classifier prediction.
Utility functions for random number handling, etc.