Introduction to K-Means

This tutorial assumes some familiarity with basic principles of machine learning, the math and code can be developed on the way.

Machine Learning

Learning can be Supervised, Unsupervised, Reinforced and Semi-supervised.

Reinforcement Learning: Learning with a critic, critic may be wrong at times, maybe stochastic, but different from supervisor in case of supervised learning. Supervisor gives feedback, critic only says yes or no.

K-Means algorithm:

  1. K as a parameter
  2. distance threshold as a parameter

K means crisp decision boundary: grading, fingerprint ROI(Region of Interest)

Reinforcement learning correspinds to lifelong learning, much like our biological learning process.

For crisp decision boundary, some error is always there and is acceptable, but try to minimize the error.

Fuzzy decision boundary: signal noise separation, decision boundary is not well defined

Threshold could be crisp or noisy.



Algorithms:

  1. Polynomial time O(nk): size of inut is n, number of steps is nk, eg: sorting, FFT

  2. Exponential time O(kn): size of inut is n, number of steps is kn, Travelling salesman problem

  3. Ugly: Optimal but takes infinite time



K Means

  • N points can be divided into K clusters, each point has D dimensions

  • uj is mean of the jth cluster

  • such that the sum of square distances of each data point to its closest vector uj is minimum.

  • Vector quantizatoin: uj -> points

  • Objective function: distortion measure or cost function \begin{equation} J = \sum_{i = 1}^{N}\sum_{j = 1}^{K} r_{ij} \left |x_i - u_j \right |^2 \end{equation}

  • Not taking abs or mod because mod is not differentiable and thus avoided during optimization.

  • r ij is a binary indicator variable: 1 if the ith data point is assigned to the jth cluster, 0 otherwise.

In total there are N data points and K clusters.

  • Find {rij} and {uj} such that J is minimised.

To solve use: Expectation Maximization framework or EM method.

Randomly choose K initial clusters with means uj.

  1. Fixed uj, find assignment rij.
  2. Take avg of xij to find new uj, repeat from 1.