Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

About Question #1:
I saw also the problem with calcError and checked the source code for the function. To solve that is like you propose switching <at> float and <at> int. So:
switching

float val0 = responses.at<float>(si);

for

float val0 = responses.type()== CV_32S ? (float)responses.at<int>(si) : responses.at<float>(si);

The type evalution is needed in order to recognize if the data you have is float or integer. It because cv::ml::trainData allows integer as well float as input when you are creating it.
The casting (float) is necessary because the output of the predict function used in calcError is also float: float val = predict(sample); And val and val0 will then be compared

About Question #2
I had the same confusion and I also think the output error should be better 0 <= x <= 1