Problem 2: Identify Features Most Correlated with the Target
Easypython
Learn the Concept: Feature SelectionProblem Description
Write a Python program that computes the correlation of all features with a target column ("price"), and prints them sorted from highest to lowest correlation.
Input
A DataFrame with several numeric feature columns and one target column.
Output
A sorted list of correlations with the target.
Constraints
- The target column must be named "price".
Example Input
text{"size": [1000,1500,2000], "rooms": [2,3,4], "price": [200000,280000,350000]}
Example Output
textprice 1.000000 size 0.998... rooms 0.995...
Concepts Covered
df.corr(), sort_values().
Related Problems
- Problem 1: Compute and Display a Correlation MatrixEasy · pythonSolve Problem
- Problem 3: Remove Low-Variance FeaturesEasy · pythonSolve Problem
- Problem 4: Drop One of Two Highly Correlated FeaturesEasy · pythonSolve Problem