Applied Data Science Notebook in Python for Beginners to Professionals

An end-to-end tutorials on Cluster Analysis - Applied Machine Learning & Data Science

Unsupervised Learning - Comparing Clustering Algorithms in Python

In [1]:
# Suppress warnings in Jupyter Notebooks

import warnings
warnings.filterwarnings("ignore")
In [2]:
# Load the library
import numpy as np
import pandas as pd
from pandas import plotting
import matplotlib.pyplot as plt
import plotly.offline as py
from plotly.offline import init_notebook_mode, iplot
import plotly.graph_objs as go
from plotly import tools
import plotly.figure_factory as ff
import seaborn as sns
plt.style.use('fivethirtyeight')
In [3]:
# Load the dataset
df = pd.read_csv('Mall_Customers.csv')
df.head()
Out[3]:
CustomerID Gender Age Annual Income (k$) Spending Score (1-100)
0 1 Male 19 15 39
1 2 Male 21 15 81
2 3 Female 20 16 6
3 4 Female 23 16 77
4 5 Female 31 17 40
In [4]:
# Let's rename few columns
df.rename(columns={'Annual Income (k$)':'Income',
                   'Spending Score (1-100)':'Spending_score'}, inplace=True)
In [5]:
dat = ff.create_table(df.head())
py.iplot(dat)