Predict whether a person's income exceeds $50K per year using classification models. Two machine learning algorithms, Decision Tree and Naive Bayes, were utilized to determine the better fit for the dataset.
Utilized two classification models to compare which is the better fit for the data: Decision Tree and Naive Bayes.
Tools: Python, Jupyter Notebook
Libraries: Pandas, Scikit-learn, NumPy, Matplotlib, Seaborn
The dataset contains Census Income data with the following features:
Demographic Information: age, race, gender, marital_status
Employment Details: worktype, current_occupation, hours_per_week
Economic Indicators: capital_gain, capital_loss, fnlwgt
Education Information: education_level, education_num
Family Relationships: relationship_status
Target Variable: label (Boolean: income > $50,000/year)
Disclaimer: This project was created using fictitious data and is not intended for actual business use. It does not reflect or represent actual data or insights.
Created dataframes for input features and target labels.
Encoded categorical variables using a Label Encoder.
Split the data into training (80%) and testing (20%) sets.
Evaluated using metrics: Accuracy, Sensitivity, Specificity.
Evaluated using metrics: Accuracy, Sensitivity, Specificity.
Both models achieved an accuracy of 81%.
Sensitivity and Specificity Analysis:
Decision Tree:
Sensitivity: 59% – Better at detecting positive cases (income > $50K).
Specificity: 87% – Effective at identifying negative cases.
Naive Bayes:
Sensitivity: 29% – Struggles to detect positive cases.
Specificity: 95% – Excels in identifying negative cases.
Conclusion: The Decision Tree model was the better overall choice due to its superior balance between sensitivity and specificity.
A confusion matrix showing true positives, true negatives, false positives, and false negatives for the Decision Tree classifier.
Highlight: Demonstrates the model's higher sensitivity in identifying individuals with income > $50K.
A confusion matrix showing the performance of the Naive Bayes model.
Highlight: Emphasizes the model’s strength in predicting negative cases but its weakness in sensitivity.
A bar chart displaying the top features contributing to the Decision Tree model’s predictions.
Highlight: Illustrates which variables have the greatest impact on predictions.
Fnlwgt (final weight): This feature represents the number of people the census observation is believed to represent. Its high importance suggests it plays a key role in scaling the influence of individual data points within the broader population. It adjusts the observation to reflect national trends, making it a critical factor for predicting income.
Relationship status: This feature indicates the individual's family or relationship context (e.g., whether they are married, single, etc.). Its importance suggests that relationship status may correlate with income, job stability, or other demographic factors.
Age: Age is likely a strong predictor of income because it typically correlates with experience, career progression, and overall earnings potential.
A side-by-side bar chart or table comparing sensitivity and specificity between the two models.
Highlight: Shows the Decision Tree model's better balance in performance metrics.
Accuracy and Sensitivity
Since fnlwgt has the highest importance, the model might perform well at identifying individuals with high income, as the census weight gives it a more generalized view.
Decision-making Impact
By understanding which features are most important, decision-makers can target interventions or further analyses. For example, they may explore how relationship status and age affect income disparities across different subgroups.