Project status: Finished.
The main goal here is to use KMeans clustering to define the customer importance, based on two main variables: the total monetary spent (BRL), and frequency of purchase by customer.
This is and End-to-End Machine Learning Project for Customer Clusterization, from Database creation to Development of ML algorithm and bussiness analysis of results.
Take a look into the data Schema used to build our DataFrame:
: Source: KaggleList of technologies:
- Machine Learning: scikit-learn
To summarize, the model was developed with the following steps:
- Database creation (DDL) on mySQL ID; 1.1. data convertion from CSV to SQL format; 1.2. building Relationships between tables;
- my SQL integration with python (
mysql-connector
) 2.1. writting of CRUD queries inside jupyter notebook and convertion to pandas DataFrame; - Development of ML algorithm and bussiness analysis of results;
To classify customers, based on income generated and frequency of purchases, it was used an Unsupervised Machine Learning method: KMeans Clustering.
K-means clustering is a method of vector quantization, that aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean (cluster centers or cluster centroid), serving as a prototype of the cluster.
K-means clustering minimizes within-cluster variances (squared Euclidean distances), but not regular Euclidean distances, which would be the more difficult Weber problem: the mean optimizes squared errors, whereas only the geometric median minimizes Euclidean distances.
It is clear that beyond k = 5, the Sum Squared Distance starts to take a more plain decrease. Therefore, the optimal number of client clusters is 5. In other words, that means this company has 5 levels of customers to consider different marketing approaches. Lastly, the python connector was used to write a query to update the database.