Trouble with Knn

asked 2016-06-06 11:33:17 -0600

Lucas Amparo Barbosa gravatar image

updated 2016-06-07 11:15:11 -0600

I've build a knn model for regression, but isn't work.

When I call for a prediction, with a set of numbers, the answer always be the same value, like this >>

In = 0.742781 || Out = 0.917355 In = 0.557086 || Out = 0.917355 In = 0.19518 || Out = 0.917355 In = 0.9759 || Out = 0.917355 In = 0.09759 || Out = 0.917355

the model is setted to regression (setIsClassifier(false)) and the Algorithm Type is Brute Force (The KdTree isn't work too, showing a error).

Please, guys. I need so much this help.

@berak , the code

//Loading the model, early trained.
Ptr<KNearest> knn = Algorithm::load<KNearest>(str.str());

//Loading the value for regression
sampleMat.at<float>(0,0) = cloud_normals->points[i/3].normal_x;
knns[i]->findNearest(sampleMat, 5, response);
//Saving the regression
tmp.x = response.at<float>(0,0);

Visual Results. After the train, i've tested the model. Results from the train. The first cloud, the regression. The second, the target

OpenCV v2 (2.4), Ubuntu 14.04

edit retag flag offensive close merge delete

Comments

please show your code, also os/opencv version

berak gravatar imageberak ( 2016-06-06 11:44:21 -0600 )edit