Expand features into powers 1,…,d. A length-n vector x becomes an n×d matrix whose column j is xj. A 2-D input is expanded block by block: all columns to the power 1, then all columns to the power 2, and so on.
Implement solve(x,degree).
Returns. Return a float NumPy array. For a vector of length n the shape is n×degree.
Example 1
Input:
solve([1.0, 2.0, 3.0], 3)
Output:
[[1.0, 1.0, 1.0], [2.0, 4.0, 8.0], [3.0, 9.0, 27.0]]
Example 2
Input:
solve([[1.0, 2.0], [3.0, 4.0]], 2)
Output:
[[1.0, 2.0, 1.0, 4.0], [3.0, 4.0, 9.0, 16.0]]
No results yet
Run your code to check it against the examples, or submit to run every test.