Skip to content

oguzerdo/automatized-kmeans-rfm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated RFM & K-Means

Automated RFM & KMeans Script

Performs RFM and Kmeans segmentation on your transaction data.

Untitled

It has two modes,

  • Automatic
  • User-defined

Automatic mode

When you run the app.py script, it runs with automatic mode defaultly.

You don't need to do anything in automatic mode.

Cluster images and segmentation file are uploaded to outputs folder.

Untitled

Untitled

User-defined mode

When you run the script with --manual parameter, it runs in manual mode.

According to an elbow graph you need to specify the input for the number of clusters.

Untitled

Sample usage:

python app.py --manual

GSheet Uploader Configuration

You can upload data to your google sheet in the script.

To do this, you need some steps.

First, you have to open and authorize a service account with your own Google account.

You can check this link for opening service account.

Then download your credentials script and save as **client-secret.json** in root folder.

Folder Tree

├── app.py
├── client-secret.json
├── datasets
│   └── data.xlsx
├── outputs
├── requirements.txt
└── scripts
    ├── data_prep.py
    └── loader.py

After these steps you have to share your Google Sheet with your service account as Editor.

Untitled

Last Step:

Set your gsheet page in loader.py

Write your spreadsheet name and sheet name

spreadSheetName = 'Clustering Data' # GSheet Name
sheetName = 'Sayfa1'                # Table name

If you have completed all these operations, you can run the script with the '--upload' parameter.

Sample Usage:

python app.py --upload 

You can connect your Google sheet to data studio and create a customer segment dashboard.

You can check mine

bon appetit!


Dashboard

RFM Section

Untitled

Cluster Info Section

Untitled

General Info Section

Untitled

Customer Info Section

Untitled


Usage Modes

python app.py                       # Automatic mode
python app.py --upload              # Automatic mode and gsheet upload
python app.py --manual              # Manual mode
python app.py --upload --manual     # Manual mode and gsheet upload

Requirements

pandas~=1.4.3
matplotlib~=3.5.3
seaborn~=0.11.2
sklearn~=0.0
scikit-learn~=1.1.2
yellowbrick~=1.5
gspread~=5.4.0
oauth2client~=4.1.3
numpy~=1.23.2

Author

Oğuz Erdoğan

Releases

No releases published

Packages

No packages published

Languages