5. Artificial Intelligence: Clustering
Activity 5.01: Clustering Sales Data Using K-Means
Solution:
- Open a new Jupyter Notebook file.
- Load the dataset as a DataFrame and inspect the data:
import pandas as pd file_url = 'https://raw.githubusercontent.com/'\ Â Â Â Â Â Â Â Â Â Â Â 'PacktWorkshops/'\ Â Â Â Â Â Â Â Â Â Â Â 'The-Applied-Artificial-Intelligence-Workshop/'\ Â Â Â Â Â Â Â Â Â Â Â 'master/Datasets/'\ Â Â Â Â Â Â Â Â Â Â Â 'Sales_Transactions_Dataset_Weekly.csv' df = pd.read_csv(file_url) df
The output of
df
is as follows:If you look at the output, you will notice that our dataset contains
811
rows, with each row representing a product. It also contains107
columns, with the first column...