Polynomial Features
📖 Scenario: Imagine you are analyzing how the size of a house affects its price. Sometimes, the relationship is not just straight but curved. Polynomial features help us capture this curved relationship by adding powers of the original size.
🎯 Goal: You will create a small dataset of house sizes, set a degree for polynomial features, generate these features, and then display the new data with polynomial terms.
📋 What You'll Learn
Create a list of house sizes called
house_sizes with values 1000, 1500, 2000, 2500, 3000Create a variable called
degree and set it to 3Use
PolynomialFeatures from sklearn.preprocessing to transform house_sizes into polynomial features of degree 3Store the transformed data in a variable called
poly_featuresPrint the
poly_features array💡 Why This Matters
🌍 Real World
Polynomial features help in real estate price prediction where the effect of size on price is not just straight but curved.
💼 Career
Data scientists use polynomial features to improve models that predict outcomes based on nonlinear relationships.
Progress0 / 4 steps