FunctionRacerProblemsRace

Score on Unseen Rows

Easyscikit-learnPython

Split X and y at random into a training part and a test part with a quarter of the rows (random_state=0). Fit a linear regression on the training part and return its R squared on the test part.

Example 1

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

The data lie exactly on a line, so the unseen 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 scikit-learn problems