Skip to content

About

We hope that this project will serve as a valuable resource for researchers, data analysts, and machine learning enthusiasts who want to gain insights into shopping trends and patterns in Istanbul.

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

7 Commits

Folders and files

Repository files navigation

Istanbul Shopping Customer Segmentation Analysis

Uncovering Shopping Patterns and Customer Behaviors through Data Science

Python Data Science Machine Learning Clustering Status


🎯 Project Overview

Business Problem

Understanding customer behavior is crucial for retail success. This project analyzes shopping data from Istanbul to identify distinct customer segments, enabling:

  • Targeted marketing campaigns - Reach the right customers with the right message
  • Personalized customer experiences - Tailor offerings to specific customer needs
  • Optimized inventory management - Stock products based on customer preferences
  • Strategic business decisions - Data-driven insights for growth

What This Project Does

  • Performs exploratory data analysis on Istanbul shopping data
  • Identifies customer segments using clustering algorithms
  • Analyzes shopping patterns and trends
  • Provides actionable business insights
  • Visualizes customer behavior patterns

Key Insights Delivered

  • πŸ›οΈ Customer purchasing patterns - Understanding what drives purchases
  • πŸ’° Spending behavior analysis - Identifying high-value customers
  • πŸ“Š Demographic segmentation - Targeting by age, gender, and income
  • πŸ• Temporal shopping trends - Peak times and seasonal patterns
  • 🎯 Customer lifetime value estimation - Predicting long-term value

πŸ“Š Dataset Description

Source: Istanbul Shopping Mall Customer Data

Features

Customer Demographics:

  • Age
  • Gender
  • Income level
  • Location

Shopping Behavior:

  • Purchase amount
  • Product categories
  • Shopping frequency
  • Payment methods
  • Visit duration

Temporal Data:

  • Purchase date/time
  • Seasonal patterns
  • Day of week trends

Dataset Characteristics:

  • Comprehensive customer transaction records
  • Multiple demographic and behavioral variables
  • Suitable for segmentation and pattern analysis

🧠 Methodology

1. Data Preparation

# Data cleaning and preprocessing
- Handling missing values
- Feature engineering
- Outlier detection and treatment
- Data normalization/standardization

2. Exploratory Data Analysis (EDA)

  • Univariate analysis (distributions)
  • Bivariate analysis (relationships)
  • Correlation analysis
  • Statistical testing
  • Visualization of patterns

3. Feature Engineering

  • RFM Analysis (Recency, Frequency, Monetary)
  • Customer lifetime value calculation
  • Shopping pattern indicators
  • Temporal features
  • Derived metrics

4. Segmentation Techniques

  • K-Means Clustering: Identify natural customer groups
  • Hierarchical Clustering: Understand segment relationships
  • DBSCAN: Detect outliers and dense regions
  • PCA: Dimensionality reduction and visualization

5. Segment Profiling

  • Demographic characteristics
  • Shopping behavior patterns
  • Value contribution
  • Growth potential
  • Marketing recommendations

πŸ› οΈ Technologies & Tools

Programming & Libraries

Python 3.9+
β”œβ”€β”€ Data Manipulation
β”‚   β”œβ”€β”€ pandas
β”‚   β”œβ”€β”€ numpy
β”‚   └── scipy
β”œβ”€β”€ Machine Learning
β”‚   β”œβ”€β”€ scikit-learn
β”‚   └── yellowbrick
β”œβ”€β”€ Visualization
β”‚   β”œβ”€β”€ matplotlib
β”‚   β”œβ”€β”€ seaborn
β”‚   β”œβ”€β”€ plotly
β”‚   └── folium (for maps)
└── Jupyter
    └── jupyter notebook

πŸ“¦ Installation & Setup

Prerequisites

  • Python 3.9 or higher
  • pip package manager
  • 4GB RAM minimum

Quick Start

# Clone the repository
git clone https://github.com/Ghulam-Mustafa-Keerio/Customer-Segmentation-Analysis.git
cd Customer-Segmentation-Analysis

# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Launch Jupyter Notebook
jupyter notebook

# Open Customer_Segmentation_Analysis.ipynb

πŸš€ Usage

Running the Analysis

1. Load and Explore Data:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Load dataset
df = pd.read_csv('data/istanbul_shopping_data.csv')

# Quick overview
print(df.head())
print(df.info())
print(df.describe())

2. Perform RFM Analysis:

# Calculate RFM scores
# Recency: Days since last purchase
# Frequency: Number of transactions
# Monetary: Total spending amount

rfm_df = calculate_rfm(df, 
                       customer_id='CustomerID',
                       date='InvoiceDate',
                       amount='TotalAmount')

3. Apply Clustering:

from sklearn.cluster import KMeans
from sklearn.preprocessing import StandardScaler

# Prepare features
features = ['Recency', 'Frequency', 'Monetary']
X = rfm_df[features]

# Standardize
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)

# Apply K-Means
kmeans = KMeans(n_clusters=4, random_state=42)
rfm_df['Segment'] = kmeans.fit_predict(X_scaled)

4. Visualize Segments:

import plotly.express as px

# 3D scatter plot of segments
fig = px.scatter_3d(rfm_df, 
                     x='Recency', 
                     y='Frequency', 
                     z='Monetary',
                     color='Segment',
                     title='Customer Segments')
fig.show()

πŸ“ˆ Key Findings

Customer Segments Identified

πŸ’Ž Champions (Segment 1)

  • Characteristics: High frequency, recent purchases, high spending
  • Action: VIP treatment, loyalty rewards, exclusive access
  • Business Value: Highest lifetime value customers

⭐ Loyal Customers (Segment 2)

  • Characteristics: Regular purchasers, moderate to high spending
  • Action: Engagement programs, upselling, personalized offers
  • Business Value: Stable revenue stream

🎯 Potential Loyalists (Segment 3)

  • Characteristics: Recent customers, growing purchase frequency
  • Action: Nurture with offers, build loyalty programs
  • Business Value: High growth potential

πŸ’€ At-Risk (Segment 4)

  • Characteristics: Previously active, now declining engagement
  • Action: Win-back campaigns, incentives, feedback surveys
  • Business Value: Retention opportunity

Shopping Trends

  • πŸ“… Peak shopping periods identified for optimal marketing timing
  • πŸ• Time-of-day patterns for staffing and promotions
  • πŸ’³ Payment preferences for checkout optimization
  • πŸ›’ Average basket analysis for upselling strategies
  • πŸ“ˆ Seasonal variations for inventory planning

πŸ“Š Visualizations

The project includes comprehensive visualizations:

1. Customer Distribution

  • Age and gender demographics
  • Income level distribution
  • Geographic heat maps

2. Shopping Patterns

  • Purchase frequency over time
  • Spending trends
  • Category preferences
  • Time-of-day analysis

3. Segmentation Results

  • 3D cluster visualization
  • Dendrogram (hierarchical clustering)
  • Elbow curve for optimal K
  • Silhouette analysis

4. Business Insights

  • Revenue by segment
  • Customer lifetime value
  • Churn risk indicators
  • Growth opportunities

πŸ’Ό Business Recommendations

For Champions

  • βœ… Exclusive early access to new products
  • βœ… Premium customer service
  • βœ… Referral incentive programs
  • βœ… Personalized communication

For Loyal Customers

  • βœ… Points-based loyalty program
  • βœ… Special birthday offers
  • βœ… Community building initiatives
  • βœ… Product recommendations

For Potential Loyalists

  • βœ… Welcome series emails
  • βœ… Educational content
  • βœ… First purchase follow-ups
  • βœ… Incentivized repeat purchases

For At-Risk Customers

  • βœ… Re-engagement campaigns
  • βœ… Limited-time offers
  • βœ… Feedback surveys
  • βœ… Win-back discounts

πŸ“‚ Project Structure

Customer-Segmentation-Analysis/
β”œβ”€β”€ Customer_Segmentation_Analysis.ipynb    # Main analysis notebook
β”œβ”€β”€ data/                                   # Data directory (if applicable)
β”‚   β”œβ”€β”€ raw/                               # Raw data files
β”‚   └── processed/                         # Processed data files
β”œβ”€β”€ requirements.txt                        # Python dependencies
β”œβ”€β”€ .gitignore                             # Git ignore rules
β”œβ”€β”€ README.md                              # This file
β”œβ”€β”€ CONTRIBUTING.md                        # Contribution guidelines
└── LICENSE                                # MIT License

πŸ” Methodology Details

RFM Analysis

  • Recency (R): Days since last purchase
  • Frequency (F): Number of transactions
  • Monetary (M): Total spending amount

Scoring System

  • Each metric scored 1-5
  • Combined RFM score (111-555)
  • Segment assignment based on scores

Clustering Validation

  • Elbow method for optimal K
  • Silhouette score analysis
  • Davies-Bouldin index
  • Calinski-Harabasz score

πŸŽ“ Learning Outcomes

Skills Demonstrated

Technical Skills:

  • βœ… Data cleaning and preprocessing
  • βœ… Exploratory data analysis
  • βœ… Feature engineering
  • βœ… Unsupervised learning (clustering)
  • βœ… Statistical analysis
  • βœ… Data visualization
  • βœ… Python programming

Business Skills:

  • Customer behavior analysis
  • Marketing strategy development
  • Data-driven decision making
  • Retail analytics
  • Customer relationship management

πŸ”¬ Technical Highlights

Advanced Techniques:

  • Dimensionality reduction (PCA, t-SNE)
  • Multiple clustering algorithms comparison
  • Hyperparameter tuning
  • Statistical significance testing
  • Time series analysis for trends

🌟 Unique Features

  • πŸ—ΊοΈ Geographic analysis of Istanbul shopping zones
  • πŸ“± Product category deep-dive
  • πŸ’‘ Actionable marketing recommendations
  • πŸ“Š Interactive visualizations
  • πŸ“ˆ Customer lifetime value analysis
  • 🎯 Churn prediction indicators

πŸš€ Future Enhancements

Planned Improvements:

  • Predictive modeling for customer churn
  • Real-time dashboard with Streamlit
  • A/B testing framework
  • Integration with CRM systems
  • Recommendation engine
  • Market basket analysis
  • Cohort analysis
  • Customer journey mapping

🀝 Contributing

Contributions are welcome! Ways to contribute:

  • Add new clustering algorithms
  • Improve visualizations
  • Enhance documentation
  • Add more business metrics
  • Optimize code performance

See CONTRIBUTING.md for details.


πŸ“š References & Resources

Tools & Libraries

Topics

  • Customer Segmentation
  • RFM Analysis
  • Clustering Algorithms
  • Retail Analytics

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Istanbul shopping mall data providers
  • Data science community
  • Open-source contributors
  • Researchers and analysts using this project

πŸ‘¨β€πŸ’» Author

Ghulam Mustafa Keerio

  • GitHub: @Ghulam-Mustafa-Keerio
  • Specialization: Data Science, Machine Learning, Business Analytics
  • Focus: Turning data into actionable insights

πŸ“§ Contact & Feedback

Have questions or suggestions?

  • Open an Issue
  • Submit a Pull Request
  • Connect on LinkedIn

πŸ“Š Project Status

  • Data collection and cleaning
  • Exploratory data analysis
  • Feature engineering
  • Clustering implementation
  • Visualization and reporting
  • Dashboard development
  • Deployment

"Data is the new oil, but insights are the refined fuel that drives business growth."


This project serves as a valuable resource for researchers, data analysts, and machine learning enthusiasts who want to gain insights into shopping trends and patterns in Istanbul.

About

We hope that this project will serve as a valuable resource for researchers, data analysts, and machine learning enthusiasts who want to gain insights into shopping trends and patterns in Istanbul.

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages