/* File name: estimate_error.h Created by: Ljubomir Buturovic Created: 03/23/2005 Purpose: Bayes error estimation API. */ /* 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. */ #define CLASS_C1 0 #define CLASS_C2 1 #define CLASS_NONE -1 #define IDX_NONE -1 /* Keywords used in Bayes error estimation output file. */ #define LEAVE_ONE_OUT "leave-one-out" #define RESUBSTITUTION "resubstitution" /* Log-likelihood ratio for a vector from 'category'. */ struct LLR { float llr; int category; }; /* Calculate leave-one-out k-NN estimate of Bayes error for set of 'nv' vectors in 'x'. The vectors are 'd'-dimensional and the number of classes is 'c', with 'nd[i]' vectors in class i. 'sigma[i]' is covariance matrix of class i in SSM. 'det[i]' is natural log of the determinant of the covariance matrix. The estimates are calculated for k between 'kmin' and 'kmax', inclusive. Send messages to 'outdev', debug information to 'fdbg'. In case of error, return (float *) 0 and set 'errc'. */ float *L_error(float **x, int nv, int d, int c, int *nd, float **sigma, float *det, int kmin, int kmax, FILE *outdev, FILE *fdbg, int *errc); /* Calculate inverted covariance matrices of `c' classes in `x' in SSM format. */ float **calc_sig(float **x, int c, int d, int *nd, float **det, int *errc);