/*
  File name: fselect.h
  Created by: Ljubomir Buturovic
  Created: 04/15/2005
  Purpose: feature selection declarations.
*/

/*
  Copyright 2005 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.
*/

/*
  Applies forward feature selection algorithm on the dataset
  dset - datset to select features from
  nfeat - number of features to select
  select_crit - ID of selection criteria
  l - number of features to simultaneously insert - complexity of this function 
  is exponentialy dependent on this value so supplying anything more than 1 
  should not be considered lightly
  val_crit - value of criteria function for resulting feature set
  errc - error code from criteria function if any

  returns - internaly allocated array of 0-based feature indices or NULL
  in case of failure. Caller is responsible for deallocation.
 */
int *forward_select(struct dataset *dset, int nfeat, int select_crit, 
		    int l, double *val_crit, int *errc);

/*
  Applies backward feature selection algorithm on the dataset
  dset - datset to select features from
  nfeat - number of features to select
  select_crit - ID of selection criteria
  l - number of features to simultaneously remove - complexity of this function 
  is exponentialy dependent on this value so supplying anything more than 1 
  should not be considered lightly
  val_crit - value of criteria function for resulting feature set
  errc - error code from criteria function if any

  returns - internaly allocated array of 0-based feature indices or NULL
  in case of failure. Caller is responsible for deallocation.
 */
int *backward_select(struct dataset *dset, int nfeat, int select_crit, 
		    int r, double *val_crit, int *errc);

/*
  Applies Pudil's floating forward feature selection algorithm on the dataset
  dset - datset to select features from
  nfeat - number of features to select
  select_crit - ID of selection criteria
  val_crit (out) - value of criteria function for resulting feature set
  current_attrs (out) - actual number of attributes in result set
  errc (out) - error code from criteria function if any

  returns - internaly allocated array of 0-based feature indices or NULL
  in case of failure. Caller is responsible for deallocation.
 */
int *float_fwd_select(struct dataset *dset, int nfeat, int select_crit, 
		      double *val_crit, int* current_attrs, int *errc);

/*
  Compute optimal subset of `d' features in `dset' using feature
  selection method `fsel_method' and feature subset evaluation
  criterion `fscrit'. If `dsflag' is 1, return the optimal-feature
  subset of `dset'.  If `index' is not NULL, return 0-based indices of
  selected features in 'index'.
  
  In case of error, return NULL and set errc.  However, if `dsflag' is
  0, the function returns NULL, so you have to check errc for errors.
*/
struct dataset *select_subset(struct dataset *dset, int d, int fsel_method, int fscrit, 
			      int **index, int dsflag, int *errc);


syntax highlighted by Code2HTML, v. 0.9.1