Predicting price elasticity of demand with Python (Implementing STP Framework - Part 4/5)
Implementing logistic regression to predict price elasticity of demand
In this series, we are learning the STP Framework (Segmentation, Targeting, and Marketing), one of the most popular marketing approaches. In the first three posts, we’ve learned to understand our customers using segmentation and divided our customer base into four segments based on their demographics, psychographics, and behavioral characteristics. That covers the first step of the STP Framework.
Our four segments of customers are:
- Standard
- Career-focused
- Fewer-opportunities
- Well-off
In the Targeting step, we define strategies for our customer segments based on the overall attractiveness, strategic direction, market expertise, future potential, etc. Since this falls more into the company strategy under the marketing department, we’ll skip this step in this blog series, and move to the third step, Positioning.
As always, the notebook and the dataset are available in the Deepnote workspace.
Positioning
Positioning is a crucial part of marketing strategy, specially when the firm operates in a highly competitive market. We need to understand how consumers perceive the product offering and how it differs from other competitive offerings. Pricing and discounts play a vital role in shaping customer purchase decisions.
In this post, we’ll employ the logistic regression to understand how the price of a product influences a purchase decision and whether or not we have price elasticity.
But before that, let’s get introduced to the dataset. We will work with a new dataset prepared for this experiment, which leverages the segmentation step that we performed in the previous part.
Data Exploration
We’ll be working with a dataset that represents the customer purchase activities of a retail shop. This dataset is linked with the already familiar customer details dataset that we have already worked with in the earlier three parts of the series (part 1, part 2, and part 3). Every record in this dataset represents a purchase history of a customer.
Here is a detailed description of each attribute:

Other calculated attributes:

Mean_Price is going to be the primary feature of our experiment in finding the price elasticity. Has_Promotion and Action_Price are secondary features that might help us improve the model. We’ll see.





