FunctionRacerProblemsRace

Honest Error

HardstatsmodelsPython

Each row of X holds the predictors of one observation and y the outcomes, in time order. A model judged on the data it was fitted to looks better than it is. So: fit ordinary least squares with an intercept on the first 80% of the rows (int(0.8 * n) of them), predict the remaining rows, and return the root mean squared error of those predictions.

Example 1

X [[0,0],[1,2],[2,4],[3,1],[4,3],[5,0],[6,2],[7,4],[8,1],[9,3],[10,0],[11,2],[12,4],[13,1],[14,3]]
y [1,13,25,12,24,11,23,35,22,34,21,33,45,32,44]
returns 0.0

The outcomes follow 1 + 2a + 5b exactly, so the held-out rows are predicted perfectly.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More statsmodels problems