/*
File name: xlearn.h
Created by: Ljubomir Buturovic
Created: 03/02/2005
Purpose: declarations of universal cross-validation functions.
*/
/*
Copyright 2004 Ljubomir J. Buturovic
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <stdio.h>
#include "dataset.h"
/*
Partition each of the 'c' classes with 'nd[i]' vectors per class,
into 'nxval' disjoint subsets. The resulting partition is specified
in 'sxc' and 'lxc' arrays.
Local arrays 'tsxc' and 'tlxc' have list of vectors in each subset,
and subset cardinalities, respectively. 'tsxc[i]' and 'tlxc[i]' are
pointers to 'sx' and 'lx' arrays, respectively, for class 'i', as
described in comments for xss(). The addresses of 'tsxc' and 'tlxc'
are returned in '*sxc' and '*lxc'.
The function may be used for cross-validation experiments, to return
all subsets. Then the subsets may be analyzed one at a time.
The function returns -1 and sets errno in case of malloc() failure,
0 otherwise. If 'nxval' is not in a correct range for any class, set
'sxc' and 'lxc' to NULL.
*/
int xpart(int c, int *nd, int nxval, int ***sxc, int ***lxc);
/*
Create learning and validation subsets of `dset' as specified by
`lxc', `sxc'. See xpart() for details.
*/
int xset(struct dataset *dset, int **lxc, int **sxc, int idx,
struct dataset **learning_dset, struct dataset **validation_dset,
FILE *fdbg);
/*
Train classifier `method' on `learning_dset', test it on
`validation_dset', and report cumulative and class-conditional error
counts. Algorithm-specific parameters of `method' are stored in
`options'.
Optionally reduce dimension of the training/validation data sets to
`idr' using `dr_method'. If `dr_method' is a feature selection
method, use `fscrit' feature subset evaluation criterion.
If `normalize' is 1, normalize the data sets before applying the
learning method and dimension reduction. NOTE: this will change
'learning_dset' and 'validation_dset'. Otherwise, the sets are
unchanged on return from xlearn().
`nmodels' is the number of models for bagging/Adaboost methods.
The function returns the number of misclassified samples, and sets
class-conditional error counts in `ccer'. In case of failure,
returns -1 and sets `errc'.
*/
int xlearn(int method, int dr_method, int idr, int fscrit, int normalize,
struct dataset *learning_dset, struct dataset *validation_dset,
unsigned int seed, int nmodels, int bag_size, void *options,
int **ccer, FILE *outdev, FILE *fdbg, int *errc);
/*
Return average error rate (in percentages) of `nexp' `nxval'-fold
cross-validation experiments for classifier `method', using `dset'.
In case of error, return -1.0 and set `errc'.
TBD: currently only supports PALG_KNN method.
*/
float xlearn_machine(struct dataset *dset, int method, int nexp, int nxval, int *errc);
/*
Reduce dimensionality of 'learning_dset' and 'validation_dset'. The
processed data sets are returned in 'l_dset' and 'v_dset',
respectively. The dimensionality reduction is performed using
'dr_method'. The number of attributes retained is 'idr'. 'fscrit' is
the feature subset evaluation criterion used for feature subset
selection methods.
Note that the processing is fully cross-validated: the
dimensionality reduction parameters are computed using the training
set, and applied to both sets.
In case of success, return 0. In case of failure, return -1 and set
errc.
TBD: where should this function go?
*/
int reduce_d(struct dataset *learning_dset, struct dataset *validation_dset,
struct dataset **l_dset, struct dataset **v_dset,
int dr_method, int idr, int fscrit, int *errc);
/*
Normalize attributes in 'learning_dset' and 'validation_dset'. The
normalization attributes are computed on 'learning_dset', then
applied to both datasets.
In case of success, return 0. Otherwise return -1 and set errno. The
possible failures are memory allocation errors.
*/
int normalize_attributes(struct dataset *learning_dset, struct dataset *validation_dset);
syntax highlighted by Code2HTML, v. 0.9.1