2d mixture-of-Gaussians classification (RG plane)

Visualize distributions

which = {1, 2} ; gobj1 = PlotRepresentativeSample2D[data1, 2000, which, pointStyle1] ; gobj2 = ... meLabelNone, nS] ; gbase = Show[g1, g2, nS] ; Show[GraphicsArray[{g1, g2}], imSize, yS] ;

[Graphics:../HTMLFiles/index_56.gif]

EM experiment #1: object 1 (Kellogs car)

Extract 2d data

Choose number of Gaussians in mixture model

Assumes full covariance matrices

Compute EM algorithm

RowBox[{Timing, [, RowBox[{RowBox[{em,  , =,  , RowBox[{EM, [, RowBox[{d2d1, ,, initFull, ,, 0.001}], ]}]}], ;}], ]}]

RowBox[{{, RowBox[{RowBox[{5.96,  , Second}], ,, Null}], }}]

Save solution

Final model

EMAllPlot[model1, g1] ;

[Graphics:../HTMLFiles/index_64.gif]

Plot log-likelihood of data given the model as a function of EM iteration

PlotLogLikelihood[em, d2d1] ;

[Graphics:../HTMLFiles/index_66.gif]

EM experiment #2: object 2 (Tide car)

Extract 2d data

Choose number of Gaussians in mixture model

Assumes full covariance matrices

Compute EM algorithm

RowBox[{Timing, [, RowBox[{RowBox[{em,  , =,  , RowBox[{EM, [, RowBox[{d2d2, ,, initFull, ,, 0.001}], ]}]}], ;}], ]}]

RowBox[{{, RowBox[{RowBox[{3.89,  , Second}], ,, Null}], }}]

Save solution

Final model

EMAllPlot[model2, g2] ;

[Graphics:../HTMLFiles/index_74.gif]

Plot log-likelihood of data given the model as a function of EM iteration

PlotLogLikelihood[em, d2d2] ;

[Graphics:../HTMLFiles/index_76.gif]

Resulting classification of 2d space

pts = 150 ; RowBox[{RowBox[{reg1,  , =, RowBox[{MixtureLikelihoodMatrix, [, RowBox[{RowBox[{{, ... n[If[#[[1]] < #[[2]], 1, 0] & /@ ({Flatten[reg1], Flatten[reg2]} // Transpose), pts + 1] ;

<br />classPlot1 = ListDensityPlot[class, ColorFunction-> (If[#0, pointStyle1[[1]], ... #62754;None, nS] ; Show[GraphicsArray[{{g1, g2}, {classPlot1, classPlot2}}], imSize, yS] ;

[Graphics:../HTMLFiles/index_79.gif]

Image classification

pdf1 = MixtureLikelihoodNative[{x, y}, model1] ; pdf2 = MixtureLikelihoodNative[{x, y}, model2] ;

RowBox[{RowBox[{class1, =, RowBox[{ClassifyImage2DAugmented, [, RowBox[{obj1, ,, pdf1, ,, pdf2 ...  255.}], ]}]}], ;}] Show[GraphicsArray[{{obj1, class1}, {obj2, class2}}], ImageSize400] ;

[Graphics:../HTMLFiles/index_82.gif]

Error plot

cnt1 = CountPixels[class1] ; cnt2 = CountPixels[class2] ;

bar = {cnt1, cnt2} // Transpose ; BarChart[bar[[1]], bar[[2]], BarStyle {pointStyle1[[ ... , FrameTrue, BarLabels {"Kellogs", "Tide"}, imSize] ;

[Graphics:../HTMLFiles/index_85.gif]


Created by Mathematica  (September 8, 2003)