[GitHub] flink pull request: [FLINK-3330] [ml] Fix SparseVector support in ...

2016-02-05 Thread tillrohrmann
Github user tillrohrmann commented on the pull request:

https://github.com/apache/flink/pull/1587#issuecomment-180292797
  
Travis passed. Will merge the PR then.


---
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.
---


[GitHub] flink pull request: [FLINK-3330] [ml] Fix SparseVector support in ...

2016-02-05 Thread tillrohrmann
Github user tillrohrmann commented on a diff in the pull request:

https://github.com/apache/flink/pull/1587#discussion_r52001518
  
--- Diff: 
flink-libraries/flink-ml/src/main/scala/org/apache/flink/ml/optimization/GradientDescent.scala
 ---
@@ -192,10 +190,18 @@ abstract class GradientDescent extends 
IterativeSolver {
   (left, right) =>
 val (leftGradVector, leftCount) = left
 val (rightGradVector, rightCount) = right
-// Add the left gradient to the right one
-BLAS.axpy(1.0, leftGradVector.weights, rightGradVector.weights)
+
+// make the left gradient dense so that the following reduce 
operations (left fold) reuse
+// it. This strongly depends on the underlying implementation of 
the ReduceDriver
--- End diff --

If this should change in the future, the code has to be adapted to reflect 
that as well.


---
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.
---


[GitHub] flink pull request: [FLINK-3330] [ml] Fix SparseVector support in ...

2016-02-05 Thread tillrohrmann
Github user tillrohrmann commented on a diff in the pull request:

https://github.com/apache/flink/pull/1587#discussion_r52001489
  
--- Diff: 
flink-libraries/flink-ml/src/main/scala/org/apache/flink/ml/optimization/GradientDescent.scala
 ---
@@ -192,10 +190,18 @@ abstract class GradientDescent extends 
IterativeSolver {
   (left, right) =>
 val (leftGradVector, leftCount) = left
 val (rightGradVector, rightCount) = right
-// Add the left gradient to the right one
-BLAS.axpy(1.0, leftGradVector.weights, rightGradVector.weights)
+
+// make the left gradient dense so that the following reduce 
operations (left fold) reuse
+// it. This strongly depends on the underlying implementation of 
the ReduceDriver
--- End diff --

The reduce is implemented somewhat like a left fold operation, just without 
having an initial value. Thus you should not convert the right element, because 
it will always be the newly read input element.


---
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.
---


[GitHub] flink pull request: [FLINK-3330] [ml] Fix SparseVector support in ...

2016-02-05 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/flink/pull/1587


---
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.
---


[GitHub] flink pull request: [FLINK-3330] [ml] Fix SparseVector support in ...

2016-02-04 Thread tillrohrmann
GitHub user tillrohrmann opened a pull request:

https://github.com/apache/flink/pull/1587

[FLINK-3330] [ml] Fix SparseVector support in GradientDescent

The GradientDescent implementation did not work with sparse input data
because it requires the gradient to be dense. This patch makes sure that
the gradient sum is always dense.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/tillrohrmann/flink fixSparseGradientDescent

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/flink/pull/1587.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1587


commit 3eb72b8674e082d8d78445a282bea09921103a08
Author: Till Rohrmann 
Date:   2016-02-04T15:13:10Z

[FLINK-3330] [ml] Fix SparseVector support in GradientDescent

The GradientDescent implementation did not work with sparse input data
because it requires the gradient to be dense. This patch makes sure that
the gradient sum is always dense.




---
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.
---


[GitHub] flink pull request: [FLINK-3330] [ml] Fix SparseVector support in ...

2016-02-04 Thread thvasilo
Github user thvasilo commented on a diff in the pull request:

https://github.com/apache/flink/pull/1587#discussion_r51909968
  
--- Diff: 
flink-libraries/flink-ml/src/test/scala/org/apache/flink/ml/regression/RegressionData.scala
 ---
@@ -27,6 +27,21 @@ object RegressionData {
   val expectedWeight0: Double = 9.8158
   val expectedSquaredResidualSum: Double = 49.7596/2
 
+  val sparseData: Seq[LabeledVector] = Seq(
+new LabeledVector(1.0, new SparseVector(10, Array(0, 2, 3), Array(1.0, 
1.0, 1.0))),
+new LabeledVector(1.0, new SparseVector(10, Array(0, 1, 5, 9), 
Array(1.0, 1.0, 1.0, 1.0))),
+new LabeledVector(0.0, new SparseVector(10, Array(0, 2), Array(0.0, 
1.0))),
+new LabeledVector(0.0, new SparseVector(10, Array(0), Array(0.0))),
+new LabeledVector(0.0, new SparseVector(10, Array(0, 2), Array(0.0, 
1.0))),
+new LabeledVector(0.0, new SparseVector(10, Array(0), Array(0.0
+
+  val expectedWeightsSparseInput = Array(0.5448906338353784, 
0.15718880164669916,
+   0.034001300318125725, 
0.38770183218867915, 0.0,
+   0.15718880164669916, 0.0, 0.0, 
0.0, 0.15718880164669916)
--- End diff --

Indentation seems a bit off here.


---
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.
---


[GitHub] flink pull request: [FLINK-3330] [ml] Fix SparseVector support in ...

2016-02-04 Thread thvasilo
Github user thvasilo commented on a diff in the pull request:

https://github.com/apache/flink/pull/1587#discussion_r51910120
  
--- Diff: 
flink-libraries/flink-ml/src/main/scala/org/apache/flink/ml/optimization/GradientDescent.scala
 ---
@@ -192,10 +190,18 @@ abstract class GradientDescent extends 
IterativeSolver {
   (left, right) =>
 val (leftGradVector, leftCount) = left
 val (rightGradVector, rightCount) = right
-// Add the left gradient to the right one
-BLAS.axpy(1.0, leftGradVector.weights, rightGradVector.weights)
+
+// make the left gradient dense so that the following reduce 
operations (left fold) reuse
+// it. This strongly depends on the underlying implementation of 
the ReduceDriver
--- End diff --

Hey @tillrohrmann could you explain what you mean by "strongly depends on 
the underlying implementation of the ReduceDriver"?


---
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.
---