Commit 15f7918e authored by P. Druzhkov's avatar P. Druzhkov

problem with the supported data matrices types is fixed

minor fixes in CvGBTrees, its test and sample
parent 6a03be26
...@@ -1832,6 +1832,7 @@ protected: ...@@ -1832,6 +1832,7 @@ protected:
// RESULT // RESULT
*/ */
virtual void read_params( CvFileStorage* fs, CvFileNode* fnode ); virtual void read_params( CvFileStorage* fs, CvFileNode* fnode );
int get_len(const CvMat* mat) const;
CvDTreeTrainData* data; CvDTreeTrainData* data;
......
This diff is collapsed.
...@@ -25,6 +25,7 @@ protected: ...@@ -25,6 +25,7 @@ protected:
string model_file_name1; string model_file_name1;
string model_file_name2; string model_file_name2;
string* datasets; string* datasets;
string data_path; string data_path;
...@@ -33,6 +34,8 @@ protected: ...@@ -33,6 +34,8 @@ protected:
vector<float> test_resps1; vector<float> test_resps1;
vector<float> test_resps2; vector<float> test_resps2;
int64 initSeed;
}; };
...@@ -44,6 +47,18 @@ int _get_len(const CvMat* mat) ...@@ -44,6 +47,18 @@ int _get_len(const CvMat* mat)
CV_GBTreesTest::CV_GBTreesTest() CV_GBTreesTest::CV_GBTreesTest()
{ {
int64 seeds[] = { CV_BIG_INT(0x00009fff4f9c8d52),
CV_BIG_INT(0x0000a17166072c7c),
CV_BIG_INT(0x0201b32115cd1f9a),
CV_BIG_INT(0x0513cb37abcd1234),
CV_BIG_INT(0x0001a2b3c4d5f678)
};
int seedCount = sizeof(seeds)/sizeof(seeds[0]);
cv::RNG& rng = cv::theRNG();
initSeed = rng.state;
rng.state = seeds[rng(seedCount)];
datasets = 0; datasets = 0;
data = 0; data = 0;
gtb = 0; gtb = 0;
...@@ -54,6 +69,7 @@ CV_GBTreesTest::~CV_GBTreesTest() ...@@ -54,6 +69,7 @@ CV_GBTreesTest::~CV_GBTreesTest()
if (data) if (data)
delete data; delete data;
delete[] datasets; delete[] datasets;
cv::theRNG().state = initSeed;
} }
...@@ -65,7 +81,7 @@ int CV_GBTreesTest::TestTrainPredict(int test_num) ...@@ -65,7 +81,7 @@ int CV_GBTreesTest::TestTrainPredict(int test_num)
float shrinkage = 0.1f; float shrinkage = 0.1f;
float subsample_portion = 0.5f; float subsample_portion = 0.5f;
int max_depth = 5; int max_depth = 5;
bool use_surrogates = true; bool use_surrogates = false;
int loss_function_type = 0; int loss_function_type = 0;
switch (test_num) switch (test_num)
{ {
...@@ -137,8 +153,10 @@ int CV_GBTreesTest::checkPredictError(int test_num) ...@@ -137,8 +153,10 @@ int CV_GBTreesTest::checkPredictError(int test_num)
if (!gtb) if (!gtb)
return cvtest::TS::FAIL_GENERIC; return cvtest::TS::FAIL_GENERIC;
float mean[] = {5.430247f, 13.5654f, 12.6569f, 13.1661f}; //float mean[] = {5.430247f, 13.5654f, 12.6569f, 13.1661f};
float sigma[] = {0.4162694f, 3.21161f, 3.43297f, 3.00624f}; //float sigma[] = {0.4162694f, 3.21161f, 3.43297f, 3.00624f};
float mean[] = {5.80226f, 12.68689f, 13.49095f, 13.19628f};
float sigma[] = {0.4764534f, 3.166919f, 3.022405f, 2.868722f};
float current_error = gtb->calc_error(data, CV_TEST_ERROR); float current_error = gtb->calc_error(data, CV_TEST_ERROR);
......
...@@ -22,9 +22,9 @@ vector<Scalar> classColors; ...@@ -22,9 +22,9 @@ vector<Scalar> classColors;
#define NBC 0 // normal Bayessian classifier #define NBC 0 // normal Bayessian classifier
#define KNN 0 // k nearest neighbors classifier #define KNN 0 // k nearest neighbors classifier
#define SVM 0 // support vectors machine #define SVM 0 // support vectors machine
#define DT 1 // decision tree #define DT 0 // decision tree
#define BT 0 // ADA Boost #define BT 0 // ADA Boost
#define GBT 0 // gradient boosted trees #define GBT 1 // gradient boosted trees
#define RF 0 // random forest #define RF 0 // random forest
#define ERT 0 // extremely randomized trees #define ERT 0 // extremely randomized trees
#define ANN 0 // artificial neural networks #define ANN 0 // artificial neural networks
...@@ -272,7 +272,6 @@ void find_decision_boundary_GBT() ...@@ -272,7 +272,6 @@ void find_decision_boundary_GBT()
Mat trainSamples, trainClasses; Mat trainSamples, trainClasses;
prepare_train_data( trainSamples, trainClasses ); prepare_train_data( trainSamples, trainClasses );
trainClasses.convertTo( trainClasses, CV_32FC1 );
// learn classifier // learn classifier
CvGBTrees gbtrees; CvGBTrees gbtrees;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment