Ask Your Question
0

What is the results value on opencv 3 random forest predict()

asked 2018-06-19 18:00:07 -0500

Rick Smith gravatar image

updated 2018-06-20 13:15:56 -0500

In python OpenCV 3+ the random forest forest documentation says predict() returns retval and results. It is clear that retval is the predicted label, but results is simply defined as "The optional output matrix of results".

For example, here is my numpy array that I pass in as a single input:

array([176.20, 39.10, 116.55,  0., 0., 48.22, 76.83, 0.], dtype=float32)

These are the values I get for results:

array([[1.],
       [1.],
       [4.],
       [1.],
       [1.],
       [1.],
       [4.],
       [3.]], dtype=float32)

retval is:

1.0

What is the format and/or meaning of the array I get back?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-06-19 20:44:39 -0500

Tetragramm gravatar image

retval is just the first value of results. results is if your samples includes more than one input, so you can actually get all of them back.

edit flag offensive delete link more

Comments

I've updated my answer to include an example of my results. I am passing in 1 value (numpy array with 8 elements). The first value of results corresponds to retval as you stated. However, I've only passed in 1 value so I'm not sure how that maps to the next 7 values in results. Could you clarify that a little more? I apologize if I'm a little slow. Thanks in advance!

Rick Smith gravatar imageRick Smith ( 2018-06-20 13:20:37 -0500 )edit

I can't say anything without having seen how you train it. You're getting one response per element, so maybe it thinks each of these is an input value.

Tetragramm gravatar imageTetragramm ( 2018-06-20 17:22:52 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-06-19 18:00:07 -0500

Seen: 28 times

Last updated: Jun 20 '18