cv::ml::rtrees oob error

asked 2019-11-19 05:04:33 -0500

JoseAFern gravatar image

Hi

I'm using cv::ml::rtrees and am looking to access the out-of-bag error. Is there a way to access this in code (i.e. access some variable or call a getter that provides this value)? I know that this value gets written to file on calling write from the model (this variable is part of DTreesImplForRTrees which is inaccessible). How can I access it without having to call write?

Somewhat related question: cv::ml::statmodel also has a method call CalcError which is inherited by rtrees. Calling this method, however, gives an error which is different (as far as I can see) from the oob error. I wonder if anyone has any input in clarifying how this is calculated. I have looked at the code and it seems to be general code for all classifiers (not specific to rtrees, so no equivalent to oob error). If after running training I set test=false while calling CalcError, I get an error different from 0, even though I am running it on the training data set and have not set any splits for training. Should this error not be 0?

Thanks

edit retag flag offensive close merge delete

Comments

opencv version ?

berak gravatar imageberak ( 2019-11-19 08:02:02 -0500 )edit
1

4.1.0 but I think it happens in any

JoseAFern gravatar imageJoseAFern ( 2019-11-19 08:04:26 -0500 )edit
berak gravatar imageberak ( 2019-11-19 08:06:46 -0500 )edit

That change of adding weights applies to calcError. I imagine that before the change the error would've been still different from the oob error, wouldn't it?

JoseAFern gravatar imageJoseAFern ( 2019-11-19 08:10:59 -0500 )edit

i think so, too.

berak gravatar imageberak ( 2019-11-19 08:18:44 -0500 )edit

Since they are different, I think I'd prefer to use the oob error for rtrees (it just seems like the better approach) rather than using the general code. I can implement a (not very efficient) workaround to access the oob error but it'd be nice to be able to access it directly...

JoseAFern gravatar imageJoseAFern ( 2019-11-19 08:31:17 -0500 )edit