minor refactoring of CvMLData interface

This commit is contained in:
Maria Dimashova
2011-06-17 10:11:52 +00:00
parent 77be493e45
commit fc04b7ab4f
2 changed files with 68 additions and 42 deletions

View File

@@ -2061,10 +2061,9 @@ CVAPI(void) cvCreateTestSet( int type, CvMat** samples,
struct CV_EXPORTS CvTrainTestSplit
{
public:
CvTrainTestSplit();
CvTrainTestSplit( int _train_sample_count, bool _mix = true);
CvTrainTestSplit( float _train_sample_portion, bool _mix = true);
CvTrainTestSplit( int train_sample_count, bool mix = true);
CvTrainTestSplit( float train_sample_portion, bool mix = true);
union
{
@@ -2073,14 +2072,7 @@ public:
} train_sample_part;
int train_sample_part_mode;
union
{
int *count;
float *portion;
} *class_part;
int class_part_mode;
bool mix;
bool mix;
};
class CV_EXPORTS CvMLData
@@ -2094,24 +2086,24 @@ public:
// 1 - file can not be opened or is not correct
int read_csv( const char* filename );
const CvMat* get_values();
const CvMat* get_values() const;
const CvMat* get_responses();
const CvMat* get_missing();
const CvMat* get_missing() const;
void set_response_idx( int idx ); // old response become predictors, new response_idx = idx
// if idx < 0 there will be no response
int get_response_idx();
int get_response_idx() const;
const CvMat* get_train_sample_idx();
const CvMat* get_test_sample_idx();
void mix_train_and_test_idx();
void set_train_test_split( const CvTrainTestSplit * spl );
const CvMat* get_train_sample_idx() const;
const CvMat* get_test_sample_idx() const;
void mix_train_and_test_idx();
const CvMat* get_var_idx();
void chahge_var_idx( int vi, bool state ); // state == true to set vi-variable as predictor
const CvMat* get_var_types();
int get_var_type( int var_idx );
int get_var_type( int var_idx ) const;
// following 2 methods enable to change vars type
// use these methods to assign CV_VAR_CATEGORICAL type for categorical variable
// with numerical labels; in the other cases var types are correctly determined automatically
@@ -2121,11 +2113,13 @@ public:
void change_var_type( int var_idx, int type); // type in { CV_VAR_ORDERED, CV_VAR_CATEGORICAL }
void set_delimiter( char ch );
char get_delimiter();
char get_delimiter() const;
void set_miss_ch( char ch );
char get_miss_ch();
char get_miss_ch() const;
const std::map<std::string, int>& get_class_labels_map() const;
protected:
virtual void clear();
@@ -2151,7 +2145,7 @@ protected:
bool mix;
int total_class_count;
std::map<std::string, int> *class_map;
std::map<std::string, int> class_map;
CvMat* train_sample_idx;
CvMat* test_sample_idx;