0
$\begingroup$

I'm reading a book on machine learning where the author uses the Random Forest Regression model to fit a dataset. The confidence interval for the root mean squared error is then computed using the following code.

Does anyone know why the code works? Under what assumptions does the sum of squared errors follow a generalized t distribution (unintuitive to me, I feel like it should follow a ${\chi}^2$ distribution?

from scipy import stats
confidence = 0.95
squared_errors = (final_predictions - y_test) ** 2 #y_test is real values, final_predictions is predicted values of y
ci = np.sqrt(stats.t.interval(confidence, len(squared_errors) - 1, loc=squared_errors.mean(), scale=stats.sem(squared_errors)))
$\endgroup$
  • $\begingroup$ Yea, that doesn't make sense to me either. If the author were to not square the errors, then I would be a little more understanding. Under the assumption the errors are iid normal, then the distribution of the squared errors should be chi-squared. $\endgroup$ – Demetri Pananos May 27 '19 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.