Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2CF822004F1 for ; Wed, 30 Aug 2017 22:27:08 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 2B921169664; Wed, 30 Aug 2017 20:27:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7A85D1693B6 for ; Wed, 30 Aug 2017 22:27:07 +0200 (CEST) Received: (qmail 57313 invoked by uid 500); 30 Aug 2017 20:27:05 -0000 Mailing-List: contact issues-help@mahout.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mahout.apache.org Delivered-To: mailing list issues@mahout.apache.org Received: (qmail 57275 invoked by uid 99); 30 Aug 2017 20:27:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2017 20:27:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id BFE25CDFCC for ; Wed, 30 Aug 2017 20:27:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id ychuXFo2Vplf for ; Wed, 30 Aug 2017 20:27:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 155E361040 for ; Wed, 30 Aug 2017 20:27:03 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 9A73EE0EBF for ; Wed, 30 Aug 2017 20:27:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id CCFE12416A for ; Wed, 30 Aug 2017 20:27:00 +0000 (UTC) Date: Wed, 30 Aug 2017 20:27:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@mahout.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (MAHOUT-1991) Implement naive DBSCAN Algorithm - O(n^2) complexity MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 30 Aug 2017 20:27:08 -0000 [ https://issues.apache.org/jira/browse/MAHOUT-1991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16147995#comment-16147995 ] ASF GitHub Bot commented on MAHOUT-1991: ---------------------------------------- Github user andrewpalumbo commented on a diff in the pull request: https://github.com/apache/mahout/pull/334#discussion_r136179872 --- Diff: math-scala/src/main/scala/org/apache/mahout/math/algorithms/clustering/DBSCAN.scala --- @@ -0,0 +1,217 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.mahout.math.algorithms.clustering + +import org.apache.mahout.math.scalabindings._ +import org.apache.mahout.math.scalabindings.RLikeOps._ +import org.apache.mahout.math._ +import org.apache.mahout.math.algorithms.common.distance.{DistanceMetric, DistanceMetricSelector} +import org.apache.mahout.math.drm._ +import org.apache.mahout.math.drm.RLikeDrmOps._ + +import scala.collection.mutable +import scala.io.Source + +class DistributedDBSCAN extends ClusteringFitter { + + var epsilon: Double = _ + var minPts: Int = _ + var distanceMeasure: Symbol = _ + + def setStandardHyperparameters(hyperparameters: Map[Symbol, Any] = Map('foo -> None)): Unit = { + epsilon = hyperparameters.asInstanceOf[Map[Symbol, Double]].getOrElse('epsilon, 0.5) + minPts = hyperparameters.asInstanceOf[Map[Symbol, Int]].getOrElse('minPts, 1) + distanceMeasure = hyperparameters.asInstanceOf[Map[Symbol, Symbol]].getOrElse('distanceMeasure, 'Euclidean) + } + + def fit[K](input: DrmLike[K], + hyperparameters: (Symbol, Any)*): DBSCANModel = { + + setStandardHyperparameters(hyperparameters.toMap) + implicit val ctx = input.context + implicit val ktag = input.keyClassTag + + val dmNumber = DistanceMetricSelector.namedMetricLookup(distanceMeasure) + + val configBC = drmBroadcast(dvec(epsilon, minPts, dmNumber)) + + val clusters = input.allreduceBlock( + { + // Assign All Points to Clusters + case (keys, block: Matrix) => { + val epsilon_local = configBC.value.get(0) + val minPts_local = configBC.value.get(1) + + val distanceMetric = DistanceMetricSelector.select(configBC.value.get(3)) + val icDBSCAN = new InCoreDBSCAN(block, epsilon_local, minPts_local.toInt, distanceMetric) + // do stuff on icDBSCAN + icDBSCAN.DBSCAN() + } + }, { + // Optionally Merge Clusters that are close enough + case (metadata1: Matrix, metadata2: Matrix) => { + // this does nothing- just returns the left matrix + metadata1 + } + }) + + val model = new DBSCANModel(1) + model.summary = s"""foo the bar""" --- End diff -- @AdityaAS do you have a plan for the model summary? > Implement naive DBSCAN Algorithm - O(n^2) complexity > ---------------------------------------------------- > > Key: MAHOUT-1991 > URL: https://issues.apache.org/jira/browse/MAHOUT-1991 > Project: Mahout > Issue Type: New Feature > Components: Algorithms > Reporter: Aditya AS > Assignee: Aditya AS > > Implement the naive DBSCAN algorithm in Mahout Samsara, as part of the Algorithms Framework. -- This message was sent by Atlassian JIRA (v6.4.14#64029)