Imports
Data Collection
## Rows: 381,109
## Columns: 12
## $ id <dbl> 1, 2, 3, 4, 5, 6, 7…
## $ Gender <chr> "Male", "Male", "Ma…
## $ Age <dbl> 44, 76, 47, 21, 29,…
## $ Driving_License <dbl> 1, 1, 1, 1, 1, 1, 1…
## $ Region_Code <dbl> 28, 3, 28, 11, 41, …
## $ Previously_Insured <dbl> 0, 0, 0, 1, 1, 0, 0…
## $ Vehicle_Age <chr> "> 2 Years", "1-2 Y…
## $ Vehicle_Damage <chr> "Yes", "No", "Yes",…
## $ Annual_Premium <dbl> 40454, 33536, 38294…
## $ Policy_Sales_Channel <dbl> 26, 26, 26, 152, 15…
## $ Vintage <dbl> 217, 183, 27, 203, …
## $ Response <dbl> 1, 0, 1, 0, 0, 0, 0…
Data Cleaning
## Rows: 381,109
## Columns: 12
## $ id <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15…
## $ gender <fct> male, male, male, male, female, female, male, fem…
## $ age <dbl> 44, 76, 47, 21, 29, 24, 23, 56, 24, 32, 47, 24, 4…
## $ driving_license <fct> yes, yes, yes, yes, yes, yes, yes, yes, yes, yes,…
## $ region_code <dbl> 28, 3, 28, 11, 41, 33, 11, 28, 3, 6, 35, 50, 15, …
## $ previously_insured <fct> no, no, no, yes, yes, no, no, no, yes, yes, no, y…
## $ vehicle_age <fct> over_2_years, between_1_2_years, over_2_years, be…
## $ vehicle_damage <fct> yes, no, yes, no, no, yes, yes, yes, no, no, yes,…
## $ health_annual_paid <dbl> 40454, 33536, 38294, 28619, 27496, 2630, 23367, 3…
## $ policy_sales_channel <dbl> 26, 26, 26, 152, 152, 160, 152, 26, 152, 152, 124…
## $ days_associated <dbl> 217, 183, 27, 203, 39, 176, 249, 72, 28, 80, 46, …
## $ response <fct> yes, no, yes, no, no, no, no, yes, no, no, yes, n…
| Characteristic |
N = 381,109 |
| gender |
|
| female |
175,020 (45.92%) |
| male |
206,089 (54.08%) |
| age |
36 (25, 49) |
| driving_license |
|
| yes |
380,297 (99.79%) |
| no |
812 (0.21%) |
| region_code |
28 (15, 35) |
| previously_insured |
|
| yes |
174,628 (45.82%) |
| no |
206,481 (54.18%) |
| vehicle_age |
|
| below_1_year |
164,786 (43.24%) |
| between_1_2_years |
200,316 (52.56%) |
| over_2_years |
16,007 (4.20%) |
| vehicle_damage |
|
| yes |
192,413 (50.49%) |
| no |
188,696 (49.51%) |
| health_annual_paid |
31,669 (24,405, 39,400) |
| policy_sales_channel |
133 (29, 152) |
| days_associated |
154 (82, 227) |
| response |
|
| yes |
46,710 (12.26%) |
| no |
334,399 (87.74%) |
Column Description
|
variables
|
description
|
|
id
|
Unique ID for the customer
|
|
gender
|
Gender of the customer
|
|
age
|
Age of the customer
|
|
driving_license
|
Customer has DL (yes/no)
|
|
region_code
|
Unique code for the region of the customer
|
|
previously_insured
|
Customer already has Vehicle Insurance (yes/no)
|
|
vehicle_age
|
Age of the Vehicle
|
|
vehicle_damage
|
Customer got his/her vehicle damaged in the past (yes/no)
|
|
health_annual_paid
|
The amount customer needs to pay as premium in the year
|
|
policy_sales_channel
|
Anonymized Code for the channel of outreaching to the customer ie.
Different Agents, Over Mail, Over Phone, In Person, etc.
|
|
days_associated
|
Number of Days, Customer has been associated with the company
|
|
response
|
Customer is interested in car insurance (yes/no)
|
Descriptive
Statistics
## Rows: 381,109
## Columns: 12
## $ id <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15…
## $ gender <fct> male, male, male, male, female, female, male, fem…
## $ age <dbl> 44, 76, 47, 21, 29, 24, 23, 56, 24, 32, 47, 24, 4…
## $ driving_license <fct> yes, yes, yes, yes, yes, yes, yes, yes, yes, yes,…
## $ region_code <dbl> 28, 3, 28, 11, 41, 33, 11, 28, 3, 6, 35, 50, 15, …
## $ previously_insured <fct> no, no, no, yes, yes, no, no, no, yes, yes, no, y…
## $ vehicle_age <fct> over_2_years, between_1_2_years, over_2_years, be…
## $ vehicle_damage <fct> yes, no, yes, no, no, yes, yes, yes, no, no, yes,…
## $ health_annual_paid <dbl> 40454, 33536, 38294, 28619, 27496, 2630, 23367, 3…
## $ policy_sales_channel <dbl> 26, 26, 26, 152, 152, 160, 152, 26, 152, 152, 124…
## $ days_associated <dbl> 217, 183, 27, 203, 39, 176, 249, 72, 28, 80, 46, …
## $ response <fct> yes, no, yes, no, no, no, no, yes, no, no, yes, n…
Check data
structure
Data summary
|
Name
|
df_cleaned
|
|
Number of rows
|
381109
|
|
Number of columns
|
12
|
|
_______________________
|
|
|
Column type frequency:
|
|
|
factor
|
6
|
|
numeric
|
6
|
|
________________________
|
|
|
Group variables
|
None
|
Variable type: factor
|
skim_variable
|
n_missing
|
complete_rate
|
ordered
|
n_unique
|
top_counts
|
|
gender
|
0
|
1
|
FALSE
|
2
|
mal: 206089, fem: 175020
|
|
driving_license
|
0
|
1
|
FALSE
|
2
|
yes: 380297, no: 812
|
|
previously_insured
|
0
|
1
|
FALSE
|
2
|
no: 206481, yes: 174628
|
|
vehicle_age
|
0
|
1
|
FALSE
|
3
|
bet: 200316, bel: 164786, ove: 16007
|
|
vehicle_damage
|
0
|
1
|
FALSE
|
2
|
yes: 192413, no: 188696
|
|
response
|
0
|
1
|
FALSE
|
2
|
no: 334399, yes: 46710
|
Variable type: numeric
|
skim_variable
|
n_missing
|
complete_rate
|
mean
|
sd
|
p0
|
p25
|
p50
|
p75
|
p100
|
hist
|
|
id
|
0
|
1
|
190555.00
|
110016.84
|
1
|
95278
|
190555
|
285832
|
381109
|
▇▇▇▇▇
|
|
age
|
0
|
1
|
38.82
|
15.51
|
20
|
25
|
36
|
49
|
85
|
▇▃▃▂▁
|
|
region_code
|
0
|
1
|
26.39
|
13.23
|
0
|
15
|
28
|
35
|
52
|
▃▂▇▃▃
|
|
health_annual_paid
|
0
|
1
|
30564.39
|
17213.16
|
2630
|
24405
|
31669
|
39400
|
540165
|
▇▁▁▁▁
|
|
policy_sales_channel
|
0
|
1
|
112.03
|
54.20
|
1
|
29
|
133
|
152
|
163
|
▅▁▁▃▇
|
|
days_associated
|
0
|
1
|
154.35
|
83.67
|
10
|
82
|
154
|
227
|
299
|
▇▇▇▇▇
|
Numerical
Statistics
|
|
age
|
days_associated
|
health_annual_paid
|
|
Mean
|
38.82
|
154.35
|
30564.39
|
|
Std.Dev
|
15.51
|
83.67
|
17213.16
|
|
Min
|
20.00
|
10.00
|
2630.00
|
|
Q1
|
25.00
|
82.00
|
24405.00
|
|
Median
|
36.00
|
154.00
|
31669.00
|
|
Q3
|
49.00
|
227.00
|
39400.00
|
|
Max
|
85.00
|
299.00
|
540165.00
|
|
MAD
|
17.79
|
108.23
|
11125.43
|
|
IQR
|
24.00
|
145.00
|
14995.00
|
|
CV
|
0.40
|
0.54
|
0.56
|
|
Skewness
|
0.67
|
0.00
|
1.77
|
|
SE.Skewness
|
0.00
|
0.00
|
0.00
|
|
Kurtosis
|
-0.57
|
-1.20
|
34.00
|
|
N.Valid
|
381109.00
|
381109.00
|
381109.00
|
|
Pct.Valid
|
100.00
|
100.00
|
100.00
|
Visualization
Numerical
Attributes

Categorical
Attributes

Hypothesis
Validation
H1) Older customers
are more likely to be interested in car insurance.
| Characteristic |
yes, N = 46,710 |
no, N = 334,399 |
p-value |
| age |
43 (35, 51) |
34 (24, 49) |
<0.001 |
Young people
seems to be less likely interested in car insurance. The median age for
interested customers is 43 years (IQR: 35, 51), while the median for
non-interested customers is 34 years (IQR: 24, 49). ## explain the
p-value
H2) Women are
likely more interested in car insurance 🟥

| Characteristic |
yes, N = 46,710 |
no, N = 334,399 |
| gender |
|
|
| female |
18,185 (39%) |
156,835 (47%) |
| male |
28,525 (61%) |
177,564 (53%) |
For customers
interested in car insurance, 61% were men, and 39% were women. So this
hypothesis is FALSE. Although, gender and response are statistically
significant, i. e., are related.
H3) Customers
having newer cars are more likely to be interested in car insurance

| Characteristic |
yes, N = 46,710 |
no, N = 334,399 |
p-value |
| vehicle_age |
|
|
<0.001 |
| below_1_year |
7,202 (15%) |
157,584 (47%) |
|
| between_1_2_years |
34,806 (75%) |
165,510 (49%) |
|
| over_2_years |
4,702 (10%) |
11,305 (3.4%) |
|
Customers who own
a car between 1 and 2 years are more likely to be interested in the car
insurance (75%). While, only 15% of the interested customers have new
car.
H4) Customer with
previous car damage are more likely to accept car insurance ✅

| Characteristic |
yes, N = 46,710 |
no, N = 334,399 |
p-value |
| vehicle_damage |
45,728 (98%) |
146,685 (44%) |
<0.001 |
Customers with
previous car damage are more likely to be interested in car insurance,
as 98% said yes.
H5) Customers with
previous car insurance are more likely to accept car insurance :

| Characteristic |
yes, N = 46,710 |
no, N = 334,399 |
p-value |
| previously_insured |
158 (0.3%) |
174,470 (52%) |
<0.001 |
Only 0.3& of
customers interested in car insurance have car previously insured
H6) Interest in car
insurance is greater in customers which have higher annual health
insurance 🟥


| Characteristic |
yes, N = 46,710 |
no, N = 334,399 |
p-value |
| health_annual_paid |
33,002 (24,868, 41,297) |
31,504 (24,351, 39,120) |
<0.001 |
Although the health annual paid showed to be significant, we consider
this hyphotesis false and will further investigate the outliers, in he
next cycle for example.
H7) Customers who
has health insurance for LONGER are more likely to be interested in car
insurance 🟥


| Characteristic |
yes, N = 46,710 |
no, N = 334,399 |
p-value |
| days_associated |
154 (82, 226) |
154 (82, 227) |
0.5 |
This Hypothesis
is false, basically the interested customers and non-interested
customers have the same amount of days associated. Yes(median:154 days,
IQR: 82, 226); No (154 days, IQR: 82, 227).
Hypothesis
Conclusion
|
hypothesis
|
conclusion
|
relevance
|
|
H1) OLDER customers are more likely to be interested in car insurance
|
True
|
High
|
|
H2) Women are likely more interested in car insurance
|
False
|
Medium
|
|
H3) Customers having newer cars are more likely to be interested in car
insurance
|
False
|
High
|
|
H4) Customer with previous car damage are more likely to accept car
insurance
|
True
|
High
|
|
H5) Customers with previous car insurance are more likely to accept car
insurance
|
False
|
High
|
|
H6) Interest in car insurance is greater in customers which have higher
annual health insurance
|
False
|
Low
|
|
H7) Customers who has health insurance for LONGER are more likely to be
interested in car insurance
|
False
|
Low
|
Multivariable
Analysis
Correlation
Matrix
Visualization

There is no high correlation between numerical variables
Data Preparation
Frequency encoding for policy_sales_channel
Target encoding for gender e region_code
Target encoding
Frequency
encoding
Using the created
encoders in the dataset
Splitting into train
and test datasets
Check response
proportions
| Characteristic |
N = 285,831 |
| response |
|
| yes |
35,032 (12%) |
| no |
250,799 (88%) |
| Characteristic |
N = 95,278 |
| response |
|
| yes |
11,678 (12%) |
| no |
83,600 (88%) |
Using tidymodels
steps to continue the preprocessing
Applying the
recipe
Feature Selection
## Time difference of 7.408854 secs
Show results

In tgis first cycle we are going to select the seven most importatnt
vaiables according to the mean decrease gini
## [1] "vehicle_damage_no" "days_associated" "age"
## [4] "health_annual_paid" "previously_insured_no" "policy_sales_channel"
## [7] "region_code"