You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by bu...@apache.org on 2014/08/20 22:57:25 UTC

svn commit: r919947 - in /websites/staging/mahout/trunk/content: ./ users/sparkbindings/play-with-shell.html

Author: buildbot
Date: Wed Aug 20 20:57:24 2014
New Revision: 919947

Log:
Staging update by buildbot for mahout

Modified:
    websites/staging/mahout/trunk/content/   (props changed)
    websites/staging/mahout/trunk/content/users/sparkbindings/play-with-shell.html

Propchange: websites/staging/mahout/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Aug 20 20:57:24 2014
@@ -1 +1 @@
-1619188
+1619229

Modified: websites/staging/mahout/trunk/content/users/sparkbindings/play-with-shell.html
==============================================================================
--- websites/staging/mahout/trunk/content/users/sparkbindings/play-with-shell.html (original)
+++ websites/staging/mahout/trunk/content/users/sparkbindings/play-with-shell.html Wed Aug 20 20:57:24 2014
@@ -435,16 +435,14 @@ val yFitted = (drmX %*% beta).collect(::
 <p>We hope that we could show that Mahout's shell allows people to interactively and incrementally write algorithms. We have entered a lot of individual commands, one-by-one, until we got the desired results. We can now refactor a little by wrapping our statements into easy-to-use functions. The definition of functions follows standard scala syntax. </p>
 <p>We put all the commands for ordinary least squares into a function <code>ols</code>. </p>
 <div class="codehilite"><pre>
-def ols(drmX: DrmLike[Int], y: Vector) = {
+def ols(drmX: DrmLike[Int], y: Vector) = 
+  solve(drmX.t %*% drmX, drmX.t %*% y)(::,0)
 
-  val XtX = (drmX.t %*% drmX).collect
-  val Xty = (drmX.t %*% y).collect(::, 0)
-
-  solve(XtX, Xty)
-}
 </pre></div>
 
-<p>And we define a function <code>goodnessOfFit</code> that tells how well a model fits the target variable:</p>
+<p>Note that DSL declares implicit <code>collect</code> if coersion rules require an in-core argument. Hence, we can simply
+skip explicit <code>collect</code>s. </p>
+<p>Next, we define a function <code>goodnessOfFit</code> that tells how well a model fits the target variable:</p>
 <div class="codehilite"><pre>
 def goodnessOfFit(drmX: DrmLike[Int], beta: Vector, y: Vector) = {
   val fittedY = (drmX %*% beta).collect(::, 0)