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
-
Clone the repository:
pip install Customer_dna
-
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
-
Customer Segmentation (
customer_segmentation()
): Segments customers based on purchasing behavior using PyCaret’s clustering models. -
Market Basket Analysis (MBA) (
mba()
): Analyzes product associations in different customer segments usingmlxtend
. -
CLTV Calculation (
process_and_visualize_clv()
): Computes customer lifetime value using the BG/NBD and Gamma-Gamma models. -
Customer Attrition Prediction (
predict_customer_attrition()
): Predicts customers likely to churn based on the CLTV output. -
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file customer_dna-0.1.1.tar.gz
.
File metadata
- Download URL: customer_dna-0.1.1.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e44fea1bf83cab302a2ac46443c5fee0e8b05036972058ecdba903aec3996f4b |
|
MD5 | a3f9df2f5ac6cd15fb18ced3b55587ec |
|
BLAKE2b-256 | 7022ebfebd3155033b4b734b22ff1fbdecdefb7d89235bdf3bf4b2dbc0aa2d6b |
File details
Details for the file Customer_dna-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: Customer_dna-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0579f0e7bc2e414ee8821c205aa4aa6b6cc3c33162be02e2acc6f119b6526e0 |
|
MD5 | bf09929e22959d0ae115da54331b3806 |
|
BLAKE2b-256 | ef94dd76ae59edfead8fbd91c599d756f7c2632e2c13e59b75ed53db5d9f9bf3 |