A wholesale distributor recently tested a change to their delivery method for some customers, by moving from a morning delivery service five days a week to a cheaper evening delivery service three days a week. Initial testing did not discover any significant unsatisfactory results, so they implemented the cheaper option for all customers. Almost immediately, the distributor began getting complaints about the delivery service change and customers were canceling deliveries — losing the distributor more money than what was being saved. We’ve been hired by the wholesale distributor to find what types of customers they have to help them make better, more informed business decisions in the future. Your task is to use unsupervised learning techniques to see if any similarities exist between customers, and how to best segment customers into distinct categories.
In this project, we apply unsupervised learning techniques on product spending data collected for customers of a wholesale distributor in Lisbon, Portugal to identify customer segments hidden in the data. We first explore the data by selecting a small subset to sample and determine if any product categories highly correlate with one another. Afterwards, we preprocess the data by scaling each product category and then identifying (and removing) unwanted outliers. With the good, clean customer spending data, we apply PCA transformations to the data and implement clustering algorithms to segment the transformed customer data. Finally, we compare the segmentation found with an additional labeling and consider ways this information could assist the wholesale distributor with future service changes.
This project requires Python 2.7 and the following Python libraries installed:
You will also need to have software installed to run and execute a Jupyter Notebook
If you do not have Python installed yet, it is highly recommended that you install the Anaconda distribution of Python, which already has the above packages and more included. Make sure that you select the Python 2.7 installer and not the Python 3.x installer.
Template code is provided in the customer_segments.ipynb
notebook file. You will also be required to use the included visuals.py
Python file and the housing.csv
dataset file to complete your work. While some code has already been implemented to get you started, you will need to implement additional functionality when requested to successfully complete the project. Note that the code included in visuals.py
is meant to be used out-of-the-box and not intended for students to manipulate. If you are interested in how the visualizations are created in the notebook, please feel free to explore this Python file.
In a terminal or command window, navigate to the top-level project directory customer_segments/
(that contains this README) and run one of the following commands:
ipython notebook customer_segments.ipynb
or
jupyter notebook customer_segments.ipynb
This will open the Jupyter Notebook software and project file in your browser.
The customer segments data is included as a selection of 440 data points collected on data found from clients of a wholesale distributor in Lisbon, Portugal. More information can be found on the UCI Machine Learning Repository.
Note (m.u.) is shorthand for monetary units.
Features
Fresh
: annual spending (m.u.) on fresh products (Continuous);Milk
: annual spending (m.u.) on milk products (Continuous);Grocery
: annual spending (m.u.) on grocery products (Continuous);Frozen
: annual spending (m.u.) on frozen products (Continuous);Detergents_Paper
: annual spending (m.u.) on detergents and paper products (Continuous);Delicatessen
: annual spending (m.u.) on and delicatessen products (Continuous);Channel
: {Hotel/Restaurant/Cafe - 1, Retail - 2} (Nominal)Region
: {Lisnon - 1, Oporto - 2, or Other - 3} (Nominal)