# Validating the Performance of a Random Forest Regressor for Non Linear data

The OOB score in SK learn Random Forest Regressor gives the R2 score.

Now, from what I know, R2 score is only valid for linear data.

How do I validate the score of my model if my Random forest model is for non linear data?

• The model "wrapper" classes like GridSearchCV accept a scoring Parameter that allows you to change the scoring function. I presume it works when oob_score=True, although it might be useful to confirm as much and post the answer here. Aug 5 '16 at 12:02
• Also, for the record this question belongs on Stackoverflow, and not here. For some reason I don't see the option to vote that it be moved, instead of just closed. Aug 5 '16 at 12:04

RandomForestRegressor man page explains that you get oob_prediction_s for the training cases as well.
((y - rfr.oob_prediction_)**2).sum() / y.size

• @ssdecontrol: did you mean to say that in case of this training being part of a grid search there are more elegant solutions? I'd expect GridSearchCV to use normal predictions on cases held out according to the cross validation scheme by the wrapper - so that is a rather different question: that way you evaluate via normal predictions. Aug 5 '16 at 12:11