Churn modeling for business part II case study

s we have outlined in our previous article about churn modeling, loss of customers, subscribers or employees is one of the biggest challenges a business has to face. Hence the need to provide the data science assistance in understanding the reasons for churn and estimating the probability of its occurrence. In this article, we will show how we have approached the problem when working for one of our clients.
Blog
Machine learning

Table of Contents

The churn prediction use case

Our client was looking to better understand the churn behaviors of their employees, working in the fields where there is an especially high turnover rate – gastronomy, hospitality or retail. Employees in these fields work on a shift basis with non-fixed schedules, meaning that their work hours may change from day to day or week to week, which might result in differing shift lengths. While employee’s timetable is usually planned a month in advance, changes are pretty common, leading to unplanned shifts. Our goal was to find how these changes, shifts’ lengths, pay, and demographic factors affect churn probability.

The data

We were provided with a complete work history for employees engaged in the years 2015-2018. For every employee, we had access to their age, sex, education level and a city that they worked in, along with their shift history, including planned shit dates and hours and the actual time the employee worked for.

Defining the churn

As Greg has mentioned in his introduction to churn modeling, churn events can be defined in multiple ways and the choice of representation is probably the most important decision in the project. After gathering the requirements of our client and taking into consideration their specific field of activity, we have decided on setting the job end date for each employee on their last shift date and marking 30 days leading to this event as ones with a high probability of churn. This came mostly from the realization that we do not have data on when the employee actually gave notice or was dismissed.

Data transformation

After defining the churn event and cleaning the data, we have performed correlation tests on the readily available variables (mostly demographic ones) and concluded that linear regression models won’t give us a satisfactory result. Additionally, we had to incorporate data on work schedules in a way that would account for shifts’ varying lengths and divergence from planned schedules.

Inspiration for data representation came from the winning paper in WSDM Cup 2018 Churn Challenge – “Predicting Customer Churn: Extreme Gradient Boosting with Temporal Data“. We also had explainability in mind, as our client was interested in better understanding the phenomena, and not only receiving a measure of probability for each employee. Hence we have decided to forgo sequential models, as results of Recurrent Neural Networks tend to be hard to explain. Our attention went to tree-based models (Random Forests, Gradient Boosting Machines) and this has finally determined a data transformation method.

Each employee in our raw dataset became represented as multiple rows, for each day of said person’s work. In each of the rows, we have written in the static part (not changing from row to row): demographic information, job specification, and the dynamic part containing aggregations for current shifts data and previous periods.

Graphic description: Simplified data transformation process for one employee, with 2 last days marked as having high churn probability.

This data transformation approach leads to high dimensionality with a number of rows being a sum of all days worked by all employees. We were prepared for such a big dataset, but in case of spacing issues transformation may be performed with bigger granularity, eg. final dataset having only every second workday, or some of the rows may be randomly removed, which also acts as a way of regularization.

Models and explanations

Having the transformed dataset, we were able to train a Machine Learning model for the task of churn prediction. Our choice of model was quite straightforward, as we had to take into consideration:

  • Model explainability
  • Model efficiency
  • Model robustness on larger datasets

We have opted for the Gradient Boosted Tree model implemented in LightGBM library. The model was trained, including hyperparameter optimization, to achieve the best results on the AUC score. We then used eli5 library to pull feature importances for all training features employed in the tree models.

To allow easy usage, we have provided a web API to the trained model and the explanation component and packaged the whole project into a docker image, which allowed for smooth integration with the client’s internal system.

Results

Our client tested the solution thoroughly and reported that results were both consistent with their intuition on the subject and sometimes surprising, providing a novel view of the issue. We were happy to hear that our model provided accurate results with explained predictions and methods we used allowed the client for quick integration and production use.

Icon creators:

  • person by Adrien Coquet from the Noun Project
  • chef by Adrien Coquet from the Noun Project
  • schedule by Adnen Kadri from the Noun Project
Topics:

CTO / Data Scientist / Kaggle Grandmaster

CTO / Data Scientist / Kaggle Grandmaster

Other stories in category

BlogKaggle Days
4 – Nature never goes out of style!

4 – Nature never goes out of style!

4 – Nature never goes out of ...

Five continents, twelve events, one grand finale, and a community of more than 10 million - that's Kaggle Days, a nonprofit event for data science enthusiasts and Kagglers. Beginning in November 2021, hundreds of participants attending each meetup face a daunting task to be on the podium and win one of three invitations to the finals in Barcelona and prizes from Kaggle Days and Z by HPZ by HP.

Paras Varshney

16 Aug 2022

BlogKaggle Days
3 – Now you are playing with power

3 – Now you are playing with power

3 – Now you are playing with ...

"It was amazing," commented attendees of the third Kaggle Days X Z by HP World Championship meetup, and we fully agree. The Moscow event brought together as many as 280 data science enthusiasts in one place to take on the challenge and compete for three spots in the grand finale of Kaggle Days in Barcelona. Of course, we already know the winning teams that best handled the contest task. In addition to the excitement of the competition, in Moscow were also inspiring lectures, speeches, and fascinating presentations of modern equipment. As always, at Kaggle Days, a lot was going on.

Paras Varshney

16 Aug 2022

BlogKaggle Days
2 – Water Water everywhere, not a drop to drink

2 – Water Water everywhere, not a drop to drink

2 – Water Water everywhere, n...

"Happy to be part of shaping the future." "It's the Way of The Future." That is how the participants summed up another meetup organized as part of Kaggle Days, a non-profit event for data science enthusiasts who want to grow and compete for prizes under the watchful eye of top Kaggle mentors and grandmasters. The second meetup in New Delhi is behind us. Three hundred participants, more than one hundred teams, and only three invitations to the finals in Barcelona mean that the excitement could not be lacking.

Paras Varshney

16 Aug 2022