# Clustering Customer Data

I dont know if this kind of question is allowed but i kinda hit a wall. I know about some clustering algorithms. I already implemented Fuzzy C-Means and Gaussian Mixture Model, but I dont really know what's the efficient way to cluster customer data and there is no label at all.

Since it's company data I can't say the detail, but if this helps here is the columns of the data:

First of all, I group by using panda's for each customer data so there's no duplicate. And then i just soft cluster to 15 clusters. Why 15 ? I tried to cluster it with number of product categories as number of clusters (since this what my supervisor asked me unless i can propose better method).

Is this the right way to do it ? or there is some papers that explain better methods?

what I make will be used for real marketing on e-commerce so I'm scared if my method screws the company up or something.

• Very similar to this question, possibly a duplicate. Don't worry, this is a solved problem! Also check out this page. Oct 8, 2018 at 14:10
• How did you handle those features? you have one "date", one "categorical feature" and 2 numerical features. What was the input of your clustering exactly? I write an answer and you may correct it according to your business question. Oct 8, 2018 at 14:20
• @KasraManshaei i tried using rfm based on how many category are there . example there are 3 category: there are 9 column : r_1 f_1 m_1 r_2 f_2 m_2 r_3 f_3 m_3 r_i mean how long since this customer buy a product with category i f_i mean how many category i product that this customer already bought till this time. m_i how much money a customer already spent on category i product. then i just cluster it . Oct 8, 2018 at 14:31

The answer could be anything according to your data! As you can not post your data here, I propose to spend some time on EDA to visualize your data from various POVs and see how it looks like. My suggestions:

1. Use only price and quantity for a 2-d scatter plot of your customers. In this task you may need feature scaling if the scale of prices and quantities are much different.
2. In the plot above, you may use different markers and/or colors to mark category or customer (as one customer can have several entries)
3. Convert "date" feature to 3 features, namely, year, month and day. (Using Python modules you may also get the weekday which might be meaningful). Then apply dimensionality reduction methods and visualize your data to get some insight about it.
4. Convert date to an ordinal feature (earliest date becomes 0 or 1 and it increases by 1 for each day) and plot total sale for each customer as a time-series and see it. You may do the same for categories. These can also be plotted as cumulative time-series. This can also be done according to year and month.

All above are just supposed to give you insight about the data (sometimes this insight can give you a proper hint for the number of clusters). This insight sometimes determines the analysis approach as well.

If your time-series become very sparse then time-series analysis might not be the best option (you can make it more dense by increasing time-stamp e.g. weekly, monthly, yearly, etc.)

The idea in your comment is pretty nice. You can use this cumulative features and apply dimensionality reduction methods to (again) see the nature of your data. Do not limit to linear ones. Try nonlinear ones as well.

You may create a graph out of your data and try graph analysis as well. Each customer is a node, so is each product when each edge shows a purchase (directed from customer to product) and the weight of that edge is the price and/or quantity. Then you end up with a bipartite graph. Try some analysis on this graph and see if it helps.

Hope it helps and good luck!

• Thanks a lot for detailed answer . The 4 points u mentioned are very interesting especially number 3 and 4. Ill try read the paper u mentioned tomorrow since it's already night here. If u dont mind tough i want to ask one more question if u know what soft/overlapping method that kinda newly released ? most soft clustering paper i read on google scholar mostly are just variant of fuzzy and modification of K means. Oct 8, 2018 at 15:21
• I am glad you liked it. To be honest I do not any significantly better algorithm than those we usually use. What you said about Fuzzy C-Means is right indeed. You may try Density-based algorithms or hierarchical ones as well. One of these categories will be enough for your purpose. I would suggest to spend more time on EDA and Feature Engineering. That is usually the key to the problem in practice. Oct 8, 2018 at 15:29