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.2.tar.gz
.
File metadata
- Download URL: customer_dna-0.1.2.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 | 8b8e49ca87aa9cde81926e8e855faf51bd1b4661d7cb6b77bcc48c53b86b7b96 |
|
MD5 | 0cb6a4c8ed2d5650f217b76996b7a295 |
|
BLAKE2b-256 | c34bf95cb62709d9f5f6562d61a54070521c044dadd46e238b257aaa43513f40 |
File details
Details for the file Customer_dna-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: Customer_dna-0.1.2-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 | a1cacadc7f85cdcf3e3f20444d6170aa0170ddd3bf0ae61961ae3a58fe8833d6 |
|
MD5 | 28941dca349e57498f1932f78d34f3f2 |
|
BLAKE2b-256 | b082b7708d6d468789cd76fa18b291946488b45ef671653810553fba3ac642c1 |