Skip to content

Machine Learning project using Binary Logistic Regression to classify purchase decisions from demographic features in the Social Network Ads dataset. The process involves feature engineering, scaling, model training, evaluation, and decision boundary visualization. Achieved 86% accuracy, confirming strong generalization and predictive performance.

Notifications You must be signed in to change notification settings

samir-m0hamed/Social_Network_Ads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“˜ Predicting Purchase Behavior using Logistic Regression

.

๐Ÿ“ Overview

This project applies Binary Logistic Regression to predict whether a user will purchase a product based on demographic features from the Social Network Ads dataset.
The pipeline includes data preprocessing, feature scaling, model training, evaluation, and decision boundary visualization.

The model demonstrates strong performance with 86% accuracy on test data and 84% accuracy on training data.


๐Ÿ“‚ Dataset

The dataset contains demographic attributes and purchase decisions.

Features:

  • Age
  • Estimated Salary

Target:

  • Purchased (0 or 1)

This dataset is widely used for practicing binary classification and visualizing decision boundaries.


๐Ÿš€ Project Workflow

  1. Load and explore the dataset
  2. Preprocess features
  3. Apply feature scaling with StandardScaler
  4. Train a Logistic Regression model
  5. Evaluate on training and testing sets
  6. Visualize results and decision boundary

๐Ÿง  Model Details

Algorithm: Logistic Regression

  • Type: Binary Classification
  • Activation: Sigmoid
  • Optimization: Gradient Descent through scikit-learn
  • Decision Boundary: Linear
  • Evaluation Metric: Accuracy and Confusion Matrix

๐Ÿ“Š Results

โœ”๏ธ Training Performance

  • Accuracy: 84%

Confusion Matrix (training data):

Pred 0 Pred 1
Actual 0 190 36
Actual 1 15 79

โœ”๏ธ Testing Performance

  • Accuracy: 86%

Confusion Matrix (test data):

Pred 0 Pred 1
Actual 0 50 2
Actual 1 9 19

๐Ÿ“ˆ Visualizations

The project includes meaningful visualizations such as:

  • Scatter plot of testing results
  • Decision boundary
  • Classification regions showing predicted classes

These visualizations help understand how the model separates buyers vs non-buyers.


๐Ÿ› ๏ธ Technologies Used

  • Python
  • NumPy
  • Pandas
  • Plotly
  • Scikit-Learn
  • Classification
  • Binary Logistic Regression

โ–ถ๏ธ Usage

Identifying which customers are likely to purchase the product, allowing us to deliver targeted social media advertisements specifically to them. .

๐Ÿ”ฎ Future Work

  • Apply feature selection or regularization
  • Apply hyperparameter tuning
  • Extend feature engineering
  • Collect more diverse demographic features
  • Evaluate model with precision, recall, ROC-AUC

๐Ÿ‘ค Author

Samir Mohamed Samir
AI & Machine Learning Enthusiast


โญ Summary

This project demonstrates how Binary Logistic Regression can effectively model user purchasing behavior from demographic features using a simple and interpretable method.
The model achieved 84% accuracy on training data and 86% on test data, supported by visual decision boundary analysis.

About

Machine Learning project using Binary Logistic Regression to classify purchase decisions from demographic features in the Social Network Ads dataset. The process involves feature engineering, scaling, model training, evaluation, and decision boundary visualization. Achieved 86% accuracy, confirming strong generalization and predictive performance.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published