You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by me...@apache.org on 2015/02/16 05:41:30 UTC
spark git commit: SPARK-5815 [MLLIB] Deprecate SVDPlusPlus APIs that
expose DoubleMatrix from JBLAS
Repository: spark
Updated Branches:
refs/heads/master cd4a15366 -> acf2558dc
SPARK-5815 [MLLIB] Deprecate SVDPlusPlus APIs that expose DoubleMatrix from JBLAS
Deprecate SVDPlusPlus.run and introduce SVDPlusPlus.runSVDPlusPlus with return type that doesn't include DoubleMatrix
CC mengxr
Author: Sean Owen <so...@cloudera.com>
Closes #4614 from srowen/SPARK-5815 and squashes the following commits:
288cb05 [Sean Owen] Clarify deprecation plans in scaladoc
497458e [Sean Owen] Deprecate SVDPlusPlus.run and introduce SVDPlusPlus.runSVDPlusPlus with return type that doesn't include DoubleMatrix
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/acf2558d
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/acf2558d
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/acf2558d
Branch: refs/heads/master
Commit: acf2558dc92901c342262c35eebb95f2a9b7a9ae
Parents: cd4a153
Author: Sean Owen <so...@cloudera.com>
Authored: Sun Feb 15 20:41:27 2015 -0800
Committer: Xiangrui Meng <me...@databricks.com>
Committed: Sun Feb 15 20:41:27 2015 -0800
----------------------------------------------------------------------
.../apache/spark/graphx/lib/SVDPlusPlus.scala | 25 ++++++++++++++++++++
.../spark/graphx/lib/SVDPlusPlusSuite.scala | 2 +-
2 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/acf2558d/graphx/src/main/scala/org/apache/spark/graphx/lib/SVDPlusPlus.scala
----------------------------------------------------------------------
diff --git a/graphx/src/main/scala/org/apache/spark/graphx/lib/SVDPlusPlus.scala b/graphx/src/main/scala/org/apache/spark/graphx/lib/SVDPlusPlus.scala
index 112ed09..fc84cfb 100644
--- a/graphx/src/main/scala/org/apache/spark/graphx/lib/SVDPlusPlus.scala
+++ b/graphx/src/main/scala/org/apache/spark/graphx/lib/SVDPlusPlus.scala
@@ -17,6 +17,8 @@
package org.apache.spark.graphx.lib
+import org.apache.spark.annotation.Experimental
+
import scala.util.Random
import org.jblas.DoubleMatrix
import org.apache.spark.rdd._
@@ -38,6 +40,8 @@ object SVDPlusPlus {
extends Serializable
/**
+ * :: Experimental ::
+ *
* Implement SVD++ based on "Factorization Meets the Neighborhood:
* a Multifaceted Collaborative Filtering Model",
* available at [[http://public.research.att.com/~volinsky/netflix/kdd08koren.pdf]].
@@ -45,12 +49,33 @@ object SVDPlusPlus {
* The prediction rule is rui = u + bu + bi + qi*(pu + |N(u)|^(-0.5)*sum(y)),
* see the details on page 6.
*
+ * This method temporarily replaces `run()`, and replaces `DoubleMatrix` in `run()`'s return
+ * value with `Array[Double]`. In 1.4.0, this method will be deprecated, but will be copied
+ * to replace `run()`, which will then be undeprecated.
+ *
* @param edges edges for constructing the graph
*
* @param conf SVDPlusPlus parameters
*
* @return a graph with vertex attributes containing the trained model
*/
+ @Experimental
+ def runSVDPlusPlus(edges: RDD[Edge[Double]], conf: Conf)
+ : (Graph[(Array[Double], Array[Double], Double, Double), Double], Double) =
+ {
+ val (graph, u) = run(edges, conf)
+ // Convert DoubleMatrix to Array[Double]:
+ val newVertices = graph.vertices.mapValues(v => (v._1.toArray, v._2.toArray, v._3, v._4))
+ (Graph(newVertices, graph.edges), u)
+ }
+
+ /**
+ * This method is deprecated in favor of `runSVDPlusPlus()`, which replaces `DoubleMatrix`
+ * with `Array[Double]` in its return value. This method is deprecated. It will effectively
+ * be removed in 1.4.0 when `runSVDPlusPlus()` is copied to replace `run()`, and hence the
+ * return type of this method changes.
+ */
+ @deprecated("Call runSVDPlusPlus", "1.3.0")
def run(edges: RDD[Edge[Double]], conf: Conf)
: (Graph[(DoubleMatrix, DoubleMatrix, Double, Double), Double], Double) =
{
http://git-wip-us.apache.org/repos/asf/spark/blob/acf2558d/graphx/src/test/scala/org/apache/spark/graphx/lib/SVDPlusPlusSuite.scala
----------------------------------------------------------------------
diff --git a/graphx/src/test/scala/org/apache/spark/graphx/lib/SVDPlusPlusSuite.scala b/graphx/src/test/scala/org/apache/spark/graphx/lib/SVDPlusPlusSuite.scala
index e01df56..9987a4b 100644
--- a/graphx/src/test/scala/org/apache/spark/graphx/lib/SVDPlusPlusSuite.scala
+++ b/graphx/src/test/scala/org/apache/spark/graphx/lib/SVDPlusPlusSuite.scala
@@ -32,7 +32,7 @@ class SVDPlusPlusSuite extends FunSuite with LocalSparkContext {
Edge(fields(0).toLong * 2, fields(1).toLong * 2 + 1, fields(2).toDouble)
}
val conf = new SVDPlusPlus.Conf(10, 2, 0.0, 5.0, 0.007, 0.007, 0.005, 0.015) // 2 iterations
- var (graph, u) = SVDPlusPlus.run(edges, conf)
+ var (graph, u) = SVDPlusPlus.runSVDPlusPlus(edges, conf)
graph.cache()
val err = graph.vertices.collect().map{ case (vid, vd) =>
if (vid % 2 == 1) vd._4 else 0.0
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org