Unsupervised learning for e-commerce improvement: Trivago hotels clusterization case.
By: Felipe Oliveira
Tags: Clustering, Machine Learning, Travel, Unsupervised Learning, Data Science

5- The Machine Learning pipeline

Once we are dealing with an unsupervised learning problem, it is extremely important to well dimension two points:

Which train of thought we are trying to reproduce. How we will assess if the clusters are good or not.

The answer to those two questions remains on the reproducibility of the stakeholder manual grouping.

Our marketing stakeholders usually use conversions, impressions and income for more significant LOS and TTT segments, creating groups of hotels which we invest more in. So, our decision was to reproduce this task.

Finally, our final assessment will consist of 3 evaluations:

How close they are to the stakeholder’s manual grouping.

If clusters reproduce characteristics not provided on features (similar cities for example).

Unsupervised learning evaluation metrics like inter/intra cluster distances and silhouette curves.

Feature Engineering

Bearing in mind that we want to reproduce and facilitate the stakeholders’ job to apply multipliers on each class of TTT and LOS, we built our features considering the KPIs performance for each respective sector.

For example, instead of considering all the impressions of a specific hotel, we sectorized those impressions for each group of LOS and TTT.

The last part of the feature engineering was to choose which KPIs they would use inside that segmentation. And here is where the e-commerce funnel enters! We considered each step of the customer’s path until the checkout (order/conversion) is done, and we divided their values by category of LOS and TTT.

Note: during our tests we tried other travel business KPIs like average ticket, cities and countries, however the e-commerce funnel KPIs were by far the most efficient ones, considering the unsupervised learning metrics and the stakeholders’ evaluations.

Pipeline and the pre-processing leap

Ok, now let’s have just a quick recap. So far we’ve presented a sectorization of our hotels (by Length Of Stay — LOS and Time To Travel — TTT) that will create our features, categorizing each products’ KPIs inside that sectorization. The KPIs chosen were the steps of the e-commerce funnel. And finally, the aim of our clusterization is to group products with similar behavior inside each sector, better driving our business strategies for them.

Now illustrating our pipeline:

After we did that feature engineering process, we created a DataFrame with a huge amount of features; so, in order to reduce the dimensionality of it, we applied a Principal Component Analysis (PCA) method.

Therefore, we considered the linearity of our features — as it is a funnel, the KPIs’ values will always reduce as the funnel arrives to its end — to choose the K-Means as the clusterization model. The intrinsic features’ linearity was also a point to justify the use of PCA as the dimensionality reduction method.

Another point to justify the use of K-Means was the fact that we already have a range of clusters in mind (Trivago has a disponibility of 10 buckets). Then, we could apply an elbow curve method to find out the optimal point of K inside that range of cluster values.

Elbow curves on some different data set arrangements.

Finally, before inputting our principal components into the K-Means algorithm, we needed to scale it, and that was the most crucial part. In the beginning we tried some Robust and MinMax scalers, however, the first results weren’t that exciting until we changed the scaling method, as we can see in the next section.