XCSF 1.4.8
XCSF learning classifier system
Loading...
Searching...
No Matches
pred_rls.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 "prediction.h"
27#include "xcsf.h"
28
32struct PredRLS {
33 int n;
35 double *weights;
36 double *matrix;
37 double *tmp_input;
38 double *tmp_vec;
39 double *tmp_matrix1;
40 double *tmp_matrix2;
41};
42
43char *
45
46char *
47pred_rls_param_json_import(struct XCSF *xcsf, cJSON *json);
48
49bool
50pred_rls_crossover(const struct XCSF *xcsf, const struct Cl *c1,
51 const struct Cl *c2);
52
53bool
54pred_rls_mutate(const struct XCSF *xcsf, const struct Cl *c);
55
56double
57pred_rls_size(const struct XCSF *xcsf, const struct Cl *c);
58
59size_t
60pred_rls_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
61
62size_t
63pred_rls_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
64
65void
66pred_rls_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x);
67
68void
69pred_rls_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src);
70
71void
72pred_rls_free(const struct XCSF *xcsf, const struct Cl *c);
73
74void
75pred_rls_init(const struct XCSF *xcsf, struct Cl *c);
76
77void
78pred_rls_print(const struct XCSF *xcsf, const struct Cl *c);
79
80void
81pred_rls_update(const struct XCSF *xcsf, const struct Cl *c, const double *x,
82 const double *y);
83
84char *
85pred_rls_json_export(const struct XCSF *xcsf, const struct Cl *c);
86
87void
88pred_rls_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json);
89
void pred_rls_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by an RLS prediction.
Definition pred_rls.c:84
void pred_rls_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies an RLS prediction from one classifier to another.
Definition pred_rls.c:69
void pred_rls_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Updates an RLS prediction for a given input and truth sample.
Definition pred_rls.c:106
double pred_rls_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of an RLS prediction.
Definition pred_rls.c:220
static struct PredVtbl const pred_rls_vtbl
Recursive least mean squares prediction implemented functions.
Definition pred_rls.h:93
void pred_rls_init(const struct XCSF *xcsf, struct Cl *c)
Initialises an RLS prediction.
Definition pred_rls.c:34
char * pred_rls_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the RLS parameters from a cJSON object.
Definition pred_rls.c:342
size_t pred_rls_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads an RLS prediction from a file.
Definition pred_rls.c:256
void pred_rls_print(const struct XCSF *xcsf, const struct Cl *c)
Prints an RLS prediction.
Definition pred_rls.c:175
char * pred_rls_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of an RLS prediction.
Definition pred_rls.c:276
char * pred_rls_param_json_export(const struct XCSF *xcsf)
Returns a json formatted string of the RLS parameters.
Definition pred_rls.c:323
void pred_rls_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates an RLS prediction from a cJSON object.
Definition pred_rls.c:299
bool pred_rls_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy function since RLS predictions do not perform crossover.
Definition pred_rls.c:190
void pred_rls_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Computes the current RLS prediction for a provided input.
Definition pred_rls.c:158
bool pred_rls_mutate(const struct XCSF *xcsf, const struct Cl *c)
Dummy function since RLS predictions do not perform mutation.
Definition pred_rls.c:206
size_t pred_rls_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes an RLS prediction to a file.
Definition pred_rls.c:235
Interface for classifier predictions.
Classifier data structure.
Definition xcsf.h:45
Recursive least mean squares prediction data structure.
Definition pred_rls.h:32
double * tmp_vec
Temporary storage for updating weights.
Definition pred_rls.h:38
double * tmp_input
Temporary storage for updating weights.
Definition pred_rls.h:37
double * matrix
Gain matrix used to update weights.
Definition pred_rls.h:36
int n
Number of weights for each predicted variable.
Definition pred_rls.h:33
double * weights
Weights used to compute prediction.
Definition pred_rls.h:35
int n_weights
Total number of weights.
Definition pred_rls.h:34
double * tmp_matrix2
Temporary storage for updating gain matrix.
Definition pred_rls.h:40
double * tmp_matrix1
Temporary storage for updating gain matrix.
Definition pred_rls.h:39
Prediction interface data structure.
Definition prediction.h:96
XCSF data structure.
Definition xcsf.h:85
XCSF data structures.