Skip to main content

A customer analysis package for data

Project description

Customer Segmentation, CLTV, and MBA Analysis

This package performs Customer Segmentation, Market Basket Analysis (MBA), and Customer Lifetime Value (CLTV) calculation with features for predicting Customer Attrition and generating Next Best Product Recommendations.

Features

  • Customer Segmentation: Clusters customers based on purchasing behavior using clustering models.
  • Market Basket Analysis (MBA): Performs market basket analysis to understand product association patterns.
  • CLTV Calculation: Estimates customer lifetime value using BG/NBD and Gamma-Gamma models.
  • Customer Attrition Prediction: Identifies customers at risk of leaving the company.
  • Next Best Product Recommendation: Recommends products based on customer purchase behavior.

Installation

  1. Clone the repository:

    pip install Customer_dna
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    

Usage:

This package provides a main() function that runs customer segmentation, market basket analysis, CLTV calculation, attrition prediction, and product recommendation.

import pandas as pd
from customer_dna.main import main

# Load your dataset
df = pd.read_csv("your_dataset.csv")

# Call the main function
recommendations = main(df, sample_size=10000, top_n=5)

# Output the recommendations
print(recommendations)

Data Requirements

Your input data should have the following columns (or their synonyms as detected by the package):

  • InvoiceNo: Invoice number of the transaction.
  • InvoiceDate: Date of the transaction.
  • Description: Product description.
  • Quantity: Quantity purchased.
  • UnitPrice: Price of the product.
  • CustomerID: Unique customer identifier.
  • Country: Country of the customer.

Key Functions

  1. Customer Segmentation (customer_segmentation()): Segments customers based on purchasing behavior using PyCaret’s clustering models.

  2. Market Basket Analysis (MBA) (mba()): Analyzes product associations in different customer segments using mlxtend.

  3. CLTV Calculation (process_and_visualize_clv()): Computes customer lifetime value using the BG/NBD and Gamma-Gamma models.

  4. Customer Attrition Prediction (predict_customer_attrition()): Predicts customers likely to churn based on the CLTV output.

  5. Product Recommendation (next_best_product_recommendation()): Recommends the next best products for each customer based on previous purchasing patterns.

Required Modules

pandas==1.3.3
numpy==1.21.2
matplotlib==3.4.3
seaborn==0.11.2
scikit-learn==0.24.2
scipy==1.7.1
pycaret==2.3.3
lifetimes==0.11.3
mlxtend==0.19.0
plotly==5.3.1
networkx==2.6.3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

customer_dna-0.1.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

Customer_dna-0.1.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file customer_dna-0.1.0.tar.gz.

File metadata

  • Download URL: customer_dna-0.1.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for customer_dna-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1cfbb76b592008f06dcbe7d144c5036f46c859ced4cbb3b16ab6624701a6bafa
MD5 94850afa8b627049d42988e291d37f9f
BLAKE2b-256 84652b82973b9e0a9df82d82ba638031e5e9a5c8d8734e9ed0d503b8e8da961c

See more details on using hashes here.

File details

Details for the file Customer_dna-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: Customer_dna-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for Customer_dna-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a93a2bceccf59bdb9d1fd2357abb62a610f7acb2aaeb91325fb87e63d4de85f6
MD5 6f673316d03b1b5ef0bb9813adde372a
BLAKE2b-256 ba1fd89b186d1a988ac7b757e4be38cb374c2125a63debb1ebe18be84ce9e2e0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page