import $ivy.`com.github.haifengl::smile-scala:3.1.0` import $ivy.`org.slf4j:slf4j-simple:2.0.13` import scala.language.postfixOps import smile._ import smile.math._ import smile.math.distance._ import smile.math.kernel._ import smile.math.matrix._ import smile.math.matrix.Matrix._ import smile.math.rbf._ import smile.stat.distribution._ import smile.data._ import smile.data.formula._ import smile.data.measure._ import smile.data.`type`._ import smile.clustering._ import java.awt.Color.{BLACK, BLUE, CYAN, DARK_GRAY, GRAY, GREEN, LIGHT_GRAY, MAGENTA, ORANGE, PINK, RED, WHITE, YELLOW} import smile.plot.swing.Palette.{DARK_RED, VIOLET_RED, DARK_GREEN, LIGHT_GREEN, PASTEL_GREEN, FOREST_GREEN, GRASS_GREEN, NAVY_BLUE, SLATE_BLUE, ROYAL_BLUE, CADET_BLUE, MIDNIGHT_BLUE, SKY_BLUE, STEEL_BLUE, DARK_BLUE, DARK_MAGENTA, DARK_CYAN, PURPLE, LIGHT_PURPLE, DARK_PURPLE, GOLD, BROWN, SALMON, TURQUOISE, BURGUNDY, PLUM} import smile.plot.swing._ import smile.plot.show import smile.plot.Render._ val x = read.csv("../data/clustering/gaussian/six.txt", header = false, delimiter = ' ').toArray val clusters = hclust(x, "complete") show(dendrogram(clusters)) val clusters = kmeans(x, 6, runs = 20) show(plot(x, clusters.y, '.')) val elongate = read.csv("../data/clustering/gaussian/elongate.txt", header = false, delimiter = '\t').toArray val clusters = kmeans(elongate, 2, runs = 20) show(plot(elongate, clusters.y, '.')) val clusters = xmeans(x, 50) show(plot(x, clusters.y, '.')) val clusters = gmeans(x, 50) show(plot(x, clusters.y, '.')) val clusters = dac(x, 12, 0.9) show(plot(x, clusters.y, '.')) val data = read.libsvm("../data/libsvm/news20.dat") val sparse = (0 until data.size).map(i => data(i).x).toArray val clusters = sib(sparse, 20, 100, 8) val clusters = clarans(x, new EuclideanDistance(), 6, 10, 20) show(plot(x, clusters.y, '.')) val t48 = read.csv("../data/clustering/chameleon/t4.8k.txt", header = false, delimiter = ' ').toArray val clusters = dbscan(t48, 20, 10) show(plot(t48, clusters.y, '.')) val clusters = denclue(x, 1.0, 50) show(plot(x, clusters.y, '.')) val sincos = read.csv("../data/clustering/nonconvex/sincos.txt", header = false, delimiter = '\t').toArray val clusters = specc(sincos, 2, 0.2) show(plot(sincos, clusters.y, 'o')) val clusters = mec(x, 20, 2.0) show(plot(x, clusters.y, '.'))