Sitemap
Divya Narang

Divya Narang

Key Driver Analysis in Python

4 min readFeb 28, 2025

In market research, KDA is one of the most important concept to examine the sales numbers, market share of products , customer satisfaction and so on. This statistical concept is used in market research when simpler techniques like linear regression fail to depict the extent of influence of each explanatory variable on the dependent variable. This methodology is adopted when the relative weight of each explanatory variable has to be examined on the dependent variable. For this purpose, this analysis quantifies the relative importance of each of the predictor variable on the target variable.

Though there are many methods to apply the key driver analysis, we will implement the shapely regression for determining the relative importance of each explanatory variable on the dependent variable. The major reason due to which shapely regression is applied is due to the existence of high correlation among the explanatory variables. A high correlation within the explanatory variables can create the problem of multi-collinearity and can make the results of linear regression unreliable. This process involves running of lots of linear regression with multiple sets of predicting variables.

Consider a dataset where the market share of a product which is a dependent variable is determined by factors such as product market access rating , product efficacy, product safety, product satisfaction and communication rating. Now lets say there are two products , product 1 and product 2. Each of the factors including the market share for product 1 and product 2 are listed in different columns. Here is the link to the kaggle dataset:-

Now our aim is to run a key driver analysis using shapely value regression to determine the relative importance of each of the factors on the market share of product 1 and product 2 combined.

Now to run a combined analysis for product 1 and product 2 together, we need to slack both the datasets. Lets begin by importing the necessary libraries and dataset in python:-

For conducting the shapely value regression , we would import the library ‘shap’

Get Divya Narang’s stories in your inbox

Join Medium for free to get updates from this writer.

After uploading the excel file, we would rename each of the columns for better clarity:-

Press enter or click to view image in full size

After dropping the rows with no respondent ID , we would stack the data for product 1 and product 2

Press enter or click to view image in full size

We would concatenate the dataset of product 1 and product 2 , so that the stacked dataset looks in the following manner :-

Press enter or click to view image in full size

After concatenation , we will drop the missing values from the dependent variable. We define the following dependent and independent variable for conducting our key driver analysis:-

Press enter or click to view image in full size

Before deciding upon the fact that which type of key driver analysis has to be applied , let us examine the correlation among explanatory variables.

Press enter or click to view image in full size

As the figure above depicts that the correlation amongst all the explanatory variables is more than 0.5, we would opt for shapely regression which would solve the issue of sensitivity to high correlation.

The code for running the key driver analysis for the shapely value regression is as follows:-

Lets plot the shapely value summary and the permutation importance of each variable:-

Press enter or click to view image in full size
Press enter or click to view image in full size

The plots depict the relative importance of each variable. Communication and safety have the highest feature value indicating these two variables are the most important in determining the market share.

Now here two variables including market access and market efficacy have negative permutation importance and removing these two values would improve the performance of the model. The negative value could be attributed to the issue of multicollinearity , overfitting and non-monotonic features.

After removing these two variables , we can get an accurate model for shapely value regression.

--

--