我刚开始使用 moa ,并且在尝试解码如何使用聚类算法方面遇到了困难。 documentation缺乏用于常用用法的示例代码,并且implementation的注释也没有得到很好的解释……也未找到任何教程。
所以,这是我的代码:
ALLSELECTED
这是我得到的错误:
任何对如何使用算法的见解将不胜感激。谢谢!
我刚开始使用 moa ,并且在尝试解码如何使用聚类算法方面遇到了困难。 documentation缺乏用于常用用法的示例代码,并且implementation的注释也没有得到很好的解释……也未找到任何教程。
所以,这是我的代码:
ALLSELECTED
这是我得到的错误:
任何对如何使用算法的见解将不胜感激。谢谢!
我已经更新了代码。 正如我在github中提到的那样,它正在工作,您必须为您的实例分配标头。 See the github discussion
这是更新的代码:
static DenseInstance randomInstance(int size) {
// generates the name of the features which is called as InstanceHeader
ArrayList<Attribute> attributes = new ArrayList<Attribute>();
for (int i = 0; i < size; i++) {
attributes.add(new Attribute("feature_" + i));
}
// create instance header with generated feature name
InstancesHeader streamHeader = new InstancesHeader(
new Instances("Mustafa Çelik Instance",attributes,size));
// generates random data
double[] data = new double[2];
Random random = new Random();
for (int i = 0; i < 2; i++) {
data[i] = random.nextDouble();
}
// creates an instance and assigns the data
DenseInstance inst = new DenseInstance(1.0,data);
// assigns the instanceHeader(feature name)
inst.setDataset(streamHeader);
return inst;
}
public static void main(String[] args) {
WithDBSCAN withDBSCAN = new WithDBSCAN();
withDBSCAN.resetLearningImpl();
withDBSCAN.initialDBScan();
for (int i = 0; i < 1500; i++) {
DenseInstance d = randomInstance(5);
withDBSCAN.trainOnInstanceImpl(d);
}
Clustering clusteringResult = withDBSCAN.getClusteringResult();
Clustering microClusteringResult = withDBSCAN.getMicroClusteringResult();
System.out.println(clusteringResult);
}
这是调试过程的屏幕截图,如您所见,将生成聚类结果:
图片链接已损坏,您可以在github github entry link
上找到它