Polynomial Features

Hard
feature-engineering LinkedIn Salesforce

Given a list of feature values and a degree, generate polynomial features up to that degree for each value. Return a list of lists.

Example

polynomial_features([2, 3], 3)
# => [[2, 4, 8], [3, 9, 27]]
# Each row: [x^1, x^2, x^3]

Test Cases

Python Editor

Output

Click "Run" to see results...