Problem 4: Check for Multicollinearity Before Modeling
Easypython
Problem Description
Write a Python program that computes the correlation between two candidate input features, and prints a warning message if their correlation exceeds 0.9, before proceeding to fit a Multiple Linear Regression model.
Input
A dataset with two candidate features and one target.
Output
A correlation value, a warning if multicollinearity is detected, and the fitted model's coefficients regardless.
Constraints
- None specific.
Example Input
textfeature1=[10,15,20,25], feature2=[12,17,22,27], target=[100,150,200,250]
Example Output
textCorrelation between feature1 and feature2: 0.99 Warning: High multicollinearity detected. Coefficients: [...]
Concepts Covered
df.corr(), conditional warnings, LinearRegression.