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, train_size;
00031 
00032 public:
00033     DataFeeder (const pDataSet&);
00034     DataFeeder (std::istream&);
00035 
00036     void set_permutation (std::istream& i) { perms = &i; }
00037     void do_normalize (NORMETHOD dn = MIN_MAX) { _do_normalize = dn; }
00038     UINT size () const { return fsize; }
00039     void set_train_size (UINT);
00040 
00041     pDataSet data () const { return dat; }
00042     bool next_train_test (pDataSet&, pDataSet&) const;
00043 
00044 protected:
00045     bool next_permutation (std::vector<UINT>&) const;
00046 
00047     struct LINEAR_SCALE_PARAM {
00048         REAL center, scale;
00049     };
00050     typedef std::vector<LINEAR_SCALE_PARAM> LINEAR_SCALE_PARAMS;
00051 
00052     static LINEAR_SCALE_PARAMS min_max (DataSet&);
00053     static LINEAR_SCALE_PARAMS mean_var (DataSet&);
00054     static void linear_scale (DataSet&, const LINEAR_SCALE_PARAMS&);
00055 };
00056 
00057 } // namespace lemga
00058 
00059 #ifdef  __DATAFEEDER_H__
00060 #warning "This header file may conflict with another `datafeeder.h' file."
00061 #endif
00062 #define __DATAFEEDER_H__
00063 #endif

Generated on Mon Jan 9 23:43:23 2006 for LEMGA by  doxygen 1.4.6