Problem 4: Check Class Balance with a Count Plot
Easypython
Problem Description
Write a Python program that uses sns.countplot() to visualize the class distribution of a binary target column, to check for imbalance.
Input
A DataFrame with a binary "target" column.
Output
A displayed bar chart showing the count of each class.
Constraints
- At least 10 rows, with an imbalanced class distribution.
Example Input
text{"target": [0,0,0,0,0,0,0,0,1,1]}
Example Output
text(A bar chart showing 8 bars-worth of class 0 and 2 bars-worth of class 1, visually revealing the imbalance)
Concepts Covered
sns.countplot(), class balance visualization.