# The Customer Lifetime Value — Survival Analysis
This is an example of a [[Machine Learning Applications]]
>[! Note] An Example
If we launch a new service, the announcement can drive a lot of sign-ups and perhaps even initial usage. If for some reason the service fails to deliver on expectations though, we will also see an increase in churn. If we only look at the upper funnel impact, we might conclude that the launch was successful. Given this, we always need to ensure we’re taking an end-to-end perspective to ensure that the change we’re evaluating is truly delivering on customer needs.
> By projecting the expected lifespan of the customer (using retention rates), the net spend (using historical purchase data), and the gross margin (by incorporating costs), we can calculate the expected customer value over time.
> Customer Lifetime Value is usually defined as the total net income a company can expect from a customer.>
***Customer Lifetime Value:*** represents the total net profit from a single customer.
1. Margin: the gross margin for your product expressed as a percentage.
> If you don’t know the gross margin, you can still use the rest of this formula (and article) to calculate the lifetime revenue of your customers. However, multiplying by gross margin (to determine LTV) allows you to account for costs and reduce the lifetime revenue amount in order to understand the net profit per customer.
>
2. Monthly Revenue
3. Tenure
$
\text{CLV} := \text{Margin } * \text{ Monthly Revenue } * \text{ Tenure}
$
$
\text{CLV} := \text{Profit per Year } \times \text{ Av. Duration of the Relationship }
$
In general, an LTV model has three components: customer’s value over time, the customer’s length of service and a discounting factor.
1. Customers value over time
2. Customers length of service
3. Discounting factor
*Note: Each component can be calculated or estimated separately or their modelling can be combined.*
## Survival Analysis
Two scenarios: some customers are still active, while others have already cancelled. Which of these two do we take in order to estimate the customers value over time and length of service?
Choosing either will bias the data.
> we've got a sense of data where we haven't actually observed the endpoint that we're trying to measure yet so essentially taking an average like this is never really going to be a sensible thing to do so.
>
Taken from this perspective, the lifetime value:
> Lifetime value is basically the probability that the customer hasn't churned at any day T into the future.
>
The survival of a customer has to do with the following aspects:
1. The **time** to a subscription end for a randomly chosen customer (time the customer churned) i.e. time taken until churn date
$
⁍
$
2. **Survival Function:** probability that the customer hasn't churned by time
$
S(t) = P(T > t)
$
3. **Hazard Function:** probability that the customer will churn at time *t*
$
\lambda(t) = \lim_{dt \rightarrow 0} \frac{P(t \leq T < t + dt)}{dt \cdot S(t)}
$
The Survival Function:
$
S(t) = \exp(\int_0^t \lambda(s) \cdot ds)
$
> To measure the problem we need survival analysis for estimating the time to an event for a particular population when you may not have all you know see all the events happen it’s all your data points.
>
> From when customers have signed up and started and moved off their free trial on to pay for subscription and how long do we think they're going to be open to using the service which obviously then goes into the lifetime value.
>
## The Kaplan-Meier Estimator
- Use the KM estimator to estimate the survival of a customer as a function of time
- Note whether or not they had the event or if they were censored
$
\text{Kaplan-Meier} = \prod_{t_i < t} \frac{n_i - d_i}{n_i}
$
[Nonparametric Estimation from Incomplete Observations](https://link.springer.com/chapter/10.1007/978-1-4612-4380-9_25)
[Harry's: Analyzing Customer Lifetime Value with Survival Analysis - Part 2](https://www.youtube.com/watch?v=gFc1n7Pz9zU&ab_channel=Looker)
[customer_segementation_lifetime_value/customer_segementation_lifetime_value.ipynb at master · rhkaz/customer_segementation_lifetime_value](https://github.com/rhkaz/customer_segementation_lifetime_value/blob/master/customer_segementation_lifetime_value.ipynb)
- ** Survivors Bias **
- Pay attention to the negative space