include/lwpr.h

Go to the documentation of this file.
00001 /*********************************************************************
00002 LWPR: A library for incremental online learning
00003 Copyright (C) 2007  Stefan Klanke, Sethu Vijayakumar
00004 Contact: sethu.vijayakumar@ed.ac.uk
00005 
00006 This library is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU Lesser General Public
00008 License as published by the Free Software Foundation; either 
00009 version 2.1 of the License, or (at your option) any later version.
00010 
00011 This library is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 Library General Public License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public
00017 License along with this library; if not, write to the Free
00018 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 *********************************************************************/
00020 
00021 
00074 #ifndef __LWPR_H
00075 #define __LWPR_H
00076 
00077 #include <lwpr_config.h>
00078 
00079 #ifndef NUM_THREADS 
00080 #define NUM_THREADS   1
00081 #endif
00082 
00083 #if NUM_THREADS < 1 || NUM_THREADS > 32
00084 #error "NUM_THREADS must be a number between 1 and 32."
00085 #endif
00086 
00087 #ifndef LWPR_REGSTORE
00088 
00089 #define LWPR_REGSTORE   2
00090 
00092 #define LWPR_REGINCR    2
00093 #endif
00094 
00095 
00096 #ifdef __cplusplus
00097 extern "C" {
00098 #endif
00099 
00105 typedef enum {
00106    LWPR_GAUSSIAN_KERNEL, LWPR_BISQUARE_KERNEL
00107 } LWPR_Kernel;
00108 
00133 typedef struct {
00134    int nReg;           
00135    int nRegStore;      
00137    double *fixStorage; 
00138    double *varStorage; 
00140    int trustworthy;    
00141    int slopeReady;     
00142    double w;           
00143    double sum_e2;      
00144    double beta0;       
00145    double SSp;         
00147    double *D;          
00148    double *M;          
00149    double *alpha;      
00150    double *beta;       
00151    double *c;          
00152    double *SXresYres;  
00153    double *SSs2;       
00154    double *SSYres;     
00155    double *SSXres;     
00156    double *U;          
00157    double *P;          
00158    double *H;          
00159    double *r;          
00160    double *h;          
00161    double *b;          
00162    double *sum_w;      
00163    double *sum_e_cv2;  
00164    double *n_data;     
00165    double *lambda;     
00166    double *mean_x;     
00167    double *var_x;      
00168    double *s;          
00169    double *slope;      
00170    const struct LWPR_Model *model; 
00171 } LWPR_ReceptiveField;
00172 
00177 typedef struct {
00178    int numRFS;                
00179    int numPointers;           
00180    int n_pruned;              
00181    LWPR_ReceptiveField **rf;  
00182    const struct LWPR_Model *model;
00183 } LWPR_SubModel;
00184 
00194 typedef struct LWPR_Model {
00195    int nIn;             
00196    int nInStore;        
00197    int nOut;            
00198    int n_data;          
00200    double *mean_x;      
00201    double *var_x;       
00202    char *name;          
00203    int diag_only;       
00204    int meta;            
00205    double meta_rate;    
00206    double penalty;      
00207    double *init_alpha;  
00208    double *norm_in;     
00209    double *norm_out;    
00210    double *init_D;      
00211    double *init_M;      
00212    double w_gen;        
00213    double w_prune;      
00214    double init_lambda;  
00215    double final_lambda; 
00216    double tau_lambda;   
00217    double init_S2;      
00218    double add_threshold;
00219    LWPR_Kernel kernel;  
00220    int update_D;        
00221    LWPR_SubModel *sub;  
00222    struct LWPR_Workspace *ws;  
00224    double *storage;     
00226    double *xn;          
00227    double *yn;          
00229 #ifdef MATLAB
00230    int isPersistent;    
00236 #endif
00237 } LWPR_Model;
00238 
00250 void lwpr_predict(const LWPR_Model *model, const double *x, 
00251       double cutoff, double *y, double *conf, double *max_w);
00252 
00280 void lwpr_predict_J(const LWPR_Model *model, const double *x, 
00281       double cutoff, double *y, double *J);
00282       
00283       
00299 void lwpr_predict_JH(const LWPR_Model *model, const double *x, 
00300       double cutoff, double *y, double *J, double *H);      
00301 
00315 int lwpr_update(LWPR_Model *model, const double *x, const double *y, 
00316       double *yp, double *max_w);
00317 
00332 int lwpr_init_model(LWPR_Model *model, int nIn, int nOut, const char *name);
00333 
00363 void lwpr_free_model(LWPR_Model *model);
00364 
00373 int lwpr_set_init_alpha(LWPR_Model *model, double alpha);
00374 
00383 int lwpr_set_init_D_spherical(LWPR_Model *model, double sigma);
00384 
00394 int lwpr_set_init_D_diagonal(LWPR_Model *model, const double *d);
00395 
00408 int lwpr_set_init_D(LWPR_Model *model, const double *D, int stride);
00409 
00420 int lwpr_duplicate_model(LWPR_Model *dest, const LWPR_Model *src);
00421 
00422 #ifdef __cplusplus
00423 }
00424 #endif
00425 
00426 #endif
00427 

Generated on Wed Apr 2 13:44:42 2008 for LWPR Library by  doxygen 1.4.6