Curves From Lines
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
- 1 to 20 rows, 1 to 3 columns
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.