Phi Transformation for Polynomial Features
Data Preparation & Feature Engineering DS practice problem on Onlearn.
Difficulty: easy.
Topics: Understanding Phi Transformation for Polynomial Features, Vandermonde Matrix, Degree Hyperparameter, Combinatorial Feature Interaction, Nested List Comprehension, Input Space Projection, Feature Engineering, Linear Algebra, Numerical Analysis, Statistical Modeling, Computational Complexity, Polynomial Basis Expansion, Vector Space Transformations, Dimensionality Management, Nonlinear Mapping, Iterative Data Processing.
Write a Python function to perform a Phi Transformation that maps input features into a higher dimensional space by generating polynomial features. The transformation allows models like linear regression to fit nonlinear data by introducing new feature dimensions that represent polynomial combinations of the original input features. The function should take a list of numerical data and a degree as inputs, and return a nested list where each inner list represents the transformed features of a data point. If the degree is less than 0, the function should return an empty list.