For this lab, we will be using the dataset in the Customer Analysis Business Case. This dataset can be found in files_for_lab folder.
An auto insurance company has collected some data about its customers including their demographics, education, employment, policy details, vehicle information on which insurance policy is, and claim amounts. You will help the senior management with some business questions that will help them to better understand their customers, improve their services, and improve profitability.
- Retain customers,
- Analyze relevant customer data,
- Develop focused customer retention programs.
- Based on the analysis, take targeted actions to increase profitable customer response, retention, and growth.
- Case Study
- Get data
- Cleaning/Wrangling/EDA
- Processing Data
- Modeling -Validation
- Reporting
-
Import the necessary libraries.
-
Load the we_fn_use_c_marketing_customer_value_analysis.csv into the variable customer_df
-
First look at its main features (head, shape, info). NOTE The target column is total_claim_amount
-
Rename the columns so they follow the PE8 (snake case) (lower_case_with_underscores)
-
Change effective to date column to datetime format.
-
Create a NEW dataframe using only the numerical data called numerical_df. Use this for the following questions.
-
Define a function that differentiates between continuous and discrete variables. Hint: The number of unique values might be useful. Store continuous data into a continuous_df variable and do the same for discrete_df
-
Plot a correlation matrix, comment what you see.
-
Create a function to plot every discrete variable. Do the same with the continuous variables (Be Careful, you may need to change the plot type to one better suited for continuous data!)
-
Comment what you can see in the plots.
-
Look for outliers in the continuous variables. (HINT: There’s a good plot to do that!)
-
Did you find outliers? Comment what you will do with them. If you decide to remove them, do that now. Also, remove them from your main dataframe.
-
Check all columns for NaN values. Decide what (if anything) you will need to do with them, do that now.
-
Save the numerical_df to csv as numerical.csv You will use this file again this week.