// returns:
// 0 - OK
// 1 - file can not be opened or is not correct
- int read_csv(const char* filename);
-
- const CvMat* get_values(){ return values; }
+ int read_csv( const char* filename );
+ const CvMat* get_values();
const CvMat* get_responses();
-
- const CvMat* get_missing(){ return missing; }
+ const CvMat* get_missing();
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() { return response_idx; }
+ int get_response_idx();
- const CvMat* get_train_sample_idx() { return train_sample_idx; }
- const CvMat* get_test_sample_idx() { return test_sample_idx; }
+ 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);
+ void set_train_test_split( const CvTrainTestSplit * spl );
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 ) { return var_types->data.ptr[var_idx]; }
+ int get_var_type( int var_idx );
// 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
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() { return delimiter; }
+ char get_delimiter();
void set_miss_ch( char ch );
- char get_miss_ch() { return miss_ch; }
+ char get_miss_ch();
protected:
virtual void clear();
#define MISS_VAL FLT_MAX
#define CV_VAR_MISS 0
-CvTrainTestSplit :: CvTrainTestSplit()
+CvTrainTestSplit::CvTrainTestSplit()
{
train_sample_part_mode = CV_COUNT;
train_sample_part.count = -1;
mix = false;
}
-CvTrainTestSplit :: CvTrainTestSplit( int _train_sample_count, bool _mix )
+CvTrainTestSplit::CvTrainTestSplit( int _train_sample_count, bool _mix )
{
train_sample_part_mode = CV_COUNT;
train_sample_part.count = _train_sample_count;
mix = _mix;
}
-CvTrainTestSplit :: CvTrainTestSplit( float _train_sample_portion, bool _mix )
+CvTrainTestSplit::CvTrainTestSplit( float _train_sample_portion, bool _mix )
{
train_sample_part_mode = CV_PORTION;
train_sample_part.portion = _train_sample_portion;
////////////////
-CvMLData :: CvMLData()
+CvMLData::CvMLData()
{
values = missing = var_types = var_idx_mask = response_out = var_idx_out = var_types_out = 0;
train_sample_idx = test_sample_idx = 0;
rng = &cv::theRNG();
}
-CvMLData :: ~CvMLData()
+CvMLData::~CvMLData()
{
clear();
delete class_map;
}
-void CvMLData :: free_train_test_idx()
+void CvMLData::free_train_test_idx()
{
cvReleaseMat( &train_sample_idx );
cvReleaseMat( &test_sample_idx );
sample_idx = 0;
}
-void CvMLData :: clear()
+void CvMLData::clear()
{
if ( !class_map->empty() )
class_map->clear();
return 0;
}
-void CvMLData :: str_to_flt_elem( const char* token, float& flt_elem, int& type)
+const CvMat* CvMLData::get_values()
+{
+ return values;
+}
+
+const CvMat* CvMLData::get_missing()
+{
+ return missing;
+}
+
+void CvMLData::str_to_flt_elem( const char* token, float& flt_elem, int& type)
{
char* stopstring = NULL;
}
}
-void CvMLData :: set_delimiter(char ch)
+void CvMLData::set_delimiter(char ch)
{
- CV_FUNCNAME( "CvMLData :: set_delimited" );
+ CV_FUNCNAME( "CvMLData::set_delimited" );
__BEGIN__;
if (ch == miss_ch /*|| ch == flt_separator*/)
__END__;
}
-void CvMLData :: set_miss_ch(char ch)
+char CvMLData::get_delimiter()
{
- CV_FUNCNAME( "CvMLData :: set_miss_ch" );
+ return delimiter;
+}
+
+void CvMLData::set_miss_ch(char ch)
+{
+ CV_FUNCNAME( "CvMLData::set_miss_ch" );
__BEGIN__;
if (ch == delimiter/* || ch == flt_separator*/)
__END__;
}
-void CvMLData :: set_response_idx( int idx )
+char CvMLData::get_miss_ch()
+{
+ return miss_ch;
+}
+
+void CvMLData::set_response_idx( int idx )
{
- CV_FUNCNAME( "CvMLData :: set_response_idx" );
+ CV_FUNCNAME( "CvMLData::set_response_idx" );
__BEGIN__;
if ( !values )
__END__;
}
-void CvMLData :: change_var_type( int var_idx, int type )
+int CvMLData::get_response_idx()
{
- CV_FUNCNAME( "CvMLData :: change_var_type" );
+ return response_idx;
+}
+
+void CvMLData::change_var_type( int var_idx, int type )
+{
+ CV_FUNCNAME( "CvMLData::change_var_type" );
__BEGIN__;
int var_count = 0;
return;
}
-void CvMLData :: set_var_types( const char* str )
+void CvMLData::set_var_types( const char* str )
{
- CV_FUNCNAME( "CvMLData :: set_var_types" );
+ CV_FUNCNAME( "CvMLData::set_var_types" );
__BEGIN__;
const char* ord = 0, *cat = 0;
__END__;
}
-const CvMat* CvMLData :: get_var_types()
+const CvMat* CvMLData::get_var_types()
{
- CV_FUNCNAME( "CvMLData :: get_var_types" );
+ CV_FUNCNAME( "CvMLData::get_var_types" );
__BEGIN__;
uchar *var_types_out_ptr = 0;
return var_types_out;
}
-const CvMat* CvMLData :: get_responses()
+int CvMLData::get_var_type( int var_idx )
+{
+ return var_types->data.ptr[var_idx];
+}
+
+const CvMat* CvMLData::get_responses()
{
- CV_FUNCNAME( "CvMLData :: get_responses_ptr" );
+ CV_FUNCNAME( "CvMLData::get_responses_ptr" );
__BEGIN__;
int var_count = 0;
return response_out;
}
-void CvMLData :: set_train_test_split( const CvTrainTestSplit * spl)
+void CvMLData::set_train_test_split( const CvTrainTestSplit * spl)
{
- CV_FUNCNAME( "CvMLData :: set_division" );
+ CV_FUNCNAME( "CvMLData::set_division" );
__BEGIN__;
int sample_count = 0;
__END__;
}
-void CvMLData :: mix_train_and_test_idx()
+const CvMat* CvMLData::get_train_sample_idx()
+{
+ return train_sample_idx;
+}
+
+const CvMat* CvMLData::get_test_sample_idx()
+{
+ return test_sample_idx;
+}
+
+void CvMLData::mix_train_and_test_idx()
{
if ( !values || !sample_idx) return;
}
}
-const CvMat* CvMLData :: get_var_idx()
+const CvMat* CvMLData::get_var_idx()
{
- CV_FUNCNAME( "CvMLData :: get_var_idx" );
+ CV_FUNCNAME( "CvMLData::get_var_idx" );
__BEGIN__;
int avcount = 0;
return var_idx_out;
}
-void CvMLData :: chahge_var_idx( int vi, bool state )
+void CvMLData::chahge_var_idx( int vi, bool state )
{
- CV_FUNCNAME( "CvMLData :: get_responses_ptr" );
+ CV_FUNCNAME( "CvMLData::get_responses_ptr" );
__BEGIN__;
int var_count = 0;