Polynomial feature expansion represents one numeric value using successive powers. This allows a linear model to learn relationships such as curves when the expanded values are supplied as separate features.
For each input value, generate powers from zero through degree:
ϕ(x)=[1,x,x2,…,xd]Here, x is an input value, d is the maximum degree, and the resulting vector is the expanded feature row. The first element is always 1 and serves as the intercept feature. Return one row containing degree + 1 values for every input value.
Input: values = [2, 3], degree = 2
Output: [[1, 2, 4], [1, 3, 9]]
Explanation: Each row contains powers zero, one, and two of its input value.
Input: values = [-2], degree = 3
Output: [[1, -2, 4, -8]]
Use range through degree inclusive for each input value.
Raise the value to every exponent, including zero for the intercept feature.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Polynomial feature expansion represents one numeric value using successive powers. This allows a linear model to learn relationships such as curves when the expanded values are supplied as separate features.
For each input value, generate powers from zero through degree:
ϕ(x)=[1,x,x2,…,xd]Here, x is an input value, d is the maximum degree, and the resulting vector is the expanded feature row. The first element is always 1 and serves as the intercept feature. Return one row containing degree + 1 values for every input value.
Input: values = [2, 3], degree = 2
Output: [[1, 2, 4], [1, 3, 9]]
Explanation: Each row contains powers zero, one, and two of its input value.
Input: values = [-2], degree = 3
Output: [[1, -2, 4, -8]]
Use range through degree inclusive for each input value.
Raise the value to every exponent, including zero for the intercept feature.
Sign in to take notes on this problem
Accepts: array
Accepts: number