datafeeder.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #ifndef __LEMGA_DATAFEEDER_H__
00003 #define __LEMGA_DATAFEEDER_H__
00004 
00011 #include <iostream>
00012 #include "learnmodel.h"
00013 
00014 namespace lemga {
00015 
00018 class DataFeeder {
00019 public:
00020     enum NORMETHOD {   // normalization method
00021         MIN_MAX,       // make min -1, max +1
00022         MEAN_VAR,      // make mean 0, var 1
00023         NONE
00024     };
00025 
00026 private:
00027     pDataSet dat;
00028     std::istream* perms;
00029     NORMETHOD _do_normalize;
00030     UINT fsize, tr_size;
00031     REAL tr_flip;
00032 
00033 public:
00034     DataFeeder (const pDataSet&);
00035     DataFeeder (std::istream&);
00036 
00037     void set_permutation (std::istream& i) { perms = &i; }
00038     void do_normalize (NORMETHOD dn = MIN_MAX) { _do_normalize = dn; }
00039     UINT size () const { return fsize; }
00041     UINT train_size () const { return tr_size; }
00043     void set_train_size (UINT);
00045     REAL train_noise () const { return tr_flip; }
00047     void set_train_noise (REAL);
00048 
00049     pDataSet data () const { return dat; }
00050     bool next_train_test (pDataSet&, pDataSet&) const;
00051 
00052 protected:
00053     bool next_permutation (std::vector<UINT>&) const;
00054 
00055     struct LINEAR_SCALE_PARAM {
00056         REAL center, scale;
00057     };
00058     typedef std::vector<LINEAR_SCALE_PARAM> LINEAR_SCALE_PARAMS;
00059 
00060     static LINEAR_SCALE_PARAMS min_max (DataSet&);
00061     static LINEAR_SCALE_PARAMS mean_var (DataSet&);
00062     static void linear_scale (DataSet&, const LINEAR_SCALE_PARAMS&);
00063 };
00064 
00065 } // namespace lemga
00066 
00067 #ifdef  __DATAFEEDER_H__
00068 #warning "This header file may conflict with another `datafeeder.h' file."
00069 #endif
00070 #define __DATAFEEDER_H__
00071 #endif

Generated on Wed Nov 8 08:15:21 2006 for LEMGA by  doxygen 1.4.6