FunctionRacerProblemsRace

Average Over Five Folds

Mediumscikit-learnPython

One train and test split can be lucky. Cross-validation cuts the rows into 5 folds and scores the model 5 times, each time on one fold after fitting on the other four. Return the mean of the 5 scores (R squared) for a linear regression of y on X.

Example 1

X [[0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14]]
y [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29]
returns 1.0

Points exactly on a line are predicted perfectly in every fold.

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 scikit-learn problems