二変数のデータ集合をクラスタ化する
二変数のデータ集合をクラスタ化する
data = ExampleData[{"Statistics", "OldFaithful"}];
𝒟 = KernelMixtureDistribution[data, "SheatherJones"];rng = RandomVariate[𝒟, 500];FindClustersを使ってデータを分ける:
Show[SmoothDensityHistogram[rng, ColorFunction -> "TemperatureMap", Mesh -> 10], ListPlot[FindClusters[rng, 2], PlotRange -> {{1, 6}, {30, 110}}, AspectRatio -> 1, Frame -> True, ImageSize -> 220, PlotStyle -> {Directive[PointSize[0.0185], Red], Directive[PointSize[0.0185], Black]}, PlotLabel -> Text[Style["Simulated Eruptions", FontFamily -> "Verdana", Bold]], Background -> Directive[Opacity[.5], White], Axes -> None]]p2 = ListPlot[FindClusters[rng, 2], PlotRange -> {{1, 6}, {30, 110}}, AspectRatio -> 1, Frame -> True, ImageSize -> 220, PlotStyle -> {Directive[PointSize[0.0185], Red], Directive[PointSize[0.0185], Black]}, PlotLabel -> Text[Style["Simulated Eruptions", FontFamily -> "Verdana", Bold]], Background -> Directive[Opacity[.5], White], Axes -> None];p1 = Plot3D[Evaluate[PDF[𝒟, {x, y}]], {x, 1, 6}, {y, 30, 105}, Mesh -> 25, PlotRange -> All, PlotLabel -> Text[Style["Duration vs. Waiting Time", FontFamily -> "Verdana", Large]], BoxRatios -> 1, PlotPoints -> 100, MeshStyle -> Opacity[.3], ColorFunction -> "TemperatureMap", Boxed -> False, ViewPoint -> {2, -2, 1}, Epilog -> Inset[p2, {Right, Bottom}, {Right, Bottom}], ImageSize -> 570]