datared py import numpy as np from numpy random import randn import matplotlib pyplot as plt from mpl_toolkits mplot import axes = mu np array ([ , - ]mu np array ([ - , ]mu np array ([ , , ] randn ( , mu randn ( , mu randn ( , mu fig plt figure (ax fig gcaprojection =' ,ax plot( [, [, [, ' ',alpha = markersize = ax plot( [, [, [, ' ',alpha = markersize = ax plot( [, [, [, ' ',alpha = markersize = ax set_xlim - , ax set_ylim - , ax set_zlim - , plt show (since we have equal mixtureswe classify each data point according to the closest distance to or we can achieve reduction in the dimensionality of the data by projecting the data onto the two-dimensional affine space spanned by the {ui }that isall vectors are of the form ( ( ) in factone may just as well project the data onto the subspace spanned by the vectors and let [ be the matrix whose columns are and the orthogonal projection matrix onto the subspace spanned by the columns of is (see theorem ) www(ww)- wlet udvbe the singular value decomposition of then can also be written as ud(dd)- dunote that has dimension so is not square the first two columns of usay and form an orthonormal basis of the subspace what we want to do is rotate this subspace to the planemapping and to [ ]and [ ]respectively this is achieved via the rotation matrix - ugiving the skewed projection matrix up (dd)- duwhose rd row only contains zeros applying to all the data pointsand ignoring the rd component of the projected points (which is )gives the right panel of figure we see that the projected points are much better separated than the original ones we have achieved dimensionality reduction of the data while retaining all the necessary information required for classification here is the rest of the python code