FunctionRacerProblemsRace

Curves From Lines

Easyscikit-learnPython

A linear model can fit curves if it is given squares and products of the columns as extra columns. Return X expanded with all terms up to degree 2: a column of 1s, the original columns, then every square and product of two columns, in scikit-learn's order.

Example 1

X [[2,3]]
returns [[1.0,2.0,3.0,4.0,6.0,9.0]]

From a = 2 and b = 3: 1, a, b, a squared, a times b, b squared.

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