Github user derrickburns commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2634#discussion_r23430407
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/clustering/metrics/FastEuclideanOps.scala
 ---
    @@ -0,0 +1,77 @@
    +/*
    + * 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.spark.mllib.clustering.metrics
    +
    +import breeze.linalg.{ DenseVector => BDV, SparseVector => BSV, Vector => 
BV }
    +
    +import org.apache.spark.mllib.base._
    +import org.apache.spark.mllib.linalg.{ SparseVector, DenseVector, Vector }
    +import org.apache.spark.mllib.base.{ Centroid, FPoint, PointOps, Infinity, 
Zero }
    +
    +class FastEUPoint(raw: BV[Double], weight: Double) extends FPoint(raw, 
weight) {
    +  val norm = if (weight == Zero) Zero else raw.dot(raw) / (weight * weight)
    --- End diff --
    
    @mengxr
    
    I spent some time thinking about clustering sparse data.  I realized that
    there may be a need to embed the sparse data into lower dimensional
    spaces.  Then, I realized that one of the Bregman divergences (i.e. the
    generalized symmetrized Bregman divergence), also embeds data into a
    different space before clustering.  This led me to the conclusion that
    embedding the data into a convenient space just prior to clustering is a
    very useful generic feature.  Adding it was trivial.  See the README on my
    GitHub project for details.
    
    I implemented two generic embeddings: 1) a sparse to dense embedding that
    maps points isomorphically and 2) random indexing
    <https://www.sics.se/~mange/papers/RI_intro.pdf> that maps high dimensional
    data into lower dimension in a way that preserves similarity per the
    Johnson-Lindenstrauss
    lemma <http://en.wikipedia.org/wiki/Johnson%E2%80%93Lindenstrauss_lemma>. I
    also recoded the embedding that I did for a generalized symmetrized KL
    divergence to use the new embedding design.
    
    I think that with these improvements one can check the "clusterer supports
    sparse data" feature box in a practical sense.
    
    I am about to being performance testing of the randoming indexing embedding
    on large volumes of high dimensional sparse data.
    
    Please take a look at the new PointOps trait definition.
    
    On Mon, Jan 19, 2015 at 5:36 PM, Derrick Burns <derrickrbu...@gmail.com>
    wrote:
    
    > For the squared Euclidean distance case, weights would naturally start at
    > 1.0 for each input point, so that a cluster with 100 points would have
    > weight 100.0.
    >
    > However, for the KL divergence where the points are derived from
    > frequencies, the initial weight could be the sum of the frequencies. This
    > puts the points on the simplex without having to perform the division.
    >
    > Sent from my iPhone
    >
    > On Jan 19, 2015, at 5:02 PM, Xiangrui Meng <notificati...@github.com>
    > wrote:
    >
    > In
    > 
mllib/src/main/scala/org/apache/spark/mllib/clustering/metrics/FastEuclideanOps.scala
    > <https://github.com/apache/spark/pull/2634#discussion-diff-23197316>:
    >
    > > + * 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.spark.mllib.clustering.metrics
    > > +
    > > +import breeze.linalg.{ DenseVector => BDV, SparseVector => BSV, Vector 
=> BV }
    > > +
    > > +import org.apache.spark.mllib.base._
    > > +import org.apache.spark.mllib.linalg.{ SparseVector, DenseVector, 
Vector }
    > > +import org.apache.spark.mllib.base.{ Centroid, FPoint, PointOps, 
Infinity, Zero }
    > > +
    > > +class FastEUPoint(raw: BV[Double], weight: Double) extends FPoint(raw, 
weight) {
    > > +  val norm = if (weight == Zero) Zero else raw.dot(raw) / (weight * 
weight)
    >
    > Could you elaborate more about the benefit of using homogeneous
    > coordinates? It should be at least documented that what "weight" stands 
for
    > here. If a cluster have 100 points, do you assign its center with weight
    > 100? If so, how to compute the distance between this center and an input
    > point?
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/spark/pull/2634/files#r23197316>.
    >
    >


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to