<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arngrímur Einarsson on Medium]]></title>
        <description><![CDATA[Stories by Arngrímur Einarsson on Medium]]></description>
        <link>https://medium.com/@arngrimureinarsson?source=rss-7685e5ba8606------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kZdvV88APtlHD8K2wKMj2Q.jpeg</url>
            <title>Stories by Arngrímur Einarsson on Medium</title>
            <link>https://medium.com/@arngrimureinarsson?source=rss-7685e5ba8606------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 19:28:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arngrimureinarsson/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Let’s Talk About Churn — Survival Analysis in Data Science]]></title>
            <link>https://medium.com/@arngrimureinarsson/lets-talk-about-churn-survival-analysis-in-data-science-5d49473472b2?source=rss-7685e5ba8606------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d49473472b2</guid>
            <category><![CDATA[survival-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[predictive-modeling]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Arngrímur Einarsson]]></dc:creator>
            <pubDate>Tue, 22 Oct 2024 21:03:26 GMT</pubDate>
            <atom:updated>2024-10-22T21:03:26.478Z</atom:updated>
            <content:encoded><![CDATA[<h3>Let’s Talk About Churn — Survival Analysis in Data Science</h3><p>One of the crucial task a data scientist has to deal with is to predict when an event will occur. That could be anything from forecasting equipment failure, patient outcomes in clinical trials or predicting customer churn. Having an idea of when these events might occur could make a huge difference for the operational manager of that equipment, the patients or the people running the telecom company.</p><p>In this post I’m going to talk about churn prediction in business and how we can predict it. This is where survival analysis comes in — a set of statistical techniques designed to analyze time-to-event data.</p><p>Survival analysis originally emerged in the medical and engineering fields where researchers wanted to understand time-to-event phenomena such as patient survival after treatment or failure rates of mechanical systems. One of the most significant milestones in this field traces came in 1958 when David Cox, a British statistician, introduced the Cox Proportional Hazard model, which became a groundbreaking method for handling time-to-event data.</p><h4><strong>What’s the math like?</strong></h4><p>At its very core, survival analysis deals with two key functions:</p><ol><li><strong>Survival function</strong> S(t): The probability that an event (e.g., customer churn) has not yet occurred by time t.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*9-CBBPYVmyLIph3azknu8A.png" /></figure><p>where T is the time to the event.</p><p>2. Hazard function h(t): The instantaneous risk of the event happening at time t, given that it has not happend before t.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*zcT472ao5H_RTrEAkoMXXQ.png" /></figure><p>We use these two functions to model the probability and rate of an event over time.</p><h4>The Cox Proportional Hazard Model</h4><p>This method is used quite frequently in survival analysis due to its flexibility and applicability across many different fields. First developed in 1972, this model focuses on estimating the hazard (or risk) of an event happening at time t, while allowing for the inclusion of covariates (predictor variables).</p><p>The hazard function can be expressed as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*VxqbAaxSL_0qR9oXOxTLAw.png" /></figure><p>where h_0 is the baseline hazard when all covariates are zero. The X’s in the equation above are the covariates (predictors) such as age, tenure, product usage while the betas are the coefficients that determines the strength for each covariate’s effect on the hazard.</p><p>One of the greatest strength of this model is that it does not require us to specify the baseline hazard making it a <strong>semi-parametric</strong> model.</p><p>In the business context, the Cox Proportional Hazard Model shines as a tool for predicting customer churn. By using it, we can see what factors contribute to churn and which does not allowing the business to respond accordingly. Variables such as customer engagement, tenure and usage can be included as covariates in the model to estimate the likelihood of a customer leaving at any given point in time.</p><h4>Enough of the math — let’s do an example!</h4><p>While the math certainly is beautiful we need to see some action. Let’s use synthetic telco churn data from Kaggle which gives us behavioral information about customers such as monthly charges, tenure, contract type and whether or not the customer has churned.</p><p>Key features:<br>1. CustomerID: Unique identifier for each customer.</p><p>2. Churn: Whether or not a customer has churned.</p><p>3. Tenure: Number of months the customer has been with the company.</p><p>4. MonthlyCharges, TotalCharges: Billing information.</p><p>After doing some basic transformation and cleaning the data (e.g., churn to binary, filling missing values, converting TotalCharges to numeric) we use. Note that Tenure is not a covariate but the time variable we are using, representing how long the customer stayed before the event (churn) occurred.</p><p>The next step is to split the data into train and test dataset (70/30) and fitting the model. The covariates yielded values of 0.06475174 and -0.00151949 meaning that as MonthlyCharges increased, the risk of churn increases. On the other hand as TotalCharges increased, the lower the risk of churn.</p><p>For demonstration purposes, we can use this model to predict the likelihood of churn for 50 random customers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*FFLyZE6jGAYb0SXg9RTZbA.png" /></figure><p>In the figure above, we can see that some customers are more likely than others to churn — we should reach out to these customers.</p><p>Thank you for reading this short post about survival!</p><p>Please feel free to reach out if you have any questions or you simply want to chat.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d49473472b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>