Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark spark上的分布式DBSCAN_Apache Spark_Spark Graphx_Dbscan - Fatal编程技术网

Apache spark spark上的分布式DBSCAN

Apache spark spark上的分布式DBSCAN,apache-spark,spark-graphx,dbscan,Apache Spark,Spark Graphx,Dbscan,我试图在Spark上实现DBSCAN算法,所以我遵循本文。 他们提出了一个包含4个主要步骤的算法: 数据分区 计算本地DBSCAN 合并数据分区 全局聚类 所以我使用GraphX实现第二步,伪代码是这样的: 在当前分区中选择任意点p 计算N{e},如果N{e}>=minPts将p标记为核心点,否则标记为噪声点 如果p是一个核心点,那么通过p创建一个集群c,将属于集群c的所有点添加到递归调用列表中 这里是我的代码(我知道它不起作用): def dataPartition():图形[Array[S

我试图在Spark上实现DBSCAN算法,所以我遵循本文。 他们提出了一个包含4个主要步骤的算法:

  • 数据分区
  • 计算本地DBSCAN
  • 合并数据分区
  • 全局聚类
  • 所以我使用GraphX实现第二步,伪代码是这样的:

  • 在当前分区中选择任意点
    p
  • 计算
    N{e}
    ,如果
    N{e}>=minPts
    将p标记为核心点,否则标记为噪声点
  • 如果p是一个核心点,那么通过
    p
    创建一个集群
    c
    ,将属于集群
    c
    的所有点添加到递归调用列表中
  • 这里是我的代码(我知道它不起作用):

    def dataPartition():图形[Array[String],Int]={
    graph.partitionBy(PartitionStrategy.RandomVertexCut)
    }
    def computingLocalDBSCAN():单位={
    graph=dataPartition()
    //val邻居=graph.mapVertices((id,attr)=>localDBSCANMap(id,attr))
    }
    def localDBSCANMap(id:VertexId,attr:Array[String],cluster:Int):单位={
    val neights=graph.collectNeights(EdgeDirection.Out).lookup(id)
    如果(邻居大小>=eps){
    attr(0)=PointType.Core.toString
    attr(1)=cluster.toString
    }否则{
    attr(0)=PointType.Noise.toString
    }
    foreach(it=>{
    
    对于(项),我首先要解决
    graph.collectNeights(EdgeDirection.Out).lookup(id)
    mapVertices
    中调用的
    无法工作的问题。有几个(未维护)DBSCAN关于Spark在野外的实施——你可以将这些作为灵感。这里还有很多广泛的问题——它可以从分解成单独的问题中受益。确保仔细地进行基准测试。参见Neukirchen,H.(2016)的结果.针对大数据和高性能计算范例的DBSCAN空间群集实现的调查和性能评估。-spark似乎没有足够快的速度解决此类问题。@user9613318我知道代码不起作用,我不知道如何编写这些算法。我一直在寻找一些示例,但大部分是这样的不要使用
    GraphX
    ,或者不考虑复杂性。好吧,但无论如何,这应该是解决此类问题的一种方法,对吗?你有什么建议吗?我只在Spark中实现拆分,然后在每个分区上运行ELKI。它是Java,很容易从Spark调用。
    def dataPartition() : Graph[Array[String], Int] = {
        graph.partitionBy(PartitionStrategy.RandomVertexCut)
    }
    
    def computingLocalDBSCAN() : Unit = {
        graph = dataPartition() 
       //val neighbors = graph.mapVertices((id, attr) => localDBSCANMap(id, attr))
    }
    
    def localDBSCANMap(id: VertexId, attr:Array[String], cluster:Int):Unit = {
        val neighbors = graph.collectNeighbors(EdgeDirection.Out).lookup(id)
        if (neighbors.size >= eps) {
            attr(0) = PointType.Core.toString
            attr(1) = cluster.toString
        } else {
            attr(0) = PointType.Noise.toString
        }
    
        neighbors.foreach(it => {
            for (item <- it) {
                localDBSCANMap(item._1, item._2, cluster)
            }
        })
    }