makeCluster[class_,\[Mu]_,\[Rho]_]:=
RandomVariate[MultinormalDistribution[\[Mu],{{1,4\[Rho]},
{4 \[Rho],4}}],500]->class;
clusters=makeCluster@@@{{1,{1.5,1.8},-.2},{2,{-1.5,1.1},.3},
clusters=makeCluster@@@{{1,{1.5,1.8},-.2},{2,{-1.5,1.1},.3},
{3,{-1.6,-2.3},-.4},{4,{1.8,-2.2},.1}};
lp1=ListPlot[Keys[clusters],PlotStyle ->"BrightBands"];
clf=Classify[Flatten[Thread/@clusters],Method->"NearestNeighbors"]
sample={{2.5,2.8},{-1.7,1.5},{-0.9,-2.1},{1.6,-1.8}};
lp2=ListPlot[List/@sample,
lp1=ListPlot[Keys[clusters],PlotStyle ->"BrightBands"];
clf=Classify[Flatten[Thread/@clusters],Method->"NearestNeighbors"]
sample={{2.5,2.8},{-1.7,1.5},{-0.9,-2.1},{1.6,-1.8}};
lp2=ListPlot[List/@sample,
PlotMarkers->clf[sample],PlotStyle->Black];
Show[lp1,lp2,ImageSize->Large,PlotRange->{{-5,5},{-5,5}}]
Show[lp1,lp2,ImageSize->Large,PlotRange->{{-5,5},{-5,5}}]
No comments:
Post a Comment