Telco Churn

This example uses the Telco Churn dataset to predict which Telco user is likely to churn; that is, customers that will likely stop using Telco. You can download the Jupyter Notebook of the study here.

  • Churn - customers that left within the last month
  • Services - services of each customer (phone, multiple lines, internet, online security, online backup, device protection, tech support, and streaming TV and movies)
  • Customer account information - how long they’ve been a customer, contract, payment method, paperless billing, monthly charges, and total charges
  • Customer demographics - gender, age range, and if they have partners and dependents

We will follow the data science cycle (Data Exploration - Data Preparation - Data Modeling - Model Evaluation - Model Deployment) to solve this problem.

Initialization

This example uses the following version of VerticaPy:

In [1]:
import verticapy as vp
vp.__version__
Out[1]:
'0.9.0'

Connect to Vertica. This example uses an existing connection called "VerticaDSN." For details on how to create a connection, use see the connection tutorial.

In [2]:
vp.connect("VerticaDSN")

Let's create a Virtual DataFrame of the dataset. The dataset is available here.

In [3]:
churn = vp.read_csv('data/churn.csv')
display(churn)
Abc
customerID
Varchar(20)
Abc
gender
Varchar(20)
123
SeniorCitizen
Int
010
Partner
Boolean
010
Dependents
Boolean
123
tenure
Int
010
PhoneService
Boolean
Abc
MultipleLines
Varchar(100)
Abc
InternetService
Varchar(22)
Abc
OnlineSecurity
Varchar(38)
Abc
OnlineBackup
Varchar(38)
Abc
DeviceProtection
Varchar(38)
Abc
TechSupport
Varchar(38)
Abc
StreamingTV
Varchar(38)
Abc
StreamingMovies
Varchar(38)
Abc
Contract
Varchar(28)
010
PaperlessBilling
Boolean
Abc
PaymentMethod
Varchar(50)
123
MonthlyCharges
Numeric(8,3)
123
TotalCharges
Numeric(9,3)
010
Churn
Boolean
10002-ORFBOFemale0
9
NoDSLNoYesNoYesYesNoOne year
Mailed check65.6593.3
20003-MKNFEMale0
9
YesDSLNoNoNoNoNoYesMonth-to-month
Mailed check59.9542.4
30004-TLHLJMale0
4
NoFiber opticNoNoYesNoNoNoMonth-to-month
Electronic check73.9280.85
40011-IGKFFMale1
13
NoFiber opticNoYesYesNoYesYesMonth-to-month
Electronic check98.01237.85
50013-EXCHZFemale1
3
NoFiber opticNoNoNoYesYesNoMonth-to-month
Mailed check83.9267.4
60013-MHZWFFemale0
9
NoDSLNoNoNoYesYesYesMonth-to-month
Credit card (automatic)69.4571.45
70013-SMEOEFemale1
71
NoFiber opticYesYesYesYesYesYesTwo year
Bank transfer (automatic)109.77904.25
80014-BMAQUMale0
63
YesFiber opticYesNoNoYesNoNoTwo year
Credit card (automatic)84.655377.8
90015-UOCOJFemale1
7
NoDSLYesNoNoNoNoNoMonth-to-month
Electronic check48.2340.35
100016-QLJISFemale0
65
YesDSLYesYesYesYesYesYesTwo year
Mailed check90.455957.9
110017-DINOCMale0
54
No phone serviceDSLYesNoNoYesYesNoTwo year
Credit card (automatic)45.22460.55
120017-IUDMWFemale0
72
YesFiber opticYesYesYesYesYesYesTwo year
Credit card (automatic)116.88456.75
130018-NYROUFemale0
5
NoFiber opticNoNoNoNoNoNoMonth-to-month
Electronic check68.95351.5
140019-EFAEPFemale0
72
YesFiber opticYesYesYesNoYesNoTwo year
Bank transfer (automatic)101.37261.25
150019-GFNTWFemale0
56
No phone serviceDSLYesYesYesYesNoNoTwo year
Bank transfer (automatic)45.052560.1
160020-INWCKFemale0
71
YesFiber opticNoYesYesNoNoYesTwo year
Credit card (automatic)95.756849.4
170020-JDNXPFemale0
34
No phone serviceDSLYesNoYesYesYesYesOne year
Mailed check61.251993.2
180021-IKXGCFemale1
1
YesFiber opticNoNoNoNoNoNoMonth-to-month
Electronic check72.172.1
190022-TCJCIMale1
45
NoDSLYesNoYesNoNoYesOne year
Credit card (automatic)62.72791.5
200023-HGHWLMale1
1
No phone serviceDSLNoNoNoNoNoNoMonth-to-month
Electronic check25.125.1
210023-UYUPNFemale1
50
YesNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceOne year
Electronic check25.21306.3
220023-XUOPTFemale0
13
YesFiber opticNoYesYesNoYesNoMonth-to-month
Electronic check94.11215.6
230027-KWYKWFemale0
23
YesFiber opticNoNoNoNoYesNoMonth-to-month
Electronic check83.751849.95
240030-FNXPPFemale0
3
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceMonth-to-month
Mailed check19.8557.2
250031-PVLZIFemale0
4
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceMonth-to-month
Mailed check20.3576.35
260032-PGELSFemale0
1
No phone serviceDSLYesNoNoNoNoNoMonth-to-month
Bank transfer (automatic)30.530.5
270036-IHMOTFemale0
55
NoFiber opticNoYesYesYesYesYesOne year
Bank transfer (automatic)103.75656.75
280040-HALCWMale0
54
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceTwo year
Credit card (automatic)20.41090.6
290042-JVWOJMale0
26
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceOne year
Bank transfer (automatic)19.6471.85
300042-RLHYPFemale0
69
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceTwo year
Bank transfer (automatic)19.71396.9
310048-LUMLSMale0
37
NoFiber opticNoNoNoNoYesYesOne year
Credit card (automatic)91.23247.55
320048-PIHNLFemale0
49
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceOne year
Bank transfer (automatic)20.45900.9
330052-DCKONMale0
66
YesFiber opticYesYesYesYesYesYesOne year
Bank transfer (automatic)115.87942.15
340052-YNYOTFemale0
67
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceOne year
Electronic check20.551343.4
350056-EPFBGMale0
20
No phone serviceDSLYesNoYesYesNoNoTwo year
Credit card (automatic)39.4825.4
360057-QBUQHFemale0
43
YesNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceTwo year
Electronic check25.11070.15
370058-EVZWMFemale0
55
YesFiber opticYesNoNoNoYesNoMonth-to-month
Bank transfer (automatic)89.84959.6
380060-FUALYFemale0
59
YesFiber opticYesYesNoNoYesNoMonth-to-month
Electronic check94.755597.65
390064-SUDOGFemale0
12
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceTwo year
Bank transfer (automatic)20.3224.5
400064-YIJGFMale0
27
YesFiber opticNoNoNoNoNoNoMonth-to-month
Bank transfer (automatic)75.751929.0
410067-DKWBLMale1
2
NoDSLYesNoNoNoNoNoMonth-to-month
Electronic check49.2591.1
420068-FIGTFFemale0
27
NoDSLNoYesYesYesYesYesOne year
Mailed check78.22078.95
430071-NDAFPMale0
25
YesNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceTwo year
Credit card (automatic)25.5630.6
440074-HDKDGMale0
25
NoDSLYesYesYesNoNoNoOne year
Bank transfer (automatic)61.61611.0
450076-LVEPSMale0
29
No phone serviceDSLYesYesYesYesNoNoMonth-to-month
Mailed check45.01242.45
460078-XZMHTMale0
72
YesDSLNoYesYesYesYesYesTwo year
Bank transfer (automatic)85.156316.2
470080-EMYVYFemale0
14
NoDSLNoYesNoNoNoNoOne year
Credit card (automatic)51.45727.85
480080-OROZOFemale0
35
NoFiber opticNoNoYesYesYesYesOne year
Electronic check99.253532.0
490082-LDZUEMale0
1
NoDSLNoNoNoNoNoNoMonth-to-month
Mailed check44.344.3
500082-OQIQYMale0
29
NoFiber opticNoNoNoYesYesYesMonth-to-month
Electronic check94.22607.6
510083-PIVIKMale0
64
YesDSLYesYesYesYesYesNoOne year
Electronic check81.255567.55
520089-IIQKOFemale0
39
YesFiber opticNoNoNoYesYesYesMonth-to-month
Credit card (automatic)99.953767.4
530093-EXYQLFemale1
40
NoFiber opticNoNoNoNoYesYesMonth-to-month
Electronic check91.553673.6
540093-XWZFYMale0
40
YesFiber opticNoYesYesNoYesYesMonth-to-month
Credit card (automatic)104.54036.85
550094-OIFMOFemale1
11
NoFiber opticNoYesNoNoYesYesMonth-to-month
Electronic check95.01120.3
560096-BXERSFemale0
6
YesDSLNoNoNoNoNoNoMonth-to-month
Electronic check50.35314.55
570096-FCPUFMale0
30
YesDSLYesNoNoNoNoYesMonth-to-month
Mailed check64.51888.45
580098-BOWSOMale0
27
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceMonth-to-month
Electronic check19.4529.8
590100-DUVFCMale1
70
YesFiber opticNoYesYesNoYesYesOne year
Electronic check104.87308.95
600103-CSITQFemale0
57
YesFiber opticNoYesYesYesYesYesOne year
Bank transfer (automatic)109.46252.7
610104-PPXDVMale0
58
NoDSLNoNoYesNoNoNoOne year
Credit card (automatic)50.32878.55
620106-GHRQRMale0
16
YesDSLNoYesYesNoNoYesMonth-to-month
Bank transfer (automatic)71.41212.1
630106-UGRDOFemale0
69
YesFiber opticYesYesYesYesYesYesTwo year
Electronic check116.08182.85
640107-WESLMMale0
1
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceMonth-to-month
Electronic check19.8519.85
650107-YHINAMale0
1
YesFiber opticNoNoYesNoYesYesMonth-to-month
Electronic check99.7599.75
660111-KLBQGMale1
32
NoFiber opticNoYesNoNoYesYesMonth-to-month
Mailed check93.952861.45
670112-QAWRZMale0
16
YesFiber opticNoNoYesNoYesNoMonth-to-month
Bank transfer (automatic)90.81442.2
680112-QWPNCMale0
49
YesDSLYesNoYesYesYesYesOne year
Electronic check84.354059.35
690114-IGABWFemale0
71
No phone serviceDSLNoYesYesYesYesYesTwo year
Bank transfer (automatic)58.254145.9
700114-PEGZZFemale0
33
YesFiber opticNoYesYesNoYesYesMonth-to-month
Electronic check107.553645.5
710114-RSRRWFemale0
10
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceMonth-to-month
Bank transfer (automatic)19.95187.75
720115-TFERTMale0
21
YesFiber opticNoYesYesYesYesYesMonth-to-month
Electronic check111.22317.1
730117-LFRMWMale0
37
No phone serviceDSLYesYesYesNoNoNoMonth-to-month
Bank transfer (automatic)40.21448.8
740118-JPNOYFemale1
26
NoFiber opticYesNoNoNoYesNoMonth-to-month
Credit card (automatic)85.82193.65
750121-SNYRKMale0
50
No phone serviceDSLYesNoNoYesNoNoOne year
Mailed check35.41748.9
760122-OAHPZFemale0
7
YesFiber opticNoNoNoNoNoNoMonth-to-month
Electronic check73.85511.25
770123-CRBRTFemale0
61
YesDSLYesYesYesYesYesYesTwo year
Mailed check88.15526.75
780125-LZQXKMale0
15
NoFiber opticNoNoYesYesYesYesMonth-to-month
Electronic check101.351553.95
790128-MKWSGFemale0
26
No phone serviceDSLYesNoNoYesNoYesMonth-to-month
Mailed check45.81147.0
800129-KPTWJMale0
72
NoFiber opticNoNoYesNoYesYesMonth-to-month
Electronic check94.656747.35
810129-QMPDRMale0
44
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceOne year
Bank transfer (automatic)20.5865.05
820130-SXOUNMale0
66
YesFiber opticNoYesNoNoNoYesMonth-to-month
Credit card (automatic)89.45976.9
830133-BMFZOFemale0
2
NoFiber opticYesYesNoYesNoNoMonth-to-month
Electronic check86.25181.65
840134-XWXCEFemale1
44
NoDSLNoNoYesYesYesYesOne year
Bank transfer (automatic)74.853268.05
850135-NMXAPFemale0
12
YesFiber opticNoYesNoNoYesNoMonth-to-month
Bank transfer (automatic)89.751052.4
860136-IFMYDMale1
69
YesFiber opticNoYesYesYesYesYesTwo year
Electronic check109.957634.25
870137-OCGABFemale0
1
YesFiber opticNoYesNoNoNoNoMonth-to-month
Mailed check80.280.2
880137-UDEUOFemale0
3
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceMonth-to-month
Mailed check19.8563.75
890139-IVFJGFemale0
2
NoFiber opticYesYesNoNoYesNoMonth-to-month
Electronic check90.35190.5
900141-YEAYSFemale1
27
YesFiber opticNoYesYesNoNoNoMonth-to-month
Bank transfer (automatic)86.452401.05
910142-GVYSNMale0
26
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceMonth-to-month
Electronic check20.3511.25
920147-ESWWRFemale1
39
YesFiber opticNoNoNoYesYesYesMonth-to-month
Electronic check101.253949.15
930148-DCDOSMale0
25
YesFiber opticNoNoNoNoYesYesMonth-to-month
Bank transfer (automatic)94.72362.1
940151-ONTOVFemale0
1
NoFiber opticNoNoNoNoNoNoMonth-to-month
Mailed check70.970.9
950156-FVPTAMale0
22
NoDSLYesNoNoYesNoNoMonth-to-month
Electronic check54.21152.7
960164-APGRBFemale0
72
YesFiber opticYesYesYesYesYesYesTwo year
Electronic check114.98496.7
970164-XAIRPFemale0
24
NoNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceTwo year
Bank transfer (automatic)19.55470.2
980168-XZKBBFemale0
19
YesFiber opticNoNoNoNoYesNoMonth-to-month
Electronic check86.851564.4
990174-QRVVYMale0
71
YesNoNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceNo internet serviceTwo year
Credit card (automatic)25.351847.55
1000177-PXBATMale1
33
YesFiber opticYesNoYesYesYesYesMonth-to-month
Bank transfer (automatic)109.93694.7
Rows: 1-100 | Columns: 21

Data Exploration and Preparation

Let's examine our data.

In [6]:
churn.describe(method = "categorical", unique = True)


Out[6]:
dtype
count
top
top_percent
unique
"customerID"varchar(20)70430002-ORFBO0.0147043.0
"gender"varchar(20)7043Male50.4762.0
"SeniorCitizen"int7043083.7852.0
"Partner"boolean7043051.6972.0
"Dependents"boolean7043070.0412.0
"tenure"int704318.70473.0
"PhoneService"boolean7043190.3172.0
"MultipleLines"varchar(100)7043No48.1333.0
"InternetService"varchar(22)7043Fiber optic43.9593.0
"OnlineSecurity"varchar(38)7043No49.6663.0
"OnlineBackup"varchar(38)7043No43.8453.0
"DeviceProtection"varchar(38)7043No43.9443.0
"TechSupport"varchar(38)7043No49.3113.0
"StreamingTV"varchar(38)7043No39.8983.0
"StreamingMovies"varchar(38)7043No39.5433.0
"Contract"varchar(28)7043Month-to-month55.0193.0
"PaperlessBilling"boolean7043159.2222.0
"PaymentMethod"varchar(50)7043Electronic check33.5794.0
"MonthlyCharges"numeric(8,3)704320.050.8661585.0
"TotalCharges"numeric(9,3)7032[null]0.1566530.0
"Churn"boolean7043073.4632.0
Rows: 1-21 | Columns: 6

Several variables are categorical, and since they all have low cardinalities, we can compute their dummies. We can also convert all booleans to numeric.

In [7]:
for column in ["DeviceProtection", 
               "MultipleLines",
               "PaperlessBilling",
               "Churn",
               "TechSupport",
               "Partner",
               "StreamingTV",
               "OnlineBackup",
               "Dependents",
               "OnlineSecurity",
               "PhoneService",
               "StreamingMovies"]:
    churn[column].decode("Yes", 1, 0)
churn.one_hot_encode().drop(["customerID", 
                             "gender", 
                             "Contract", 
                             "PaymentMethod", 
                             "InternetService"])
Out[7]:
123
SeniorCitizen
Int
123
Partner
Integer
123
Dependents
Integer
123
tenure
Int
123
PhoneService
Integer
123
MultipleLines
Integer
123
OnlineSecurity
Integer
123
OnlineBackup
Integer
123
DeviceProtection
Integer
123
TechSupport
Integer
123
StreamingTV
Integer
123
StreamingMovies
Integer
123
PaperlessBilling
Integer
123
MonthlyCharges
Numeric(8,3)
123
TotalCharges
Numeric(9,3)
123
Churn
Integer
123
gender_Female
Bool
123
InternetService_DSL
Bool
123
InternetService_Fiber_optic
Bool
123
Contract_Month-to-month
Bool
123
Contract_One_year
Bool
123
Bool
123
Bool
123
PaymentMethod_Electronic_check
Bool
1011910010110165.6593.30110010
2000911000001059.9542.40010100
3000410001000173.9280.851001101
41101310011011198.01237.851001101
5110310000110183.9267.41101100
6001910000111169.4571.450110100
711071101111111109.77904.250101000
80106311100100184.655377.80001000
9100710100000148.2340.350110101
100116511111111190.455957.90110000
110005400100110045.22460.550010000
1201172111111111116.88456.750101000
13010510000000168.95351.50101101
1400072111110101101.37261.250101000
150005600111100045.052560.10110000
160117111011001195.756849.40101000
170113400101111061.251993.20110010
18100111000000172.172.10101101
191004510101001062.72791.51010010
20100100000000125.125.11010101
211105011000000025.21306.30100011
220101311011010094.11215.61101101
230112311000010183.751849.950101101
24000310000000019.8557.20100100
25011410000000020.3576.351100100
26011100100000030.530.51110100
2701155100111111103.75656.750101010
280115410000000020.41090.60000000
290002610000000119.6471.850000010
300116910000000019.71396.90100000
310113710000011091.23247.550001010
320104910000000020.45900.90100010
3301066111111110115.87942.150001010
340006710000000020.551343.40100011
350112000101100139.4825.40010000
360014311000000125.11070.150100001
370105511100010189.84959.60101100
380105911110010194.755597.650101101
390111210000000020.3224.50100000
400112711000000175.751929.00001100
41100210100000149.2591.11010101
420002710011111078.22078.950110010
430112511000000025.5630.60000000
440112510111000161.61611.00010010
450012900111100145.01242.450010100
460107211011111185.156316.20010000
470001410010000051.45727.850110010
480003510001111199.253532.00101011
49000110000000144.344.30010100
500002910000111194.22607.60001101
510006411111110081.255567.550010011
520113911000111199.953767.40101100
531004010000011191.553673.60101101
5400040110110111104.54036.851001100
551001110010011195.01120.31101101
56010611000000050.35314.550110101
570003011100001164.51888.450010100
580002710000000119.4529.80000101
5911070110110111104.87308.950001011
6001057110111111109.46252.70101010
610105810001000050.32878.550010010
620001611011001171.41212.10010100
6301069111111111116.08182.850101001
64000110000000119.8519.851000101
65001111001011199.7599.751001101
661113210010011193.952861.450001100
670111611001010190.81442.20001100
680104911101111084.354059.351010011
690107100011111058.254145.90110000
7000033110110110107.553645.50101101
710101010000000119.95187.750100100
7201021110111111111.22317.11001101
730113700111000040.21448.81010100
741002610100010185.82193.650101100
750005000100100135.41748.90010010
76000711000000173.85511.251101101
770116111111111088.15526.750110000
7800015100011111101.351553.951001101
790012600100101045.81147.00110100
800107210001011194.656747.350001101
810114410000000120.5865.050000010
820006611010001089.45976.90001100
83000210110100186.25181.651101101
841004410001111074.853268.050110010
850001211010010189.751052.41101100
8611069110111111109.957634.250001001
87000111010000180.280.21101100
88000310000000019.8563.751100100
89010210110010090.35190.50101101
901002711011000186.452401.050101100
910002610000000120.3511.250000101
9211039110001111101.253949.150101101
930002511000011194.72362.11001100
94000110000000070.970.91101100
950102210100100154.21152.71010101
9600072111111111114.98496.70101001
970002410000000119.55470.20100000
980101911000010186.851564.40101101
990117111000000025.351847.550000000
10011033111011111109.93694.70001100
Rows: 1-100 of 7043 | Columns: 24

Let's compute the correlations between the different variables and the response column.

In [8]:
%matplotlib inline
churn.corr(focus = "Churn")
Out[8]:
"Churn"
1.0
0.405
-0.352
0.308
0.302
-0.199
0.193
0.192
-0.178
-0.171
-0.165
-0.164
0.151
-0.15
-0.134
-0.124
-0.118
-0.082
-0.066
0.063
0.061
0.04
0.012
0.009
Rows: 1-24 | Columns: 2

Many features have a strong correlation with the 'Churn' variable. For example, the customers that have a 'Month to Month' contract are more likely to churn. Having this type of contract gives customers a lot of flexibility and allows them to leave at any time. New customers are also likely to churn.

In [9]:
# No lock-in = Churn
churn.hist(["Contract_Month-to-month", "tenure"], method = "avg", of = "Churn")
Out[9]:
<AxesSubplot:xlabel='"Contract_Month-to-month"', ylabel='avg("Churn")'>

The following scatter plot shows that providing better tariff plans can prevent churning. Indeed, customers having high total charges are more likely to churn even if they've been with the company for a long time.

In [10]:
churn.scatter(["TotalCharges", "tenure"], catcol = "Churn")
Out[10]:
<AxesSubplot:xlabel='"TotalCharges"', ylabel='"tenure"'>

Let's move on to machine learning.

Machine Learning

Logistic regression is a very powerful algorithm and we can use it to detect churns. Let's split our vDataFrame into training and testing set to evaluate our model.

In [11]:
train, test = churn.train_test_split(test_size = 0.2, 
                                     random_state = 0)

Let's train and evaluate our model.

In [12]:
from verticapy.learn.linear_model import LogisticRegression
model = LogisticRegression("churn_model", 
                           penalty = 'L2', 
                           tol = 1e-6, 
                           max_iter = 1000, 
                           solver = "BFGS")
model.fit(train, 
          churn.get_columns(exclude_columns = ["churn"]), 
          'churn',
          test)
model.classification_report()
Out[12]:
value
auc0.8554368006422792
prc_auc0.6822415600545241
accuracy0.8031161473087819
log_loss0.1717601946823
precision0.6761006289308176
recall0.5512820512820513
f1_score0.6073446327683616
mcc0.48220268504473107
informedness0.45049927241708065
markedness0.5161371920021156
csi0.43610547667342797
cutoff0.5
Rows: 1-12 | Columns: 2

The model is excellent! Let's run some machine learning on the entire dataset and compute the importance of each feature.

In [13]:
model.fit(churn, 
          churn.get_columns(exclude_columns = ["churn"]), 
          'churn')
model.features_importance()
Out[13]:
importance
sign
28.58-1
18.431
8.661
7.01
5.791
5.26-1
4.311
3.581
2.93-1
2.81-1
2.41
2.291
1.451
1.4-1
1.341
0.97-1
0.731
0.681
0.63-1
0.391
0.21-1
0.171
0.0-1
Rows: 1-23 | Columns: 3

Based on our model, most churning customers are at least one of the following:

  • Paying higher bills
  • New Telco customers
  • Have a monthly contract

Notice that customers have a 'Fiber Optic' option are also likely to churn. Let's check if this relationship is causal by computing some aggregations.

In [15]:
import verticapy.stats as st
# Is Fiber optic a Bad Option? - VerticaPy
churn.groupby(["InternetService_Fiber_optic"], 
              [st.avg(churn["tenure"])._as("tenure"),
               st.avg(churn["totalcharges"])._as("totalcharges"),
               st.avg(churn["contract_month-to-month"])._as("contract_month_to_month"),
               st.avg(churn["monthlycharges"])._as("monthlycharges")])
Out[15]:
123
InternetService_Fiber_optic
Integer
123
tenure
Float
123
totalcharges
Float
123
contract_month_to_month
Float
123
monthlycharges
Float
1031.94223460856351558.065485264230.44261464403344343.7882442361287
2132.91795865633073205.304570413440.6873385012919991.5001291989664
Rows: 1-2 | Columns: 5

It seems like the 'Fiber Optic' option in and of itself doesn't lead to churning, but customers that have this option tend to churn because their contract puts them into one of the three categories we listed before: they're paying more.

To retain these customers, we'll need to make some changes to what types of contracts we offer.

We'll use a lift chart to help us identify which of our customers are likely to churn.

In [16]:
model.lift_chart()
Out[16]:
decision_boundary
positive_prediction_ratio
lift
10.00.03.76243980738363
20.0010.03.76243980738363
30.0020.03.76243980738363
40.0030.03.76243980738363
50.0040.03.76243980738363
60.0050.03.76243980738363
70.0060.03.76243980738363
80.0070.03.76243980738363
90.0080.03.76243980738363
100.0090.03.76243980738363
110.010.03.76243980738363
120.0110.03.76243980738363
130.0120.03.76243980738363
140.0130.03.76243980738363
150.0140.03.76243980738363
160.0150.03.76243980738363
170.0160.03.76243980738363
180.0170.03.76243980738363
190.0180.03.76243980738363
200.0190.03.76243980738363
210.020.03.76243980738363
220.0210.03.76243980738363
230.0220.03.76243980738363
240.0230.03.76243980738363
250.0240.03.76243980738363
260.0250.03.76243980738363
270.0260.03.76243980738363
280.0270.03.76243980738363
290.0280.03.76243980738363
300.0290.03.76243980738363
310.030.03.76243980738363
320.0310.03.76243980738363
330.0320.03.76243980738363
340.0330.03.76243980738363
350.0340.03.76243980738363
360.0350.03.76243980738363
370.0360.03.76243980738363
380.0370.03.76243980738363
390.0380.03.76243980738363
400.0390.03.76243980738363
410.040.03.76243980738363
420.0410.03.76243980738363
430.0420.03.76243980738363
440.0430.03.76243980738363
450.0440.03.76243980738363
460.0450.03.76243980738363
470.0460.03.76243980738363
480.0470.03.76243980738363
490.0480.03.76243980738363
500.0490.03.76243980738363
510.050.03.76243980738363
520.0510.03.76243980738363
530.0520.03.76243980738363
540.0530.03.76243980738363
550.0540.03.76243980738363
560.0550.03.76243980738363
570.0560.03.76243980738363
580.0570.03.76243980738363
590.0580.03.76243980738363
600.0590.03.76243980738363
610.060.03.76243980738363
620.0610.03.76243980738363
630.0620.03.76243980738363
640.0630.03.76243980738363
650.0640.03.76243980738363
660.0650.03.76243980738363
670.0660.03.76243980738363
680.0670.03.76243980738363
690.0680.03.76243980738363
700.0690.03.76243980738363
710.070.03.76243980738363
720.0710.03.76243980738363
730.0720.03.76243980738363
740.0730.03.76243980738363
750.0740.03.76243980738363
760.0750.03.76243980738363
770.0760.03.76243980738363
780.0770.03.76243980738363
790.0780.03.76243980738363
800.0790.03.76243980738363
810.080.03.76243980738363
820.0810.03.76243980738363
830.0820.03.76243980738363
840.0830.03.76243980738363
850.0840.03.76243980738363
860.0850.03.76243980738363
870.0860.03.76243980738363
880.0870.03.76243980738363
890.0880.03.76243980738363
900.0890.03.76243980738363
910.090.03.76243980738363
920.0910.03.76243980738363
930.0920.03.76243980738363
940.0930.03.76243980738363
950.0940.03.76243980738363
960.0950.03.76243980738363
970.0960.03.76243980738363
980.0970.03.76243980738363
990.0980.03.76243980738363
1000.0990.03.76243980738363
1010.10.03.76243980738363
1020.1010.03.76243980738363
1030.1020.03.76243980738363
1040.1030.03.76243980738363
1050.1040.03.76243980738363
1060.1050.03.76243980738363
1070.1060.03.76243980738363
1080.1070.03.76243980738363
1090.1080.03.76243980738363
1100.1090.03.76243980738363
1110.110.03.76243980738363
1120.1110.03.76243980738363
1130.1120.03.76243980738363
1140.1130.03.76243980738363
1150.1140.03.76243980738363
1160.1150.03.76243980738363
1170.1160.03.76243980738363
1180.1170.03.76243980738363
1190.1180.03.76243980738363
1200.1190.03.76243980738363
1210.120.03.76243980738363
1220.1210.03.76243980738363
1230.1220.03.76243980738363
1240.1230.03.76243980738363
1250.1240.03.76243980738363
1260.1250.03.76243980738363
1270.1260.03.76243980738363
1280.1270.03.76243980738363
1290.1280.03.76243980738363
1300.1290.03.76243980738363
1310.130.03.76243980738363
1320.1310.03.76243980738363
1330.1320.03.76243980738363
1340.1330.03.76243980738363
1350.1340.03.76243980738363
1360.1350.03.76243980738363
1370.1360.03.76243980738363
1380.1370.03.76243980738363
1390.1380.03.76243980738363
1400.1390.03.76243980738363
1410.140.03.76243980738363
1420.1410.03.76243980738363
1430.1420.03.76243980738363
1440.1430.03.76243980738363
1450.1440.03.76243980738363
1460.1450.03.76243980738363
1470.1460.03.76243980738363
1480.1470.03.76243980738363
1490.1480.03.76243980738363
1500.1490.03.76243980738363
1510.150.03.76243980738363
1520.1510.03.76243980738363
1530.1520.03.76243980738363
1540.1530.03.76243980738363
1550.1540.0005350454788657043.76243980738363
1560.1550.001070090957731413.76243980738363
1570.1560.002140181915462813.76243980738363
1580.1570.002675227394328523.76243980738363
1590.1580.002675227394328523.76243980738363
1600.1590.003745318352059933.76243980738363
1610.160.003745318352059933.29213483146067
1620.1610.004815409309791333.38619582664526
1630.1620.004815409309791333.38619582664526
1640.1630.005350454788657043.42039982489421
1650.1640.005350454788657043.42039982489421
1660.1650.005350454788657043.42039982489421
1670.1660.005350454788657043.42039982489421
1680.1670.005350454788657043.42039982489421
1690.1680.005350454788657043.42039982489421
1700.1690.005350454788657043.42039982489421
1710.170.005350454788657043.42039982489421
1720.1710.005350454788657043.42039982489421
1730.1720.005350454788657043.42039982489421
1740.1730.005350454788657043.42039982489421
1750.1740.005350454788657043.42039982489421
1760.1750.005350454788657043.42039982489421
1770.1760.005350454788657043.42039982489421
1780.1770.006420545746388443.47302136066181
1790.1780.006420545746388443.47302136066181
1800.1790.006420545746388443.47302136066181
1810.180.006420545746388443.47302136066181
1820.1810.006955591225254153.49369410685623
1830.1820.008560727661851263.541119818714
1840.1830.009630818619582663.38619582664526
1850.1840.01016586409844843.40411220668042
1860.1850.01123595505617983.4352711284807
1870.1860.01177100053504553.44890315676833
1880.1870.01337613697164263.48374056239225
1890.1880.01337613697164263.48374056239225
1900.1890.01391118245050833.49369410685623
1910.190.0144462279293743.50296119997786
1920.1910.01658640984483683.53441315239068
1930.1920.01712145532370253.541119818714
1940.1930.01712145532370253.541119818714
1950.1940.01819154628143393.55341537364009
1960.1950.01819154628143393.55341537364009
1970.1960.01819154628143393.55341537364009
1980.1970.01872659176029963.46540508574808
1990.1980.01926163723916533.47302136066181
2000.1990.02033172819689673.48713933367263
2010.20.02086677367576243.49369410685623
2020.2010.02086677367576243.49369410685623
2030.2020.02140181915462813.49994400686849
2040.2030.02193686463349383.50590982051656
2050.2040.02193686463349383.50590982051656
2060.2050.02300695559122533.51706329820643
2070.2060.02407704654895673.52728731942215
2080.2070.02514713750668813.53669341894061
2090.2080.02568218298555383.541119818714
2100.2090.02675227394328523.42039982489421
2110.210.02782236490101663.43240122778857
2120.2110.0288924558587483.44358897624942
2130.2120.03049759229534513.40411220668042
2140.2130.03156768325307653.26446983287697
2150.2140.03317281968967363.28551081771528
2160.2150.0342429106474053.29857736537743
2170.2160.03584804708400213.3168877249303
2180.2170.03691813804173363.3283121373009
2190.2180.0379882289994653.33916532905297
2200.2190.03852327447833073.30360568453197
2210.220.04066345639379353.32494680652507
2220.2210.04226859283039063.33969376161019
2230.2220.04226859283039063.26629389871765
2240.2230.04387372926698773.24757962321534
2250.2240.04761904761904763.28291316526611
2260.2250.0486891385767793.26078116639914
2270.2260.05296950240770473.23896992113895
2280.2270.05403959336543613.24791812432262
2290.2280.05617977528089893.23816540799411
2300.2290.05671482075976463.21627919018278
2310.230.0577849117174963.17455858747994
2320.2310.0577849117174963.17455858747994
2330.2320.05939004815409313.18802151618002
2340.2330.06099518459069023.17717139290173
2350.2340.06260032102728733.18989461930351
2360.2350.06367041198501873.17539246155072
2370.2360.06367041198501873.17539246155072
2380.2370.06581059390048153.16972668704237
2390.2380.0668806848582133.17773632380374
2400.2390.06741573033707863.1816605082573
2410.240.06741573033707863.1816605082573
2420.2410.06795077581594443.18553237025147
2430.2420.06848582129481013.18935294930533
2440.2430.07062600321027293.20414228757832
2450.2440.072231139646873.2147428733974
2460.2450.07383627608346713.22494840632882
2470.2460.07437132156233283.2084609400388
2480.2470.0775815944355273.22812882882027
2490.2480.07811663991439273.21237550805854
2500.2490.07811663991439273.21237550805854
2510.250.07972177635098983.16725158926644
2520.2510.08293204922418413.16944657687208
2530.2520.08935259497057253.14163723916533
2540.2530.09470304975922953.1561698858147
2550.2540.09630818619582673.14994960618164
2560.2550.09737827715355813.14111947221936
2570.2560.09791332263242373.14395655137536
2580.2570.1021936864633493.15186843513278
2590.2580.1064740502942753.17256576978535
2600.2590.1086142322097383.18239700374532
2610.260.1096843231674693.17407473462405
2620.2610.1118245050829323.17076580541604
2630.2620.1155698234349923.16220621943527
2640.2630.1187800963081863.16386983802714
2650.2640.1241305510968433.18571545734672
2660.2650.1262707330123063.19401364943358
2670.2660.1284109149277693.17952659778898
2680.2670.1289459604066353.18157190729633
2690.2680.1305510968432323.17659277855227
2700.2690.1326912787586943.18459069020867
2710.270.1337613697164263.17773632380374
2720.2710.1348314606741573.17101950321296
2730.2720.1359015516318893.1333105281162
2740.2730.1385767790262173.13335019328733
2750.2740.1385767790262173.11332878630147
2760.2750.1396468699839493.10758477761749
2770.2760.1423220973782773.06996622320259
2780.2770.1428571428571433.06271777003484
2790.2780.1449973247726063.06192548889178
2800.2790.1476725521669343.06322532990525
2810.280.1492776886035313.06935879023401
2820.2810.151952915997863.07049685430158
2830.2820.1546281433921883.0802977459883
2840.2830.1567683253076513.07073778151366
2850.2840.1573033707865173.05568315848284
2860.2850.1621187800963083.07282819848312
2870.2860.1647940074906373.07382350311448
2880.2870.1674692348849653.07478762326652
2890.2880.1680042803638313.06063756351932
2900.2890.1706795077581593.06961201676567
2910.290.1706795077581593.05399058156585
2920.2910.1722846441947573.03635493227451
2930.2920.1749598715890853.03782177040604
2940.2930.1765650080256823.03570938004058
2950.2940.1781701444622793.02631027985205
2960.2950.1803103263777423.03335458155092
2970.2960.1840556447298023.03109904857135
2980.2970.1883360085607283.02369591826264
2990.2980.1915462814339223.02686168773784
3000.2990.1920813269127883.01499082779179
3010.30.1936864633493853.0132814386568
3020.3010.1952915997859823.01160203880488
3030.3020.2027822364901023.0211116249966
3040.3030.2081326912787593.02394439064511
3050.3040.2081326912787592.99302471384914
3060.3050.2102728731942212.96320409679713
3070.3060.2108079186730872.95888479862106
3080.3070.2118780096308192.95620270580142
3090.3080.2134831460674162.94933886669168
3100.3090.2150882825040132.93120310575236
3110.310.216693418940612.92473727829246
3120.3110.2199036918138042.92871735006566
3130.3120.2215088282504012.92242041323982
3140.3130.2225789192081332.90924713730779
3150.3140.2231139646869982.90543962903513
3160.3150.2257891920813272.90265008906013
3170.3160.2273943285179242.90733985116008
3180.3170.2284644194756552.90517504114432
3190.3180.2289994649545212.90148511272107
3200.3190.2300695559122532.90457651198377
3210.320.2300695559122532.8993711777329
3220.3210.2348849652220442.91307067979085
3230.3220.2359550561797752.91094027202839
3240.3230.2391653290529692.91474972946357
3250.3240.2423756019261642.92347381259826
3260.3250.2429106474050292.91492776886035
3270.3260.2439807383627612.90791957994396
3280.3270.2455858747993582.91224261650773
3290.3280.2493311931514182.91245340571557
3300.3290.2514713750668812.90846498268142
3310.330.2541466024612092.89652983550603
3320.3310.2584269662921352.90761348314607
3330.3320.2611021936864632.90977912203361
3340.3330.2669876939539862.91078676571229
3350.3340.2685928303905832.90576120508705
3360.3350.2696629213483152.90838905356035
3370.3360.2723381487426432.91488867877971
3380.3370.273943285179242.90992323471362
3390.3380.2766185125735692.90759548642352
3400.3390.2787586944890322.90835480659773
3410.340.281433921883362.91035785100557
3420.3410.2825040128410922.90009958875702
3430.3420.2835741037988232.89839113068797
3440.3430.2857142857142862.88669950738916
3450.3440.2878544676297492.88757862535291
3460.3450.2899946495452112.88844529122086
3470.3460.292669876939542.88647205419193
3480.3470.2932049224184062.87963270174054
3490.3480.2937399678972712.87285042316219
3500.3490.2948100588550032.87133564247698
3510.350.2953451043338682.86464382575967
3520.3510.2974852862493312.86563908617164
3530.3520.2980203317281972.85904361898046
3540.3530.2990904226859282.85761392979273
3550.3540.3028357410379882.8622861975526
3560.3550.303905831995722.86086453894766
3570.3560.3055109684323172.85685256651071
3580.3570.3065810593900482.85169048892965
3590.3580.3092562867843772.8501837597218
3600.3590.3103263777421082.85256874285295
3610.360.311396468699842.84751621313039
3620.3610.3130016051364372.84738329536795
3630.3620.3140716960941682.83875599863006
3640.3630.3151417870518992.8338581157915
3650.3640.3167469234884972.83019614481716
3660.3650.3183520599250942.83373631062438
3670.3660.3237025147137512.82767215337527
3680.3670.3242375601926162.81834180874472
3690.3680.3263777421080792.81951877457495
3700.3690.3285179240235422.81381003865231
3710.370.3311931514178712.80934890322131
3720.3710.3333333333333332.80718562874251
3730.3720.3344034242910652.80946819547762
3740.3730.3365436062065282.80732460123879
3750.3740.3376136971642592.80626420621639
3760.3750.3408239700374532.80312766936067
3770.3760.3418940609951852.80536643747741
3780.3770.3440342429106472.80330103840982
3790.3780.3456393793472452.78731205913971
3800.3790.349919743178172.79300298981713
3810.380.3525949705724992.79217098318222
3820.3810.3542001070090962.78917710245012
3830.3820.3568753344034242.78220327220053
3840.3830.3595505617977532.77841708852945
3850.3840.3632958801498132.77986575540096
3860.3850.368646334938472.77550431187079
3870.3860.3707865168539332.77379870906048
3880.3870.3729266987693952.76918748230875
3890.3880.3745318352059932.76649985837031
3900.3890.3750668806848582.75886015164845
3910.390.3766720171214552.7533863039481
3920.3910.3772070626003212.7402066778982
3930.3920.3777421080791872.73843557114726
3940.3930.3788121990369182.74054257574857
3950.3940.379882289994652.72863356817403
3960.3950.3820224719101122.7272913933725
3970.3960.3846976993044412.72426406999882
3980.3970.3857677902621722.72088174636268
3990.3980.3863028357410382.71920074167265
4000.3990.3873729266987692.71315380532445
4010.40.3895131086142322.71193681165869
4020.4010.3932584269662922.71649632458445
4030.4020.3959336543606212.70311209462513
4040.4030.3975387907972182.69056090171899
4050.4040.3996789727126812.68181539705684
4060.4050.4012841091492782.67980043260942
4070.4060.4018191546281432.67321882246462
4080.4070.4044943820224722.67331249471995
4090.4080.4055644729802032.66784787090439
4100.4090.40716960941682.66593733093011
4110.410.4077046548956662.66695733323379
4120.4110.4093097913322632.67000598575925
4130.4120.4103798822899952.67202901135485
4140.4130.4135901551631892.67313048815032
4150.4140.4157303370786522.66978605510235
4160.4150.4173354735152492.66791186341748
4170.4160.4194756554307122.66704593941118
4180.4170.4248261102193692.67207263601306
4190.4180.4264312466559662.66311236810369
4200.4190.4291064740502942.6656154819096
4210.420.4301765650080262.66051152606547
4220.4210.4307116104868912.65914314744848
4230.4220.4339218833600862.65796052594784
4240.4230.4376672017121462.66234927546696
4250.4240.4387372926698772.66424925911449
4260.4250.4403424291064742.66021302532365
4270.4260.4430176565008032.64681407010505
4280.4270.4440877474585342.64422103313159
4290.4280.4456928838951312.64036424561968
4300.4290.4478330658105942.64191452917793
4310.430.4499732477260572.64124530718667
4320.4310.452113429641522.64277775331601
4330.4320.4537185660781172.64337113227947
4340.4330.4547886570358482.64522236251124
4350.4340.4553237025147142.63960121688662
4360.4350.4569288389513112.64020016064554
4370.4360.4579989299090422.64204140698965
4380.4370.4585339753879082.64079518012102
4390.4380.4606741573033712.64014724870196
4400.4390.4622792937399682.63431766092338
4410.440.4644194756554312.6358335373761
4420.4410.4660246120920282.63431275902825
4430.4420.4665596575708942.62677943317736
4440.4430.4713750668806852.62863558311259
4450.4440.4745853397538792.63400482174371
4460.4450.4761904761904762.63045673886208
4470.4460.4772605671482082.62605344928497
4480.4470.479400749063672.62141995911021
4490.4480.4815409309791332.62292473016674
4500.4490.4826110219368652.62063375000775
4510.450.4826110219368652.61659268023133
4520.4510.4836811128945962.6143317339545
4530.4520.4836811128945962.60631845660904
4540.4530.4858212948100592.60388364718318
4550.4540.4879614767255222.60344848583753
4560.4550.490636704119852.59410323561713
4570.4560.4927768860353132.59760649370339
4580.4570.4933119315141792.5965340586884
4590.4580.4938469769930442.59352646916735
4600.4590.4970572498662392.59295740434673
4610.460.4997324772605672.59727921662698
4620.4610.5008025682182992.59134927131058
4630.4620.5024077046548962.58633307403604
4640.4630.5024077046548962.58444109665927
4650.4640.5050829320492242.58496592297682
4660.4650.505617977528092.58394303632088
4670.4660.5066880684858212.58377846090812
4680.4670.5082932049224182.58633706006834
4690.4680.5098983413590152.5870166929557
4700.4690.5115034777956132.58397446541577
4710.470.5136436597110752.57995872506306
4720.4710.5147137506688072.57796801617026
4730.4720.516853932584272.5721987642835
4740.4730.5173889780631352.5675930089908
4750.4740.5173889780631352.56397413230442
4760.4750.5189941144997322.56469895513852
4770.4760.5216693418940612.55458134554251
4780.4770.5227394328517922.54917038267254
4790.4780.5232744783306582.54120589200358
4800.4790.5243445692883892.53764006279143
4810.480.5275548421615842.53919620128697
4820.4810.5286249331193152.53566884699524
4830.4820.5296950240770462.5321654719985
4840.4830.5313001605136442.5295211433527
4850.4840.5329052969502412.52179680225713
4860.4850.5350454788657042.51668214540711
4870.4860.5366506153023012.51749641548084
4880.4870.5387907972177632.51578810493713
4890.4880.5398608881754952.51577320453948
4900.4890.5398608881754952.50912211873766
4910.490.5409309791332262.50746647677314
4920.4910.5409309791332262.50416500675763
4930.4920.5409309791332262.50087221910904
4940.4930.5420010700909582.4992469015604
4950.4940.5430711610486892.49436734454238
4960.4950.5430711610486892.49436734454238
4970.4960.544141252006422.49276956619489
4980.4970.5462814339218832.49283000865586
4990.4980.5489566613162122.49210022103009
5000.4990.5500267522739432.48892414542495
5010.50.5532370251471372.48585479925538
5020.5010.5559122525414662.48517162102453
5030.5020.5580524344569292.48368653107666
5040.5030.559122525414662.48373316406563
5050.5040.5601926163723922.47753111844696
5060.5050.562867843766722.47845126948502
5070.5060.562867843766722.47690029872815
5080.5070.562867843766722.47225901147256
5090.5080.5639379347244522.47078601681143
5100.5090.5644729802033172.46851616715779
5110.510.566613162118782.46866403718666
5120.5110.5676832530765112.46264567281556
5130.5120.5687533440342432.45818900752846
5140.5130.5698234349919742.45526862430365
5150.5140.5719636169074372.45396470658517
5160.5150.5757089352594972.45356680772411
5170.5160.5789192081326912.45682551091677
5180.5170.5789192081326912.45386369595484
5190.5180.5794542536115572.45169814163446
5200.5190.5805243445692882.44739040228491
5210.520.5821294810058852.44828619045059
5220.5210.5826645264847512.44614743297956
5230.5220.5848047084002142.44636925013106
5240.5230.5848047084002142.44056184538297
5250.5240.5864098448368112.43569641399436
5260.5250.5880149812734082.42944850077239
5270.5260.5880149812734082.4265970353959
5280.5270.5885500267522742.42595767181828
5290.5280.589085072231142.42106734537076
5300.5290.5901551631888712.41839808131943
5310.530.5906902086677372.41496136473926
5320.5310.5917602996254682.40674287273932
5330.5320.5933654360620652.40770095002218
5340.5330.5939004815409312.40709405544428
5350.5340.5949705724986622.40588445417515
5360.5350.5949705724986622.4031206581336
5370.5360.5955056179775282.40252180471485
5380.5370.5960406634563942.3991745537638
5390.5380.5971107544141252.39799133354662
5400.5390.5981808453718572.39408520469829
5410.540.5987158908507222.39078372769011
5420.5410.6003210272873192.39040626494022
5430.5420.6003210272873192.38905346003646
5440.5430.6003210272873192.38770218545499
5450.5440.6029962546816482.38619564598838
5460.5450.6029962546816482.38083641938313
5470.5460.6046013911182452.37517149851592
5480.5470.6051364365971112.36933152681007
5490.5480.6062065275548422.3656183694593
5500.5490.6062065275548422.35907266284762
5510.550.6062065275548422.35256308044462
5520.5510.6072766185125742.35023069971404
5530.5520.6078116639914392.34455930948316
5540.5530.6088817549491712.34482831369253
5550.5540.6094168004280362.33792631784504
5560.5550.6094168004280362.33029849951602
5570.5560.6131621187800962.33446454751578
5580.5570.6147672552166932.32922593679083
5590.5580.6158373461744252.32951491032736
5600.5590.616372391653292.32528468782507
5610.560.6185125735687532.32711632816237
5620.5610.6206527554842162.32397772980032
5630.5620.6227929373996792.32703503495991
5640.5630.623863028357412.32239534960789
5650.5640.6254681647940072.32222393602506
5660.5650.6270733012306052.31352542195887
5670.5660.6281433921883362.31140990783275
5680.5670.6297485286249332.30645398608882
5690.5680.6308186195826642.30437222488587
5700.5690.6324237560192622.30186534799557
5710.570.6345639379347242.30369313967836
5720.5710.6345639379347242.2989457040479
5730.5720.6356340288924562.29219409803679
5740.5730.6367041198501872.29370049732916
5750.5740.6383092562867842.29243651185325
5760.5750.6383092562867842.29009729092279
5770.5760.6404494382022472.29076319910387
5780.5770.642589620117712.28794440945202
5790.5780.6436597110754412.28827860883848
5800.5790.6436597110754412.28596721630429
5810.580.6441947565543072.2844062168885
5820.5810.646334938469772.28278618147635
5830.5820.6484751203852332.28117911283089
5840.5830.6495452113429642.27924247812561
5850.5840.6522204387372932.28066341382429
5860.5850.6532905296950242.2798704738538
5870.5860.6543606206527552.27908067579504
5880.5870.6554307116104872.27829400101085
5890.5880.6559657570893532.2790272746306
5900.5890.6559657570893532.27565426929074
5910.590.6581059390048152.27410366736209
5920.5910.6607811663991442.27440683412569
5930.5920.6629213483146072.27065899724711
5940.5930.6634563937934722.26807261115979
5950.5940.6645264847512042.26732180532288
5960.5950.6655965757089352.26219193832056
5970.5960.6666666666666672.25818882466281
5980.5970.6682718031032642.25385482945907
5990.5980.6688068485821292.24703762982778
6000.5990.6704119850187272.24492241840556
6010.60.6704119850187272.24171996131797
6020.6010.6709470304975922.2381876273525
6030.6020.6720171214553242.23645262568568
6040.6030.6720171214553242.23222692398386
6050.6040.6725521669341892.2276904559026
6060.6050.6725521669341892.22245622080884
6070.6060.6730872124130552.22109304443388
6080.6070.6741573033707862.21734057872
6090.6080.6746923488496522.21392281713054
6100.6090.6752273943285182.21258109828431
6110.610.6768325307651152.21268542833114
6120.6110.6773675762439812.21135041603885
6130.6120.6789727126805782.20941051160103
6140.6130.6800428036383092.20778439297534
6150.6140.6800428036383092.20269967534988
6160.6150.6800428036383092.19662884482526
6170.6160.6805778491171752.19533185091375
6180.6170.6811128945960412.19504393895479
6190.6180.6827180310326382.19217954074041
6200.6190.6853932584269662.19375757544762
6210.620.6875334403424292.19162971554305
6220.6210.6880684858212952.18639746601688
6230.6220.6891385767790262.18289300536492
6240.6230.6902086677367582.18333214193652
6250.6240.6907437132156232.18207987031997
6260.6250.6907437132156232.17718950754472
6270.6260.6918138041733552.17471375545241
6280.6270.692348849652222.17154197625085
6290.6280.6928838951310862.16934975537035
6300.6290.6939539860888182.16594959173394
6310.630.6955591225254152.1623217283814
6320.6310.696094168004282.16016513212979
6330.6320.696094168004282.15826022460586
6340.6330.6966292134831462.15801613621739
6350.6340.6971642589620122.15398025879651
6360.6350.6982343499197432.15539242696911
6370.6360.6987693953986092.15326309747722
6380.6370.7003745318352062.1516093088096
6390.6380.7014446227929372.15207617254796
6400.6390.7030497592295342.14949822039221
6410.640.7030497592295342.14576645264847
6420.6410.70358480470842.14274939225183
6430.6420.7041198501872662.13882107408935
6440.6430.7051899411449972.13561398196883
6450.6440.7067950775815942.13495832712791
6460.6450.7094703049759232.13204922418406
6470.6460.7105403959336542.13071218089785
6480.6470.7121455323702512.13007545028822
6490.6480.7121455323702512.12375207108889
6500.6490.7137506688068492.12223877507389
6510.650.714820759764582.12093653276984
6520.6510.7153558052434462.11984071743443
6530.6520.7164258962011772.12033118774692
6540.6530.7169609416800432.1183484629807
6550.6540.7180310326377742.11706256667037
6560.6550.718566078116642.11775216316689
6570.6560.7201712145532372.11627412483843
6580.6570.7212413055109682.11411790760864
6590.6580.7217763509898342.11128589856927
6600.6590.7249866238630282.10927014439587
6610.660.726056714820762.10802263361667
6620.6610.7281968967362232.10467759056684
6630.6620.7292669876939542.10344768558814
6640.6630.729802033172822.10154295547554
6650.6640.7319422150882822.09996640412109
6660.6650.7324772605671482.09893239458361
6670.6660.733547351524882.09943222463287
6680.6670.7340823970037452.09840138850827
6690.6680.7340823970037452.09329578902285
6700.6690.7356875334403422.08940013536046
6710.670.7367576243980742.0873809890279
6720.6710.737292669876942.08553582243549
6730.6720.7388978063135372.0867186240951
6740.6730.7399678972712682.08471724904309
6750.6740.7410379882289992.08355822999853
6760.6750.7415730337078652.08090246330156
6770.6760.7421080791867312.07577725252231
6780.6770.7426431246655972.07315063622409
6790.6780.7431781701444622.07217640462167
6800.6790.7442482611021942.07105412428596
6810.680.7453183520599252.06830254604791
6820.6810.7479935794542542.0700082057152
6830.6820.7485286249331192.06904610476796
6840.6830.7501337613697162.06860416076543
6850.6840.7528089887640452.0694889792763
6860.6850.7544141252006422.06743574762701
6870.6860.7576243980738362.0689766086428
6880.6870.7586944890315682.06868540010469
6890.6880.7597645799892992.06839509349003
6900.6890.7619047619047622.06861555432984
6910.690.7635098983413592.06818243649323
6920.6910.7640449438202252.06485935624282
6930.6920.7656500802568222.0612754074908
6940.6930.7656500802568222.05969830312394
6950.6940.7661851257356882.05956185174822
6960.6950.7667201712145532.05863926841571
6970.6960.7672552166934192.05536711763357
6980.6970.768325307651152.05198008484728
6990.6980.7693953986088822.04938956174911
7000.6990.7699304440877472.04307580483964
7010.70.7710005350454792.04206243406396
7020.7010.7726056714820762.04016638447689
7030.7020.7742108079186732.0405736136747
7040.7030.7752808988764052.03728523202499
7050.7040.7763509898341362.03325890521923
7060.7050.7768860353130022.02861589317528
7070.7060.7774210807918672.02475001486237
7080.7070.7774210807918672.02250278954066
7090.7080.7774210807918672.02100740855024
7100.7090.7779561262707332.0179223459741
7110.710.7806313536650622.01741994817079
7120.7110.7811663991439272.01362247755869
7130.7120.7822364901016592.00901643476803
7140.7130.783306581059392.00590381573548
7150.7140.7843766720171212.00353678082978
7160.7150.7865168539325842.0024571024091
7170.7160.7875869448903162.00083504207684
7180.7170.7886570358480472.00066243725955
7190.7180.7891920813269131.99697686789883
7200.7190.7897271268057791.9968936194528
7210.720.7902621722846441.99537651544187
7220.7210.790797217763511.9888719725726
7230.7220.7918673087212411.98375878693544
7240.7230.7924023542001071.98156947181193
7250.7240.7934724451578381.97931828107482
7260.7250.7940074906367041.9785473685887
7270.7260.7966827180310331.97890246315585
7280.7270.7988228999464951.97862720409431
7290.7280.8009630818619581.97835349197516
7300.7290.8009630818619581.97557782941189
7310.730.8025682182985551.97261786475898
7320.7310.8025682182985551.96780324653955
7330.7320.8036383092562871.96221687176743
7340.7330.8068485821294811.96052495837405
7350.7340.809523809523811.95822890559733
7360.7350.8111289459604071.95605581206913
7370.7360.8121990369181381.95394581854545
7380.7370.8127340823970041.95122774578891
7390.7380.8148742643124671.94772121911804
7400.7390.8154093097913321.94371466659412
7410.740.8159443552701981.93907425017237
7420.7410.8175494917067951.93765016032429
7430.7420.8180845371856611.93695975269009
7440.7430.8180845371856611.93110791053695
7450.7440.8186195826645271.9291330111585
7460.7450.8196896736222581.92777852338185
7470.7460.8207597645799891.92514431772064
7480.7470.8218298555377211.92380410923477
7490.7480.8228999464954521.92246924377276
7500.7490.8228999464954521.92119270377026
7510.750.8228999464954521.91673813307586
7520.7510.8239700374531841.91542390194076
7530.7520.8245050829320491.90846601157938
7540.7530.8255751738897811.90654995822428
7550.7540.8271803103263781.90650014494103
7560.7550.8282504012841091.90148769893237
7570.7560.8287854467629751.89961514394956
7580.7570.8303905831995721.89772719566441
7590.7580.8309256286784381.89525430453025
7600.7590.8314606741573031.89279101996574
7610.760.8325307651150351.89216429873592
7620.7610.8336008560727661.88910126326255
7630.7620.8341359015516321.88605905456948
7640.7630.8346709470304981.88182305210595
7650.7640.836811128945961.88001784624537
7660.7650.836811128945961.87941739340402
7670.7660.836811128945961.87582271557156
7680.7670.8378812199036921.87165843022959
7690.7680.8378812199036921.8686903705559
7700.7690.8389513108614231.86870624579586
7710.770.8389513108614231.86339406758608
7720.7710.840556447298021.86166706689754
7730.7720.8410914927768861.85933837699059
7740.7730.8410914927768861.85293088258367
7750.7740.8416265382557521.85063096216837
7760.7750.8421615837346171.84891672083104
7770.7760.8432316746923491.84780465454553
7780.7770.8432316746923491.84435618551683
7790.7780.8432316746923491.8426367732867
7800.7790.844301765650081.83982956803575
7810.780.8448368111289461.83417488603234
7820.7810.8448368111289461.83021948732555
7830.7820.8459069020866771.82971926652523
7840.7830.8459069020866771.82578800966038
7850.7840.8469769930444091.82361978416665
7860.7850.8469769930444091.81916377980705
7870.7860.8475120385232751.81532277030023
7880.7870.8496522204387371.81493147452163
7890.7880.8496522204387371.8127288877807
7900.7890.8507223113964691.80952186743496
7910.790.8512573568753341.80519955776458
7920.7910.8523274478330661.8036613340843
7930.7920.8539325842696631.80109596058316
7940.7930.8539325842696631.79839890164249
7950.7940.8544676297485291.79308157934696
7960.7950.8566078116639911.78903063012212
7970.7960.8582129481005891.78337867938633
7980.7970.859283039058321.77667695697092
7990.7980.8603531300160511.77471493407828
8000.7990.8614232209737831.76965471512931
8010.80.866773675762441.76415412097293
8020.8010.8694489031567681.75840226833431
8030.8020.8721241305510971.75774631299378
8040.8030.8731942215088281.75839111272912
8050.8040.8737292669876941.75244272831074
8060.8050.8753344034242911.75066880684858
8070.8060.8774745853397541.75046844939267
8080.8070.8790797217763511.7501949613622
8090.8080.8801498127340821.74639206635047
8100.8090.8806848582129481.7400887673373
8110.810.8822899946495451.73642967880649
8120.8110.8833600856072771.7341675382441
8130.8120.8849652220438741.73199984453452
8140.8130.8860353130016051.73024168870516
8150.8140.8871054039593371.72753397968487
8160.8150.8876404494382021.72475480531899
8170.8160.8892455858747991.72548977921401
8180.8170.8913857677902621.72583279710934
8190.8180.8929909042268591.72561473990747
8200.8190.8929909042268591.72182945942508
8210.820.8945960406634561.72114893514239
8220.8210.8967362225789191.71915188581651
8230.8220.8983413590155161.71754661136409
8240.8230.8999464954521131.7150199880811
8250.8240.9004815409309791.71325384086219
8260.8250.9004815409309791.71047709233567
8270.8260.9010165864098451.70734266656805
8280.8270.9015516318887111.70559889035281
8290.8280.9020866773675761.70248886614299
8300.8290.9026217228464421.69802995052332
8310.830.9042268592830391.69605848879123
8320.8310.9047619047619051.69209726443769
8330.8320.9052969502407711.68950322560857
8340.8330.9069020866773681.68936039033517
8350.8340.9079721776350991.6882232557192
8360.8350.909042268592831.68442298623051
8370.8360.9106474050294281.68340498216796
8380.8370.9111824505082931.68085912696073
8390.8380.9111824505082931.67909722011906
8400.8390.9111824505082931.67733900313464
8410.840.9111824505082931.67339644606276
8420.8410.9117174959871591.67045269197022
8430.8420.912787586944891.66850073080231
8440.8430.9149277688603531.66850935441546
8450.8440.9154628143392191.66732310552535
8460.8450.9154628143392191.66473610303424
8470.8460.9154628143392191.6621571160427
8480.8470.9159978598180851.65970032214398
8490.8480.9181380417335471.66101021596869
8500.8490.9186730872124131.66112346342959
8510.850.9186730872124131.65856460828695
8520.8510.9192081326912791.65570481277794
8530.8520.920278223649011.65466542283299
8540.8530.9208132691278761.65140497539077
8550.8540.9208132691278761.64804248116753
8560.8550.9208132691278761.64469365214814
8570.8560.9208132691278761.64135840519828
8580.8570.9208132691278761.63762238454912
8590.8580.9213483146067421.63320427232534
8600.8590.9213483146067421.62705207139995
8610.860.9224184055644731.62567574634821
8620.8610.9224184055644731.62080115640414
8630.8620.9229534510433391.61769906972501
8640.8630.9245585874799361.61527850612644
8650.8640.9250936329588021.61260744347206
8660.8650.9256286784376671.60875453948929
8670.8660.9256286784376671.60637237580792
8680.8670.9261637239165331.60216071502609
8690.8680.9261637239165331.59979938751684
8700.8690.9266987693953991.59954485674729
8710.870.9266987693953991.59601904148627
8720.8710.9272338148742641.59303889230291
8730.8720.9272338148742641.59070704713243
8740.8730.9272338148742641.5860637767443
8750.8740.9272338148742641.58259907431938
8760.8750.9283039058319961.5802065034642
8770.8760.9288389513108611.57653765523002
8780.8770.9288389513108611.57463729643635
8790.8780.9309791332263241.57295657492732
8800.8790.9331193151417871.57053495071255
8810.880.9331193151417871.56603699858641
8820.8810.9331193151417871.56193644943515
8830.8820.9331193151417871.56045065970917
8840.8830.9341894060995191.55816411377889
8850.8840.935259497057251.55736319756253
8860.8850.935259497057251.55368409716669
8870.8860.935259497057251.54965711199495
8880.8870.9363295880149811.54778318357342
8890.8880.9368646334938471.54539810056972
8900.8890.9373996789727131.54157964044343
8910.890.9379347244515781.53850174535654
8920.8910.9379347244515781.53635149833298
8930.8920.939004815409311.53381692496127
8940.8930.9400749063670411.53058734465687
8950.8940.9411449973247731.52596993801886
8960.8950.942750133761371.52295404103146
8970.8960.9432851792402351.52032578052197
8980.8970.9438202247191011.51701573033708
8990.8980.9448903156768331.51630960744854
9000.8990.9454253611556981.51302483833566
9010.90.9454253611556981.50856163822257
9020.9010.9459604066345641.50565721581128
9030.9020.946495452113431.50141123827242
9040.9030.9470304975922951.49887878889692
9050.9040.9481005885500271.49653049128705
9060.9050.9497057249866241.49436801479211
9070.9060.9507758159443551.49005026470263
9080.9070.9513108614232211.4872427695705
9090.9080.9513108614232211.48295676735271
9100.9090.9523809523809521.48068601749787
9110.910.9534510433386841.4777755646369
9120.9110.9534510433386841.47484992009627
9130.9120.953986088817551.47050201152236
9140.9130.9545211342964151.46778758284986
9150.9140.9561262707330121.46704777128399
9160.9150.9561262707330121.46353503173586
9170.9160.9577314071696091.46217265636489
9180.9170.9577314071696091.45805742697915
9190.9180.9593365436062071.45703122562394
9200.9190.9593365436062071.45389107212044
9210.920.9593365436062071.45170100594767
9220.9210.9604066345639381.44926597730764
9230.9220.9609416800428041.44696828566617
9240.9230.9614767255216691.4428306303603
9250.9240.9625468164794011.43738144265941
9260.9250.9625468164794011.43190802062262
9270.9260.9625468164794011.42587512396949
9280.9270.9636169074371321.42416017089069
9290.9280.9636169074371321.41998199771541
9300.9290.9646869983948641.41444515694593
9310.930.9652220438737291.40789077214687
9320.9310.9662921348314611.40391865539976
9330.9320.9673622257891921.3999776027474
9340.9330.9684323167469241.39721297730085
9350.9340.9684323167469241.393781426804
9360.9350.9689673622257891.38858334851676
9370.9360.9700374531835211.38672562935282
9380.9370.9700374531835211.38138990902927
9390.9380.9711075441412521.37872567139134
9400.9390.9721776350989831.37718636785174
9410.940.9727126805778491.37379304475265
9420.9410.9732477260567151.37042010605343
9430.9420.9737827715355811.36788662593652
9440.9430.9737827715355811.36298575824805
9450.9440.9737827715355811.35811988287152
9460.9450.9737827715355811.352753941019
9470.9460.9743178170144461.34923255006806
9480.9470.9753879079721781.34488779781576
9490.9480.9759229534510431.33932283541525
9500.9490.9759229534510431.33385621159723
9510.950.9769930444087751.32989064813831
9520.9510.977528089887641.32421065846463
9530.9520.9791332263242381.3220554622719
9540.9530.9796682718031031.3174655359188
9550.9540.9796682718031031.31545298593077
9560.9550.9796682718031031.30945205993526
9570.9560.9802033172819691.30372417762943
9580.9570.9807383627608351.29854117245984
9590.9580.9828785446762981.29722258373944
9600.9590.9828785446762981.291646781193
9610.960.9839486356340291.28823809454077
9620.9610.9839486356340291.28108254134021
9630.9620.9844836811128951.27540332453682
9640.9630.985018726591761.27164525158679
9650.9640.985018726591761.26583546882187
9660.9650.985018726591761.26145541529653
9670.9660.985018726591761.25551054656394
9680.9670.985018726591761.24962144784291
9690.9680.985018726591761.24334081590258
9700.9690.9855537720706261.23978785781765
9710.970.9860888175494921.23692054316947
9720.9710.9866238630283571.23275390988191
9730.9720.9866238630283571.22686808219547
9740.9730.9876939539860891.22171748186986
9750.9740.9876939539860891.215942556798
9760.9750.9876939539860891.21148855475845
9770.9760.9892990904226861.207350087444
9780.9770.9892990904226861.199026405352
9790.9780.9892990904226861.19367728274748
9800.9790.9898341359015521.1863837810908
9810.980.9898341359015521.18034825227399
9820.9810.9909042268592831.17504865485236
9830.9820.9909042268592831.16913398041518
9840.9830.9914392723381491.16216052060041
9850.9840.9919743178170141.15623461012585
9860.9850.9919743178170141.1471079432477
9870.9860.992509363295881.13836663557277
9880.9870.9935794542536121.12818516426795
9890.9880.9951845906902091.12131678284466
9900.9890.996254681647941.11024768959561
9910.990.996254681647941.09996277615769
9920.9910.996254681647941.09088491456685
9930.9920.9973247726056711.08479316333536
9940.9930.9973247726056711.07514760094482
9950.9940.9978598180845371.06398032460507
9960.9950.9989299090422691.05456765056076
9970.9960.9989299090422691.04267108807856
9980.9970.9994649545211341.02857274406448
9990.9981.01.01136200201352
10000.9991.01.0
10011.01.01.0
Rows: 1-1001 | Columns: 3

By targeting less than 30% of the entire distribution, our predictions will be more than three times more accurate than the other 70%.

Conclusion

We've solved our problem in a Pandas-like way, all without ever loading data into memory!


VerticaPy

Python API for Vertica Data Science at Scale

About the Author


Badr Ouali
Head of Data Science


Badr Ouali works as a Lead Data Scientist for Vertica worldwide. He can embrace data projects end to end through a clear understanding of the “big picture” as well as attention to details, resulting in achieving great business outcomes – a distinctive differentiator in his role. Badr enjoys sharing knowledge and insights related to data analytics with colleagues & peers and has a sweet spot for Python. He loves helping customers finding the best value from their data and empower them to solve their use-cases.