XCSF  1.4.7
XCSF learning classifier system
xcs_supervised.c File Reference

Supervised regression learning functions. More...

#include "xcs_supervised.h"
#include "clset.h"
#include "ea.h"
#include "loss.h"
#include "pa.h"
#include "param.h"
#include "perf.h"
#include "utils.h"
Include dependency graph for xcs_supervised.c:

Go to the source code of this file.

Functions

static int xcs_supervised_sample (const struct Input *data, const int cnt, const bool shuffle)
 Selects a data sample for training or testing. More...
 
static void xcs_supervised_trial (struct XCSF *xcsf, const double *x, const double *y, const double *cover)
 Executes a single XCSF trial. More...
 
double xcs_supervised_fit (struct XCSF *xcsf, const struct Input *train_data, const struct Input *test_data, const bool shuffle, const int start, const int trials)
 Executes MAX_TRIALS number of XCSF learning iterations using the training data and test iterations using the test data. More...
 
void xcs_supervised_predict (struct XCSF *xcsf, const double *x, double *pred, const int n_samples, const double *cover)
 Calculates the XCSF predictions for the provided input. More...
 
double xcs_supervised_score (struct XCSF *xcsf, const struct Input *data, const double *cover)
 Calculates the XCSF error for the input data. More...
 
double xcs_supervised_score_n (struct XCSF *xcsf, const struct Input *data, const int N, const double *cover)
 Calculates the XCSF error for a subsample of the input data. More...
 

Detailed Description

Supervised regression learning functions.

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

Definition in file xcs_supervised.c.

Function Documentation

◆ xcs_supervised_fit()

double xcs_supervised_fit ( struct XCSF xcsf,
const struct Input train_data,
const struct Input test_data,
const bool  shuffle,
const int  start,
const int  trials 
)

Executes MAX_TRIALS number of XCSF learning iterations using the training data and test iterations using the test data.

Parameters
[in]xcsfThe XCSF data structure.
[in]train_dataThe input data to use for training.
[in]test_dataThe input data to use for testing.
[in]shuffleWhether to randomise the instances during training.
[in]startIndex to begin sampling.
[in]trialsNumber of trials to execute.
Returns
The average XCSF training error using the loss function.

Definition at line 99 of file xcs_supervised.c.

References param_set_explore(), perf_print(), Input::x, Input::x_dim, xcs_supervised_sample(), xcs_supervised_trial(), Input::y, and Input::y_dim.

Referenced by XCS::fit(), and main().

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

◆ xcs_supervised_predict()

void xcs_supervised_predict ( struct XCSF xcsf,
const double *  x,
double *  pred,
const int  n_samples,
const double *  cover 
)

Calculates the XCSF predictions for the provided input.

Parameters
[in]xcsfThe XCSF data structure.
[in]xThe input feature variables.
[out]predThe calculated XCSF predictions.
[in]n_samplesThe number of instances.
[in]coverIf cover is not NULL and the match set is empty, the prediction array will be set to this value instead of covering.

Definition at line 141 of file xcs_supervised.c.

References param_set_explore(), and xcs_supervised_trial().

Referenced by XCS::predict().

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

◆ xcs_supervised_sample()

static int xcs_supervised_sample ( const struct Input data,
const int  cnt,
const bool  shuffle 
)
static

Selects a data sample for training or testing.

Parameters
[in]dataThe input data.
[in]cntThe current sequence counter.
[in]shuffleWhether to select the sample randomly.
Returns
The row of the data sample selected.

Definition at line 41 of file xcs_supervised.c.

References Input::n_samples, and rand_uniform_int().

Referenced by xcs_supervised_fit(), and xcs_supervised_score_n().

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

◆ xcs_supervised_score()

double xcs_supervised_score ( struct XCSF xcsf,
const struct Input data,
const double *  cover 
)

Calculates the XCSF error for the input data.

Parameters
[in]xcsfThe XCSF data structure.
[in]dataThe input data to calculate the error.
[in]coverIf cover is not NULL and the match set is empty, the prediction array will be set to this value instead of covering.
Returns
The average XCSF error using the loss function.

Definition at line 161 of file xcs_supervised.c.

References Input::n_samples, param_set_explore(), Input::x, Input::x_dim, xcs_supervised_trial(), Input::y, and Input::y_dim.

Referenced by XCS::fit(), XCS::score(), and xcs_supervised_score_n().

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

◆ xcs_supervised_score_n()

double xcs_supervised_score_n ( struct XCSF xcsf,
const struct Input data,
const int  N,
const double *  cover 
)

Calculates the XCSF error for a subsample of the input data.

Parameters
[in]xcsfThe XCSF data structure.
[in]dataThe input data to calculate the error.
[in]NThe maximum number of samples to draw randomly for scoring.
[in]coverIf cover is not NULL and the match set is empty, the prediction array will be set to this value instead of covering.
Returns
The average XCSF error using the loss function.

Definition at line 185 of file xcs_supervised.c.

References Input::n_samples, param_set_explore(), Input::x, Input::x_dim, xcs_supervised_sample(), xcs_supervised_score(), xcs_supervised_trial(), Input::y, and Input::y_dim.

Referenced by XCS::score().

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

◆ xcs_supervised_trial()

static void xcs_supervised_trial ( struct XCSF xcsf,
const double *  x,
const double *  y,
const double *  cover 
)
static

Executes a single XCSF trial.

Parameters
[in]xcsfThe XCSF data structure.
[in]xThe feature variables.
[in]yThe labelled variables.
[in]coverIf cover is not NULL and the match set is empty, the prediction array will be set to this value instead of covering.

Definition at line 59 of file xcs_supervised.c.

References clset_free(), clset_init(), clset_kill(), clset_match(), clset_update(), ea(), and pa_build().

Referenced by xcs_supervised_fit(), xcs_supervised_predict(), xcs_supervised_score(), and xcs_supervised_score_n().

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