Java apachedbscanclusterer始终返回集群中的一个点
我试图使用apache.commons.math3.ml.clustering包中的DBSCANClusterer,但没有成功。我使用的是Apache Common Math 3.4.1 当我运行DBSCANClusterer.cluster()方法时,我总是得到一个带有一个点的集群,它总是对应于我的点列表中的第一个点Java apachedbscanclusterer始终返回集群中的一个点,java,cluster-analysis,dbscan,apache-commons-math,Java,Cluster Analysis,Dbscan,Apache Commons Math,我试图使用apache.commons.math3.ml.clustering包中的DBSCANClusterer,但没有成功。我使用的是Apache Common Math 3.4.1 当我运行DBSCANClusterer.cluster()方法时,我总是得到一个带有一个点的集群,它总是对应于我的点列表中的第一个点 publicstaticvoidmain(字符串[]args) { DBSCanceClusterer dbscan=新的DBSCanceClusterer(.9,2); 列表
publicstaticvoidmain(字符串[]args)
{
DBSCanceClusterer dbscan=新的DBSCanceClusterer(.9,2);
列表点=新的ArrayList();
double[]foo=新的double[2];
int i=0;
对于(i=0;i您的第一个“簇”可能是噪波簇。使用您的参数,所有数据都是噪波,因此您只能得到一个簇,包含所有点。您为每个点重复使用foo数组时创建了1000个相同的点。您曾经绘制过点吗?:)我想这对你来说会变得非常明显。不管选择了什么样的点和每股收益,结果总是一样的。变量“cluster”在列表“points”中有第一个点。我甚至测试过彼此非常接近的点,比如10.0001到10.0005。例如,我将“foo[]=”行更改为“foo[0]=10+r.nextInt(100)/1000;“。仍然没有成功
public static void main(String[] args)
{
DBSCANClusterer dbscan = new DBSCANClusterer(.9,2);
List<DoublePoint> points = new ArrayList<DoublePoint>();
double[] foo = new double[2];
int i = 0;
for (i =0; i<1000 ; i++)
{
foo[0] = 10 + i;
foo[1] = 20 + i;
points.add(new DoublePoint(foo));
}
List<Cluster<DoublePoint>> cluster = dbscan.cluster(points);
// My output here is always: [1009 , 1019]
for(Cluster<DoublePoint> c: cluster){
System.out.println(c.getPoints().get(0));
}
}