Shark-ML/Shark

How to get mean value from 0/1 RFClassifier

Mad5ci opened this issue · 2 comments

We've built a random forest classifier that trains on and delivers a 0 or 1 output for one of two classes.
We want to be able to get a double value representing the mean value of all of the individual trees.
So, for example, if 2/3 of the trees in the forest vote 1 then we would expect to get a value near 0.666.
There doesn't appear to be a way to drill down to that level of detail -- but maybe by doing some trickery with the decision function.

How should we go about getting at the data from the trees after a prediction?

Thanks! That worked... Here is a snippet of the code that's giving the desired result.

    // Code to make the prediction
    double thePrediction;
    unsigned int modelOutput;

    auto predictionData = model.decisionFunction()(theInputs);

    thePrediction = predictionData.element(0)[1];