Ask Your Question

Revision history [back]

Trouble with Knn

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.

Trouble with Knn

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);

Trouble with Knn

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

Trouble with Knn

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