Appendix
1. Introduction to Clustering
Activity 1.01: Implementing k-means Clustering
Solution:
- Import the required libraries:
from sklearn.datasets import make_blobs
from sklearn.cluster import KMeans
from sklearn.metrics import accuracy_score, silhouette_score
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from scipy.spatial.distance import cdist
import math
np.random.seed(0)
%matplotlib inline
- Load the seeds data file using pandas:
seeds = pd.read_csv('Seed_Data.csv')
- Return the first five rows of the dataset, as follows:
seeds.head()
The output is as follows:
- Separate ...
Get The Unsupervised Learning Workshop now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.