In this assignment, I selected a telecommunications customer churn dataset that contains information about customer demographics, services, account information, and billing behavior. The dataset provides a useful opportunity to explore customer behavior and identify factors that may influence whether a customer stays with or leaves a telecommunications company.
My plan for this assignment is to load the data into R, clean and prepare the dataset, and perform exploratory data analysis (EDA) to identify patterns and relationships between customer characteristics and churn.
What factors are most strongly associated with customer churn in the telecommunications industry, and can customer churn be predicted using customer demographic, service, and account information?
2.CODE BASE
Under the Codebase section, I will import packages such as tidyverse to support data manipulation, analysis, and visualization. These tools will help me clean and explore the Telco dataset, identify meaningful patterns and relationships, and develop a better understanding of the factors associated with customer churn.
#IMPORT TIDYVERSE PACKAGE
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.2.1 ✔ readr 2.2.0
✔ forcats 1.0.1 ✔ stringr 1.6.0
✔ ggplot2 4.0.3 ✔ tibble 3.3.1
✔ lubridate 1.9.5 ✔ tidyr 1.3.2
✔ purrr 1.2.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
#IMPORT DATASET
dat <-read.csv("Telco Data - Approach.csv")names(dat)
CustomerID Count Country State City Zip.Code
1 3668-QPYBK 1 United States California Los Angeles 90003
2 9237-HQITU 1 United States California Los Angeles 90005
3 9305-CDSKC 1 United States California Los Angeles 90006
4 7892-POOKP 1 United States California Los Angeles 90010
5 0280-XJGEX 1 United States California Los Angeles 90015
6 4190-MFLUW 1 United States California Los Angeles 90020
Lat.Long Latitude Longitude Gender Senior.Citizen Partner
1 33.964131, -118.272783 33.96413 -118.2728 Male No No
2 34.059281, -118.30742 34.05928 -118.3074 Female No No
3 34.048013, -118.293953 34.04801 -118.2940 Female No No
4 34.062125, -118.315709 34.06213 -118.3157 Female No Yes
5 34.039224, -118.266293 34.03922 -118.2663 Male No No
6 34.066367, -118.309868 34.06637 -118.3099 Female No Yes
Dependents Tenure.Months Phone.Service Multiple.Lines InternetService
1 No 2 Yes No DSL
2 Yes 2 Yes No Fiber optic
3 Yes 8 Yes Yes Fiber optic
4 Yes 28 Yes Yes Fiber optic
5 Yes 49 Yes Yes Fiber optic
6 No 10 Yes No DSL
Online.Security Online.Backup Device.Protection Tech.Support Streaming.TV
1 Yes Yes No No No
2 No No No No No
3 No No Yes No Yes
4 No No Yes Yes Yes
5 No Yes Yes No Yes
6 No No Yes Yes No
Streaming.Movies Contract Paperless.Billing Payment.Method
1 No Month-to-month Yes Mailed check
2 No Month-to-month Yes Electronic check
3 Yes Month-to-month Yes Electronic check
4 Yes Month-to-month Yes Electronic check
5 Yes Month-to-month Yes Bank transfer (automatic)
6 No Month-to-month No Credit card (automatic)
Monthly.Charges Total.Charges Churn.Label Churn.Value Churn.Score CLTV
1 53.85 108.15 Yes 1 86 3239
2 70.70 151.65 Yes 1 67 2701
3 99.65 820.50 Yes 1 86 5372
4 104.80 3046.05 Yes 1 84 5003
5 103.70 5036.30 Yes 1 89 5340
6 55.20 528.35 Yes 1 78 5925
Churn.Reason
1 Competitor made better offer
2 Moved
3 Moved
4 Moved
5 Competitor had better devices
6 Competitor offered higher download speeds
Comment: from the above you can see that the dataframe has 7043 rows and 33 columns
datis_churn <-factor( dat$Churn,levels =c("No", "Yes"),labels =c("Stayed", "Churned"))# Display the first six rowsprint(head(dat))
CustomerID Count Country State City Zip.Code
1 3668-QPYBK 1 United States California Los Angeles 90003
2 9237-HQITU 1 United States California Los Angeles 90005
3 9305-CDSKC 1 United States California Los Angeles 90006
4 7892-POOKP 1 United States California Los Angeles 90010
5 0280-XJGEX 1 United States California Los Angeles 90015
6 4190-MFLUW 1 United States California Los Angeles 90020
Lat.Long Latitude Longitude Gender Senior.Citizen Partner
1 33.964131, -118.272783 33.96413 -118.2728 Male No No
2 34.059281, -118.30742 34.05928 -118.3074 Female No No
3 34.048013, -118.293953 34.04801 -118.2940 Female No No
4 34.062125, -118.315709 34.06213 -118.3157 Female No Yes
5 34.039224, -118.266293 34.03922 -118.2663 Male No No
6 34.066367, -118.309868 34.06637 -118.3099 Female No Yes
Dependents Tenure.Months Phone.Service Multiple.Lines InternetService
1 No 2 Yes No DSL
2 Yes 2 Yes No Fiber optic
3 Yes 8 Yes Yes Fiber optic
4 Yes 28 Yes Yes Fiber optic
5 Yes 49 Yes Yes Fiber optic
6 No 10 Yes No DSL
Online.Security Online.Backup Device.Protection Tech.Support Streaming.TV
1 Yes Yes No No No
2 No No No No No
3 No No Yes No Yes
4 No No Yes Yes Yes
5 No Yes Yes No Yes
6 No No Yes Yes No
Streaming.Movies Contract Paperless.Billing Payment.Method
1 No Month-to-month Yes Mailed check
2 No Month-to-month Yes Electronic check
3 Yes Month-to-month Yes Electronic check
4 Yes Month-to-month Yes Electronic check
5 Yes Month-to-month Yes Bank transfer (automatic)
6 No Month-to-month No Credit card (automatic)
Monthly.Charges Total.Charges Churn.Label Churn.Value Churn.Score CLTV
1 53.85 108.15 Yes 1 86 3239
2 70.70 151.65 Yes 1 67 2701
3 99.65 820.50 Yes 1 86 5372
4 104.80 3046.05 Yes 1 84 5003
5 103.70 5036.30 Yes 1 89 5340
6 55.20 528.35 Yes 1 78 5925
Churn.Reason
1 Competitor made better offer
2 Moved
3 Moved
4 Moved
5 Competitor had better devices
6 Competitor offered higher download speeds
Comment : Here is created a new column called ISCHURN and renamed the categories “NO” to stayed (meaning the customer did not leave the telco) and “YES” to Churned (meaning the customer left the telco due to various reason i will further analysis).
#DATA VISUALISATION
library(tidyverse)head(dat)
CustomerID Count Country State City Zip.Code
1 3668-QPYBK 1 United States California Los Angeles 90003
2 9237-HQITU 1 United States California Los Angeles 90005
3 9305-CDSKC 1 United States California Los Angeles 90006
4 7892-POOKP 1 United States California Los Angeles 90010
5 0280-XJGEX 1 United States California Los Angeles 90015
6 4190-MFLUW 1 United States California Los Angeles 90020
Lat.Long Latitude Longitude Gender Senior.Citizen Partner
1 33.964131, -118.272783 33.96413 -118.2728 Male No No
2 34.059281, -118.30742 34.05928 -118.3074 Female No No
3 34.048013, -118.293953 34.04801 -118.2940 Female No No
4 34.062125, -118.315709 34.06213 -118.3157 Female No Yes
5 34.039224, -118.266293 34.03922 -118.2663 Male No No
6 34.066367, -118.309868 34.06637 -118.3099 Female No Yes
Dependents Tenure.Months Phone.Service Multiple.Lines InternetService
1 No 2 Yes No DSL
2 Yes 2 Yes No Fiber optic
3 Yes 8 Yes Yes Fiber optic
4 Yes 28 Yes Yes Fiber optic
5 Yes 49 Yes Yes Fiber optic
6 No 10 Yes No DSL
Online.Security Online.Backup Device.Protection Tech.Support Streaming.TV
1 Yes Yes No No No
2 No No No No No
3 No No Yes No Yes
4 No No Yes Yes Yes
5 No Yes Yes No Yes
6 No No Yes Yes No
Streaming.Movies Contract Paperless.Billing Payment.Method
1 No Month-to-month Yes Mailed check
2 No Month-to-month Yes Electronic check
3 Yes Month-to-month Yes Electronic check
4 Yes Month-to-month Yes Electronic check
5 Yes Month-to-month Yes Bank transfer (automatic)
6 No Month-to-month No Credit card (automatic)
Monthly.Charges Total.Charges Churn.Label Churn.Value Churn.Score CLTV
1 53.85 108.15 Yes 1 86 3239
2 70.70 151.65 Yes 1 67 2701
3 99.65 820.50 Yes 1 86 5372
4 104.80 3046.05 Yes 1 84 5003
5 103.70 5036.30 Yes 1 89 5340
6 55.20 528.35 Yes 1 78 5925
Churn.Reason
1 Competitor made better offer
2 Moved
3 Moved
4 Moved
5 Competitor had better devices
6 Competitor offered higher download speeds
CustomerID Count Country State City Zip.Code
1 3668-QPYBK 1 United States California Los Angeles 90003
2 9237-HQITU 1 United States California Los Angeles 90005
3 9305-CDSKC 1 United States California Los Angeles 90006
4 7892-POOKP 1 United States California Los Angeles 90010
5 0280-XJGEX 1 United States California Los Angeles 90015
6 4190-MFLUW 1 United States California Los Angeles 90020
Lat.Long Latitude Longitude Gender Senior.Citizen Partner
1 33.964131, -118.272783 33.96413 -118.2728 Male No No
2 34.059281, -118.30742 34.05928 -118.3074 Female No No
3 34.048013, -118.293953 34.04801 -118.2940 Female No No
4 34.062125, -118.315709 34.06213 -118.3157 Female No Yes
5 34.039224, -118.266293 34.03922 -118.2663 Male No No
6 34.066367, -118.309868 34.06637 -118.3099 Female No Yes
Dependents Tenure.Months Phone.Service Multiple.Lines InternetService
1 No 2 Yes No DSL
2 Yes 2 Yes No Fiber optic
3 Yes 8 Yes Yes Fiber optic
4 Yes 28 Yes Yes Fiber optic
5 Yes 49 Yes Yes Fiber optic
6 No 10 Yes No DSL
Online.Security Online.Backup Device.Protection Tech.Support Streaming.TV
1 Yes Yes No No No
2 No No No No No
3 No No Yes No Yes
4 No No Yes Yes Yes
5 No Yes Yes No Yes
6 No No Yes Yes No
Streaming.Movies Contract Paperless.Billing Payment.Method
1 No Month-to-month Yes Mailed check
2 No Month-to-month Yes Electronic check
3 Yes Month-to-month Yes Electronic check
4 Yes Month-to-month Yes Electronic check
5 Yes Month-to-month Yes Bank transfer (automatic)
6 No Month-to-month No Credit card (automatic)
Monthly.Charges Total.Charges Churn.Label Churn.Value Churn.Score CLTV
1 53.85 108.15 Yes 1 86 3239
2 70.70 151.65 Yes 1 67 2701
3 99.65 820.50 Yes 1 86 5372
4 104.80 3046.05 Yes 1 84 5003
5 103.70 5036.30 Yes 1 89 5340
6 55.20 528.35 Yes 1 78 5925
Churn.Reason
1 Competitor made better offer
2 Moved
3 Moved
4 Moved
5 Competitor had better devices
6 Competitor offered higher download speeds
ggplot(dat, aes(x = Gender, y = Total.Charges)) +stat_summary(fun = sum, geom ="bar", fill ="blue") +labs(title ="Total Charges by Gender",x ="Gender",y ="Total Charges" ) +theme_minimal()
Warning: Removed 11 rows containing non-finite outside the scale range
(`stat_summary()`).
## Comment ; The analysis shows that male customers accounted for 50.47% of the total charges, while female customers accounted for 49.53%. This indicates a nearly equal contribution to total charges between male and female customers, with male customers contributing slightly more## PAYMENT METHOD VS TOTAL CHARGEShead(dat)
CustomerID Count Country State City Zip.Code
1 3668-QPYBK 1 United States California Los Angeles 90003
2 9237-HQITU 1 United States California Los Angeles 90005
3 9305-CDSKC 1 United States California Los Angeles 90006
4 7892-POOKP 1 United States California Los Angeles 90010
5 0280-XJGEX 1 United States California Los Angeles 90015
6 4190-MFLUW 1 United States California Los Angeles 90020
Lat.Long Latitude Longitude Gender Senior.Citizen Partner
1 33.964131, -118.272783 33.96413 -118.2728 Male No No
2 34.059281, -118.30742 34.05928 -118.3074 Female No No
3 34.048013, -118.293953 34.04801 -118.2940 Female No No
4 34.062125, -118.315709 34.06213 -118.3157 Female No Yes
5 34.039224, -118.266293 34.03922 -118.2663 Male No No
6 34.066367, -118.309868 34.06637 -118.3099 Female No Yes
Dependents Tenure.Months Phone.Service Multiple.Lines InternetService
1 No 2 Yes No DSL
2 Yes 2 Yes No Fiber optic
3 Yes 8 Yes Yes Fiber optic
4 Yes 28 Yes Yes Fiber optic
5 Yes 49 Yes Yes Fiber optic
6 No 10 Yes No DSL
Online.Security Online.Backup Device.Protection Tech.Support Streaming.TV
1 Yes Yes No No No
2 No No No No No
3 No No Yes No Yes
4 No No Yes Yes Yes
5 No Yes Yes No Yes
6 No No Yes Yes No
Streaming.Movies Contract Paperless.Billing Payment.Method
1 No Month-to-month Yes Mailed check
2 No Month-to-month Yes Electronic check
3 Yes Month-to-month Yes Electronic check
4 Yes Month-to-month Yes Electronic check
5 Yes Month-to-month Yes Bank transfer (automatic)
6 No Month-to-month No Credit card (automatic)
Monthly.Charges Total.Charges Churn.Label Churn.Value Churn.Score CLTV
1 53.85 108.15 Yes 1 86 3239
2 70.70 151.65 Yes 1 67 2701
3 99.65 820.50 Yes 1 86 5372
4 104.80 3046.05 Yes 1 84 5003
5 103.70 5036.30 Yes 1 89 5340
6 55.20 528.35 Yes 1 78 5925
Churn.Reason
1 Competitor made better offer
2 Moved
3 Moved
4 Moved
5 Competitor had better devices
6 Competitor offered higher download speeds
ggplot(dat, aes(x = Payment.Method, y = Total.Charges)) +stat_summary(fun = sum, geom ="bar", fill ="red") +labs(title ="Payment.Method by Gender",x ="Payment Method",y ="Total Charges" ) +theme_minimal()
Warning: Removed 11 rows containing non-finite outside the scale range
(`stat_summary()`).
##Comment : Electronic check customers contributed the highest share of total charges (30.80%), followed by automatic bank transfers (29.57%), credit cards (29.10%), and mailed checks (10.53%)## CHURN LABEL VS GENDER head(dat)
CustomerID Count Country State City Zip.Code
1 3668-QPYBK 1 United States California Los Angeles 90003
2 9237-HQITU 1 United States California Los Angeles 90005
3 9305-CDSKC 1 United States California Los Angeles 90006
4 7892-POOKP 1 United States California Los Angeles 90010
5 0280-XJGEX 1 United States California Los Angeles 90015
6 4190-MFLUW 1 United States California Los Angeles 90020
Lat.Long Latitude Longitude Gender Senior.Citizen Partner
1 33.964131, -118.272783 33.96413 -118.2728 Male No No
2 34.059281, -118.30742 34.05928 -118.3074 Female No No
3 34.048013, -118.293953 34.04801 -118.2940 Female No No
4 34.062125, -118.315709 34.06213 -118.3157 Female No Yes
5 34.039224, -118.266293 34.03922 -118.2663 Male No No
6 34.066367, -118.309868 34.06637 -118.3099 Female No Yes
Dependents Tenure.Months Phone.Service Multiple.Lines InternetService
1 No 2 Yes No DSL
2 Yes 2 Yes No Fiber optic
3 Yes 8 Yes Yes Fiber optic
4 Yes 28 Yes Yes Fiber optic
5 Yes 49 Yes Yes Fiber optic
6 No 10 Yes No DSL
Online.Security Online.Backup Device.Protection Tech.Support Streaming.TV
1 Yes Yes No No No
2 No No No No No
3 No No Yes No Yes
4 No No Yes Yes Yes
5 No Yes Yes No Yes
6 No No Yes Yes No
Streaming.Movies Contract Paperless.Billing Payment.Method
1 No Month-to-month Yes Mailed check
2 No Month-to-month Yes Electronic check
3 Yes Month-to-month Yes Electronic check
4 Yes Month-to-month Yes Electronic check
5 Yes Month-to-month Yes Bank transfer (automatic)
6 No Month-to-month No Credit card (automatic)
Monthly.Charges Total.Charges Churn.Label Churn.Value Churn.Score CLTV
1 53.85 108.15 Yes 1 86 3239
2 70.70 151.65 Yes 1 67 2701
3 99.65 820.50 Yes 1 86 5372
4 104.80 3046.05 Yes 1 84 5003
5 103.70 5036.30 Yes 1 89 5340
6 55.20 528.35 Yes 1 78 5925
Churn.Reason
1 Competitor made better offer
2 Moved
3 Moved
4 Moved
5 Competitor had better devices
6 Competitor offered higher download speeds
ggplot(dat, aes(x = Churn.Label, y = Total.Charges)) +stat_summary(fun = sum, geom ="bar", fill ="Green") +labs(title ="Churn label by total charges",x ="Churn.Label",y ="Total Charges" ) +theme_minimal()
Warning: Removed 11 rows containing non-finite outside the scale range
(`stat_summary()`).
## Comment : The analysis shows that 73.46% of customers remained with the telecommunications company, while 26.54% of customers churned. This indicates that approximately one in four customers left the company, highlighting a significant level of customer churn that warrants further investigation
#THOUGHTS
The analysis shows that male customers contributed 50.47% of total charges, compared with 49.53% for female customers, indicating a nearly equal contribution.
For payment methods, electronic check customers contributed the highest share at 30.80%, followed by automatic bank transfers at 29.57% and credit cards at 29.10%. Mailed checks contributed 10.53%.
The churn analysis shows that 73.46% of customers stayed, while 26.54% churned. This means approximately 1 in 4 customers left, highlighting the importance of further investigating the factors associated with churn.
#AI USE
ChatGPT was used as a supporting tool to assist with data analysis, R coding, and visualization development. All AI-generated code and analytical suggestions were reviewed, tested, and monitored by me to ensure that the final analysis was accurate and aligned with the project objectives.