Commit 108caae2 authored by Maksim Shabunin's avatar Maksim Shabunin

Modified logistic regression module according to comments

- Reworked documentation to reflect actual code
- Removed some unused variables
- Removed unnecessary 'cv::' modifiers
parent 4667e188
This diff is collapsed.
......@@ -18,5 +18,5 @@ Most of the classification and regression algorithms are implemented as C++ clas
random_trees
expectation_maximization
neural_networks
mldata
logistic_regression
mldata
......@@ -89,9 +89,6 @@ public:
CV_PROP_RW double maxVal;
CV_PROP_RW double logStep;
};
#define CV_TYPE_NAME_ML_LR "opencv-ml-lr"
class CV_EXPORTS TrainData
{
......@@ -590,7 +587,7 @@ public:
int regularized;
int train_method;
int mini_batch_size;
cv::TermCriteria term_crit;
TermCriteria term_crit;
};
enum { REG_L1 = 0, REG_L2 = 1};
......
This diff is collapsed.
......@@ -74,7 +74,7 @@ static bool calculateError( const Mat& _p_labels, const Mat& _o_labels, float& e
CV_Assert(_p_labels_temp.total() == _o_labels_temp.total());
CV_Assert(_p_labels_temp.rows == _o_labels_temp.rows);
accuracy = (float)cv::countNonZero(_p_labels_temp == _o_labels_temp)/_p_labels_temp.rows;
accuracy = (float)countNonZero(_p_labels_temp == _o_labels_temp)/_p_labels_temp.rows;
error = 1 - accuracy;
return true;
}
......@@ -166,7 +166,7 @@ void CV_LRTest_SaveLoad::run( int /*start_from*/ )
params1.mini_batch_size = 10;
// train and save the classifier
String filename = cv::tempfile(".xml");
String filename = tempfile(".xml");
try
{
// run LR classifier train classifier
......@@ -208,8 +208,8 @@ void CV_LRTest_SaveLoad::run( int /*start_from*/ )
// check if there is any difference between computed learnt mat and retreived mat
float errorCount = 0.0;
errorCount += 1 - (float)cv::countNonZero(responses1 == responses2)/responses1.rows;
errorCount += 1 - (float)cv::sum(comp_learnt_mats)[0]/comp_learnt_mats.rows;
errorCount += 1 - (float)countNonZero(responses1 == responses2)/responses1.rows;
errorCount += 1 - (float)sum(comp_learnt_mats)[0]/comp_learnt_mats.rows;
if(errorCount>0)
{
......
......@@ -58,9 +58,9 @@
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/ml/ml.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core.hpp>
#include <opencv2/ml.hpp>
#include <opencv2/highgui.hpp>
using namespace std;
using namespace cv;
......@@ -78,7 +78,7 @@ static void showImage(const Mat &data, int columns, const String &name)
static float calculateAccuracyPercent(const Mat &original, const Mat &predicted)
{
return 100 * (float)cv::countNonZero(original == predicted) / predicted.rows;
return 100 * (float)countNonZero(original == predicted) / predicted.rows;
}
int main()
......
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