📄 quickstart.txt
字号:
Once you have downloaded the library, you can start using it in you Java
programs. For now this guide features some basis sample programs that should
get you under way.
+----------------------------------------------+
| 1. Creating a dataset |
| 2. Creating and using a clustering algorithm |
+----------------------------------------------+
1. Creating a dataset
=====================
The code snippter below will create a two-dimensional dataset with four clusters of
objects, one in each corner.
Dataset data = new SimpleDataset();
double small=1.0f/4.0f;
double large=3.0f/4.0f;
Random rg = new Random(System.currentTimeMillis());
for (int i = 0; i < itemsPerCluster; i++) {
// lower left
double[] vec1 = { ((rg.nextGaussian() * clusterSpread) + space * small),
((rg.nextGaussian() * clusterSpread) + space * small) };
data.addInstance(new SimpleInstance(vec1));
// upper left
double[] vec2 = { ((rg.nextGaussian() * clusterSpread) + space * small),
((rg.nextGaussian() * clusterSpread) + space * large) };
data.addInstance(new SimpleInstance(vec2));
// lower righ
double[] vec3 = { ((rg.nextGaussian() * clusterSpread) + space * large),
((rg.nextGaussian() * clusterSpread) + space * small) };
data.addInstance(new SimpleInstance(vec3));
// upper right
double[] vec4= { ((rg.nextGaussian() * clusterSpread) + space * large),
((rg.nextGaussian() * clusterSpread) + space * large) };
data.addInstance(new SimpleInstance(vec4));
}
2. Creating and using a clustering algorithm
============================================
The following code snippet will take as input the dataset created in the
previous section, or any other dataset.
XMeans km = new XMeans();
Dataset[] clusters = km.executeClustering(data);
In the array clusters, you find the different clusters that are the output of
the algorithm.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -