I have been tasked with performing customer segmentation for a Business to business use case based on customer purchase history. Can experts provide me inputs on how do I proceed with customer segmentation based on the following dataset

Dataset details which have been provided to me

enter image description here

Hierarchy 3,4,5 define the categories under which the product falls enter image description here

Edit: Also need inputs on how do i select features for my clustering algorithm?


So the question is about how to before customer segmentation on this data.

When I do any customer segmentation, I firstly think to myself, do I know how many segments prior to the analysis or not.

If I do,

Then I would use a clustering method like K-means clustering (https://towardsdatascience.com/understanding-k-means-clustering-in-machine-learning-6a6e67336aa1), where k refers to number of customer segments.

If I do not,

Then I would use something like agglomerative clustering (https://www.datanovia.com/en/lessons/agglomerative-hierarchical-clustering/).

When it comes to data representation, you would represent a customer and their (purchasing) behaviours as a vector of values (I will refer to as customer vector).

If the variables are numerical (e.g. number of items purchases), then you can put the numerical values in the customer vector. If the variables are categorical (e.g. products purchased), then we concatenate a one-hot encoded vector (https://machinelearningmastery.com/why-one-hot-encode-data-in-machine-learning/) of that variable to the customer vector.

  • $\begingroup$ Thank you shepan6. For clustering do I need to use the entire dataset or How do i do dimensionality reduction? $\endgroup$
    – pkumar_a
    Jun 26 '20 at 9:26
  • $\begingroup$ It would be obviously a good idea to do this for the whole dataset, but bear in mind for this task you need to group the features by customer to perform segmentation of customers. Dimensionality reduction might also be a good idea prior to clustering, something like Principal Component Analysis (PCA) would be a good place to start. (towardsdatascience.com/…) $\endgroup$
    – shepan6
    Jun 26 '20 at 9:41

What @shepan6 said... but one other thing.

Since you're grouping customers, you'll want to aggregate your dataset so that each row is a customer (not just a transaction)

Your new columns might look like this, prior to your clustering exercise:

  • customerid
  • days_since_prior_transaction
  • num_transactions_ever
  • num_transactions_last_180_days
  • num_online_sales
  • num_store_sales
  • region
  • num_dinnerware_purchases
  • num_tableware_purchases
  • num_porcelain_purchases
  • num_porc_dinnerware_set_purchases
  • num_CATEGORY1_purchases
  • diff_types_categories_purchased
  • $\begingroup$ Thank you Josh. $\endgroup$
    – pkumar_a
    Jun 26 '20 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.