http://git-wip-us.apache.org/repos/asf/mahout/blob/5112e9ec/docs/latest/mahout-samsara/faq.html ---------------------------------------------------------------------- diff --git a/docs/latest/mahout-samsara/faq.html b/docs/latest/mahout-samsara/faq.html index 88e249e..4819bad 100644 --- a/docs/latest/mahout-samsara/faq.html +++ b/docs/latest/mahout-samsara/faq.html @@ -1,217 +1,169 @@ - - <!DOCTYPE html> -<html lang="en"> +<html lang=" en "> + <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> - <title>Mahout Samsara</title> - - <meta name="author" content="Apache Mahout"> - - <!-- Enable responsive viewport --> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <!-- Bootstrap styles --> - <link href="/assets/themes/mahout3/css/bootstrap.min.css" rel="stylesheet"> - <!-- Optional theme --> - <link href="/assets/themes/mahout3/css/bootstrap-theme.min.css" rel="stylesheet"> - <!-- Sticky Footer --> - <link href="/assets/themes/mahout3/css/bs-sticky-footer.css" rel="stylesheet"> - - <!-- Custom styles --> - <link href="/assets/themes/mahout3/css/style.css" rel="stylesheet" type="text/css" media="all"> - - <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> - <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> - <!--[if lt IE 9]> - <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> - <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> - <![endif]--> - - <!-- Fav and touch icons --> - <!-- Update these with your own images - <link rel="shortcut icon" href="images/favicon.ico"> - <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> - <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png"> - <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png"> - --> - - <!-- atom & rss feed --> - <link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Sitewide ATOM Feed"> - <link href="/rss.xml" type="application/rss+xml" rel="alternate" title="Sitewide RSS Feed"> - <script type="text/x-mathjax-config"> - MathJax.Hub.Config({ - tex2jax: { - skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'] - } - }); - MathJax.Hub.Queue(function() { - var all = MathJax.Hub.getAllJax(), i; - for(i = 0; i < all.length; i += 1) { - all[i].SourceElement().parentNode.className += ' has-jax'; - } - }); - </script> - <script type="text/javascript"> - var mathjax = document.createElement('script'); - mathjax.type = 'text/javascript'; - mathjax.async = true; - - mathjax.src = ('https:' == document.location.protocol) ? - 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' : - 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; - - var s = document.getElementsByTagName('script')[0]; - s.parentNode.insertBefore(mathjax, s); - </script> -</head> + <title> + Mahout Samsara + + </title> -<nav class="navbar navbar-default navbar-fixed-top"> - <div class="container-fluid"> - <!-- Brand and toggle get grouped for better mobile display --> - <div class="navbar-header"> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> - <span class="sr-only">Toggle navigation</span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> - <a class="navbar-brand" href="/"> - <img src="/assets/img/Mahout-logo-82x100.png" height="30" alt="I'm mahout"> - </a> - </div> + <meta name="description" content="Distributed Linear Algebra"> - + <link rel="stylesheet" href="/assets/css/main.css"> + <!-- Font Awesome --> + <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> -<!-- Collect the nav links, forms, and other content for toggling --> -<div class="collapse navbar-collapse" id="main-navbar"> - <ul class="nav navbar-nav"> - - <!-- Quick Start --> - <li id="quickstart"> - <a href="/index.html" >Mahout Overview</a> - </li> - - <li id="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Key Concepts<span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="/index.html">Mahout Overview</a></li> - <li><span><b> Scala DSL</b><span></li> - <li><a href="/mahout-samsara/in-core-reference.html">In-core Reference</a></li> - <li><a href="/mahout-samsara/out-of-core-reference.html">Out-of-core Reference</a></li> - <li><a href="/mahout-samsara/faq.html">Samsara FAQ</a></li> - <li role="separator" class="divider"></li> - <li><span> <b>Bindings</b><span></li> - <li><a href="/distributed/spark-bindings/">Spark Bindings</a></li> - <li><a href="/distributed/flink-bindings.html">Flink Bindings</a></li> - <li><a href="/distributed/flink-bindings.html">H20 Bindings</a></li> - <!--<li role="separator" class="divider"></li> - <li><span> <b>Native Solvers</b><span></li> - <li><a href="/native-solvers/viennacl.html">ViennaCL</a></li> - <li><a href="/native-solvers/viennacl-omp.html">ViennaCL-OMP</a></li> - <li><a href="/native-solvers/cuda.html">CUDA</a></li>--> - </ul> - </li> - - <li id="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Tutorials<span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><span> <b>Reccomenders</b><span></li> - <li><a href="/tutorials/cco-lastfm">CCO Example with Last.FM Data</a></li> - <li><a href="/tutorials/intro-cooccurrence-spark">Introduction to Cooccurrence in Spark</a></li> - <li role="separator" class="divider"></li> - <li><span> <b>Mahout Samsara</b><span></li> - <li><a href="/tutorials/samsara/play-with-shell.html">Playing with Samsara in Spark Shell</a></li> - <li><a href="/tutorials/samsara/playing-with-samsara-flink-batch.html">Playing with Samsara in Flink Batch</a></li> - <li><a href="/tutorials/samsara/classify-a-doc-from-the-shell.html">Text Classification (Shell)</a></li> - <li><a href="/tutorials/samsara/spark-naive-bayes.html">Spark Naive Bayes</a></li> - <li role="separator" class="divider"></li> - <li><span> <b>Misc</b><span></li> - <li><a href="/tutorials/misc/mahout-in-zeppelin">Mahout in Apache Zeppelin</a></li> - <li><a href="/tutorials/misc/contributing-algos">How To Contribute a New Algorithm</a></li> - <li><a href="/tutorials/misc/how-to-build-an-app.html">How To Build An App</a></li> - <li role="separator" class="divider"></li> - <li><span> <b>Deprecated</b><span></li> - <li><a href="/tutorials/map-reduce">MapReduce</a></li> - </ul> - </li> - - - <!-- Algorithms (Samsara / MR) --> - <li id="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Algorithms<span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="/algorithms/linear-algebra">Distributed Linear Algebra</a></li> - <li><a href="/algorithms/preprocessors">Preprocessors</a></li> - <li><a href="/algorithms/regression">Regression</a></li> - <li><a href="/algorithms/reccomenders">Reccomenders</a></li> - <li role="separator" class="divider"></li> - <li><a href="/algorithms/map-reduce">MapReduce <i>(deprecated)</i></a></li> - </ul> - <!--<li><a href="/algorithms/reccomenders/recommender-overview.html">Reccomender Overview</a></li> Do we still need? seems like short version of next post--> - <!-- - <li><a href="/algorithms/reccomenders/intro-cooccurrence-spark.html">Intro to Coocurrence With Spark</a></li> - <li role="separator" class="divider"></li> - <li><span> <a href="/algorithms/map-reduce"><b>MapReduce</b> (deprecated)</a><span></li> + <!-- Google Fonts --> + <link href="https://fonts.googleapis.com/css?family=Maven+Pro:400,500" rel="stylesheet"> + <link href="https://fonts.googleapis.com/css?family=Muli:400,400i,700,700i" rel="stylesheet"> + <link rel="canonical" href="http://mahout.apache.org//docs/latest/mahout-samsara/faq.html"> + <link rel="alternate" type="application/rss+xml" title="Apache Mahout" href="/%20/feed.xml"> - --> - </li> - <!-- Scala Docs --> - <li id="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">API Docs<span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="/0.13.0/api/index.html">0.13.0</a></li> - </ul> - </li> - - - </ul> - <form class="navbar-form navbar-left"> - <div class="form-group"> - <input type="text" class="form-control" placeholder="Search"> - </div> - <button type="submit" class="btn btn-default">Submit</button> - </form> - <ul class="nav navbar-nav navbar-right"> - <li><a href="http://github.com/apache/mahout">Github</a></li> - - <!-- Apache --> - <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Apache <span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="http://www.apache.org/foundation/how-it-works.html">Apache Software Foundation</a></li> - <li><a href="http://www.apache.org/licenses/">Apache License</a></li> - <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> - <li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li> +</head> + + +<body> + + <nav class="navbar navbar-expand-lg navbar-light bg-light navbar-mahout"> + + <div class="container"> + + <a class="navbar-brand" href="/"> + <img src="/assets/mahout-logo-blue.svg" alt=""> + </a> + + <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> + <span class="navbar-toggler-icon"></span> + </button> + + <div class="collapse navbar-collapse" id="navbarSupportedContent"> + + <div class="navbar-nav ml-auto"> + + <!-- Quick Start --> + <li class="nav-item"> + <a class="nav-link" href="//docs/latest/" >Mahout Overview</a> + </li> + + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Key Concepts</a> + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <a class="dropdown-item" href="/docs/latest/index.html">Mahout Overview</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Scala DSL</h6> + <a class="dropdown-item" href="/docs/latest/mahout-samsara/in-core-reference.html">In-core Reference</a> + <a class="dropdown-item" href="/docs/latest/mahout-samsara/out-of-core-reference.html">Out-of-core Reference</a> + <a class="dropdown-item" href="/docs/latest/mahout-samsara/faq.html">Samsara FAQ</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Distributed Engine Bindings</h6> + <a class="dropdown-item" href="/docs/latest/distributed/spark-bindings/">Spark Bindings</a> + <a class="dropdown-item" href="/docs/latest/distributed/flink-bindings.html">Flink Bindings</a> + <a class="dropdown-item" href="/docs/latest/distributed/flink-bindings.html">H20 Bindings</a> + <!--<div class="dropdown-divider"></div> + <h6 class="dropdown-header">Native Solvers</h6> + <a class="dropdown-item" href="/docs/latest/native-solvers/viennacl.html">ViennaCL</a></li> + <a class="dropdown-item" href="/docs/latest/native-solvers/viennacl-omp.html">ViennaCL-OMP</a></li> + <a class="dropdown-item" href="/docs/latest/native-solvers/cuda.html">CUDA</a></li>--> + </div> + </li> + + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Tutorial</a> + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Reccomenders</h6> + <a class="dropdown-item" href="/docs/latest/tutorials/cco-lastfm">CCO Example with Last.FM Data</a> + <a class="dropdown-item" href="/docs/latest/tutorials/intro-cooccurrence-spark">Introduction to Cooccurrence in Spark</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Mahout Samsara</h6> + <a class="dropdown-item" href="/docs/latest/tutorials/samsara/play-with-shell.html">Playing with Samsara in Spark Shell</a> + <a class="dropdown-item" href="/docs/latest/tutorials/samsara/playing-with-samsara-flink-batch.html">Playing with Samsara in Flink Batch</a> + <a class="dropdown-item" href="/docs/latest/tutorials/samsara/classify-a-doc-from-the-shell.html">Text Classification (Shell)</a> + <a class="dropdown-item" href="/docs/latest/tutorials/samsara/spark-naive-bayes.html">Spark Naive Bayes</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Misc</h6> + <a class="dropdown-item" href="/docs/latest/tutorials/misc/mahout-in-zeppelin">Mahout in Apache Zeppelin</a> + <a class="dropdown-item" href="/docs/latest/tutorials/misc/contributing-algos">How To Contribute a New Algorithm</a> + <a class="dropdown-item" href="/docs/latest/tutorials/misc/how-to-build-an-app.html">How To Build An App</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Deprecated</h6> + <a class="dropdown-item" href="/docs/latest/tutorials/map-reduce">MapReduce</a> + </div> + </li> + + + <!-- Algorithms (Samsara / MR) --> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Algorithms</a> + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <a class="dropdown-item" href="/docs/latest/algorithms/linear-algebra">Distributed Linear Algebra</a> + <a class="dropdown-item" href="/docs/latest/algorithms/preprocessors">Preprocessors</a> + <a class="dropdown-item" href="/docs/latest/algorithms/regression">Regression</a> + <a class="dropdown-item" href="/docs/latest/algorithms/reccomenders">Reccomenders</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Deprecated</h6> + <a class="dropdown-item" href="/docs/latest/algorithms/map-reduce">MapReduce <i>(deprecated)</i></a> + </div> + <!--<a class="dropdown-item" href="/docs/latest/algorithms/reccomenders/recommender-overview.html">Reccomender Overview</a></li> Do we still need? seems like short version of next post--> + <!-- + <a class="dropdown-item" href="/docs/latest/algorithms/reccomenders/intro-cooccurrence-spark.html">Intro to Coocurrence With Spark</a></li> + <li role="separator" class="divider"></li> + <li><span> <a href="/docs/latest/algorithms/map-reduce"><b>MapReduce</b> (deprecated)</a><span></li> + + + --> + </li> + + <!-- Scala /docs --> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">API /docs</a> + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <a class="dropdown-item" href="/docs/latest/0.13.0/api/index.html">0.13.0</a> + </div> + </li> + + <!-- Apache --> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Apache</a> + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <a class="dropdown-item" href="http://www.apache.org/foundation/how-it-works.html">Apache Software Foundation</a> + <a class="dropdown-item" href="http://www.apache.org/licenses/">Apache License</a> + <a class="dropdown-item" href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a> + <a class="dropdown-item" href="http://www.apache.org/foundation/thanks.html">Thanks</a> + </div> + </li> + </ul> - </li> - </ul> -</div><!-- /.navbar-collapse --> + <!--<form class="navbar-form navbar-left">--> + <!--<div class="form-group">--> + <!--<input type="text" class="form-control" placeholder="Search">--> + <!--</div>--> + <!--<button type="submit" class="btn btn-default">Submit</button>--> + <!--</form>--> + <!--<ul class="nav navbar-nav navbar-right">--> + <!--<a class="dropdown-item" href="http://github.com/apache/mahout">Github</a></li>--> - </div><!-- /.container-fluid --> -</nav> -<body> -<div id="wrap"> - <body class=""> + <!--</ul>--> + </div><!-- /.navbar-collapse --> + </div> +</nav> - <div class="container"> - + <div class="container mt-5 pb-4"> -<div class="page-header"> - <h1>Mahout Samsara </h1> -</div> + <div class="row"> -<div class="row"> - <div class="col-xs-12"> - <h1 id="faq-for-using-mahout-with-spark">FAQ for using Mahout with Spark</h1> + <div class="col-lg-8"> + <h1 id="faq-for-using-mahout-with-spark">FAQ for using Mahout with Spark</h1> <p><strong>Q: Mahout Spark shell doesnât start; âClassNotFoundâ problems or various classpath problems.</strong></p> @@ -228,10 +180,10 @@ the classpath is sane and is made available to Mahout:</p> <ol> <li>Check Spark is of correct version (same as in Mahoutâs poms), is compiled and SPARK_HOME is set.</li> <li>Check Mahout is compiled and MAHOUT_HOME is set.</li> - <li>Run <code>$SPARK_HOME/bin/compute-classpath.sh</code> and make sure it produces sane result with no errors. + <li>Run <code class="highlighter-rouge">$SPARK_HOME/bin/compute-classpath.sh</code> and make sure it produces sane result with no errors. If it outputs something other than a straightforward classpath string, most likely Spark is not compiled/set correctly (later spark versions require -<code>sbt/sbt assembly</code> to be run, simply runnig <code>sbt/sbt publish-local</code> is not enough any longer).</li> - <li>Run <code>$MAHOUT_HOME/bin/mahout -spark classpath</code> and check that path reported in step (3) is included.</li> +<code class="highlighter-rouge">sbt/sbt assembly</code> to be run, simply runnig <code class="highlighter-rouge">sbt/sbt publish-local</code> is not enough any longer).</li> + <li>Run <code class="highlighter-rouge">$MAHOUT_HOME/bin/mahout -spark classpath</code> and check that path reported in step (3) is included.</li> </ol> <p><strong>Q: I am using the command line Mahout jobs that run on Spark or am writing my own application that uses @@ -258,34 +210,26 @@ or mis-identified classes.</li> <p><strong>A:</strong> In the Mahout spark-shell the SparkContext is called âsdcâ, where the âdâ stands for distributed.</p> - </div> -</div> + </div> </div> - </div> -<div id="footer"> - <div class="container"> - <p>© 2017 Apache Mahout - with help from <a href="http://jekyllbootstrap.com" target="_blank" title="The Definitive Jekyll Blogging Framework">Jekyll Bootstrap</a> - and <a href="http://getbootstrap.com" target="_blank">Bootstrap</a> - </p> - </div> -</div> - - - - + <footer class="footer bg-light"> + <div class="container text-center small"> + Copyright © 2014-2017 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. + </div> +</footer> + <script src="/assets/vendor/jquery/jquery-slim.min.js"></script> + <script src="/assets/vendor/popper/popper.min.js"></script> + <script src="/assets/vendor/bootstrap/js/bootstrap.min.js"></script> + <script src="/assets/header.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script> -<!-- Latest compiled and minified JavaScript, requires jQuery 1.x (2.x not supported in IE8) --> -<!-- Placed at the end of the document so the pages load faster --> -<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> -<script src="/assets/themes/mahout3/js/bootstrap.min.js"></script> </body> -</html> +</html>
http://git-wip-us.apache.org/repos/asf/mahout/blob/5112e9ec/docs/latest/mahout-samsara/in-core-reference.html ---------------------------------------------------------------------- diff --git a/docs/latest/mahout-samsara/in-core-reference.html b/docs/latest/mahout-samsara/in-core-reference.html index 993c371..6ea562e 100644 --- a/docs/latest/mahout-samsara/in-core-reference.html +++ b/docs/latest/mahout-samsara/in-core-reference.html @@ -1,434 +1,422 @@ - - <!DOCTYPE html> -<html lang="en"> +<html lang=" en "> + <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> - <title>Mahout Samsara In Core</title> - - <meta name="author" content="Apache Mahout"> - - <!-- Enable responsive viewport --> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - - <!-- Bootstrap styles --> - <link href="/assets/themes/mahout3/css/bootstrap.min.css" rel="stylesheet"> - <!-- Optional theme --> - <link href="/assets/themes/mahout3/css/bootstrap-theme.min.css" rel="stylesheet"> - <!-- Sticky Footer --> - <link href="/assets/themes/mahout3/css/bs-sticky-footer.css" rel="stylesheet"> - - <!-- Custom styles --> - <link href="/assets/themes/mahout3/css/style.css" rel="stylesheet" type="text/css" media="all"> - - <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> - <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> - <!--[if lt IE 9]> - <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> - <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> - <![endif]--> - - <!-- Fav and touch icons --> - <!-- Update these with your own images - <link rel="shortcut icon" href="images/favicon.ico"> - <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> - <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png"> - <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png"> - --> - - <!-- atom & rss feed --> - <link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Sitewide ATOM Feed"> - <link href="/rss.xml" type="application/rss+xml" rel="alternate" title="Sitewide RSS Feed"> - <script type="text/x-mathjax-config"> - MathJax.Hub.Config({ - tex2jax: { - skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'] - } - }); - MathJax.Hub.Queue(function() { - var all = MathJax.Hub.getAllJax(), i; - for(i = 0; i < all.length; i += 1) { - all[i].SourceElement().parentNode.className += ' has-jax'; - } - }); - </script> - <script type="text/javascript"> - var mathjax = document.createElement('script'); - mathjax.type = 'text/javascript'; - mathjax.async = true; - - mathjax.src = ('https:' == document.location.protocol) ? - 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' : - 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; - - var s = document.getElementsByTagName('script')[0]; - s.parentNode.insertBefore(mathjax, s); - </script> -</head> + <title> + Mahout Samsara In Core + + </title> -<nav class="navbar navbar-default navbar-fixed-top"> - <div class="container-fluid"> - <!-- Brand and toggle get grouped for better mobile display --> - <div class="navbar-header"> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> - <span class="sr-only">Toggle navigation</span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> - <a class="navbar-brand" href="/"> - <img src="/assets/img/Mahout-logo-82x100.png" height="30" alt="I'm mahout"> - </a> - </div> + <meta name="description" content="Distributed Linear Algebra"> - + <link rel="stylesheet" href="/assets/css/main.css"> + <!-- Font Awesome --> + <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> -<!-- Collect the nav links, forms, and other content for toggling --> -<div class="collapse navbar-collapse" id="main-navbar"> - <ul class="nav navbar-nav"> - - <!-- Quick Start --> - <li id="quickstart"> - <a href="/index.html" >Mahout Overview</a> - </li> - - <li id="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Key Concepts<span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="/index.html">Mahout Overview</a></li> - <li><span><b> Scala DSL</b><span></li> - <li><a href="/mahout-samsara/in-core-reference.html">In-core Reference</a></li> - <li><a href="/mahout-samsara/out-of-core-reference.html">Out-of-core Reference</a></li> - <li><a href="/mahout-samsara/faq.html">Samsara FAQ</a></li> - <li role="separator" class="divider"></li> - <li><span> <b>Bindings</b><span></li> - <li><a href="/distributed/spark-bindings/">Spark Bindings</a></li> - <li><a href="/distributed/flink-bindings.html">Flink Bindings</a></li> - <li><a href="/distributed/flink-bindings.html">H20 Bindings</a></li> - <!--<li role="separator" class="divider"></li> - <li><span> <b>Native Solvers</b><span></li> - <li><a href="/native-solvers/viennacl.html">ViennaCL</a></li> - <li><a href="/native-solvers/viennacl-omp.html">ViennaCL-OMP</a></li> - <li><a href="/native-solvers/cuda.html">CUDA</a></li>--> - </ul> - </li> - - <li id="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Tutorials<span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><span> <b>Reccomenders</b><span></li> - <li><a href="/tutorials/cco-lastfm">CCO Example with Last.FM Data</a></li> - <li><a href="/tutorials/intro-cooccurrence-spark">Introduction to Cooccurrence in Spark</a></li> - <li role="separator" class="divider"></li> - <li><span> <b>Mahout Samsara</b><span></li> - <li><a href="/tutorials/samsara/play-with-shell.html">Playing with Samsara in Spark Shell</a></li> - <li><a href="/tutorials/samsara/playing-with-samsara-flink-batch.html">Playing with Samsara in Flink Batch</a></li> - <li><a href="/tutorials/samsara/classify-a-doc-from-the-shell.html">Text Classification (Shell)</a></li> - <li><a href="/tutorials/samsara/spark-naive-bayes.html">Spark Naive Bayes</a></li> - <li role="separator" class="divider"></li> - <li><span> <b>Misc</b><span></li> - <li><a href="/tutorials/misc/mahout-in-zeppelin">Mahout in Apache Zeppelin</a></li> - <li><a href="/tutorials/misc/contributing-algos">How To Contribute a New Algorithm</a></li> - <li><a href="/tutorials/misc/how-to-build-an-app.html">How To Build An App</a></li> - <li role="separator" class="divider"></li> - <li><span> <b>Deprecated</b><span></li> - <li><a href="/tutorials/map-reduce">MapReduce</a></li> - </ul> - </li> - - - <!-- Algorithms (Samsara / MR) --> - <li id="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Algorithms<span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="/algorithms/linear-algebra">Distributed Linear Algebra</a></li> - <li><a href="/algorithms/preprocessors">Preprocessors</a></li> - <li><a href="/algorithms/regression">Regression</a></li> - <li><a href="/algorithms/reccomenders">Reccomenders</a></li> - <li role="separator" class="divider"></li> - <li><a href="/algorithms/map-reduce">MapReduce <i>(deprecated)</i></a></li> - </ul> - <!--<li><a href="/algorithms/reccomenders/recommender-overview.html">Reccomender Overview</a></li> Do we still need? seems like short version of next post--> - <!-- - <li><a href="/algorithms/reccomenders/intro-cooccurrence-spark.html">Intro to Coocurrence With Spark</a></li> - <li role="separator" class="divider"></li> - <li><span> <a href="/algorithms/map-reduce"><b>MapReduce</b> (deprecated)</a><span></li> + <!-- Google Fonts --> + <link href="https://fonts.googleapis.com/css?family=Maven+Pro:400,500" rel="stylesheet"> + <link href="https://fonts.googleapis.com/css?family=Muli:400,400i,700,700i" rel="stylesheet"> + <link rel="canonical" href="http://mahout.apache.org//docs/latest/mahout-samsara/in-core-reference.html"> + <link rel="alternate" type="application/rss+xml" title="Apache Mahout" href="/%20/feed.xml"> - --> - </li> - <!-- Scala Docs --> - <li id="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">API Docs<span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="/0.13.0/api/index.html">0.13.0</a></li> - </ul> - </li> - - - </ul> - <form class="navbar-form navbar-left"> - <div class="form-group"> - <input type="text" class="form-control" placeholder="Search"> - </div> - <button type="submit" class="btn btn-default">Submit</button> - </form> - <ul class="nav navbar-nav navbar-right"> - <li><a href="http://github.com/apache/mahout">Github</a></li> - - <!-- Apache --> - <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Apache <span class="caret"></span></a> - <ul class="dropdown-menu"> - <li><a href="http://www.apache.org/foundation/how-it-works.html">Apache Software Foundation</a></li> - <li><a href="http://www.apache.org/licenses/">Apache License</a></li> - <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> - <li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li> +</head> + + +<body> + + <nav class="navbar navbar-expand-lg navbar-light bg-light navbar-mahout"> + + <div class="container"> + + <a class="navbar-brand" href="/"> + <img src="/assets/mahout-logo-blue.svg" alt=""> + </a> + + <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> + <span class="navbar-toggler-icon"></span> + </button> + + <div class="collapse navbar-collapse" id="navbarSupportedContent"> + + <div class="navbar-nav ml-auto"> + + <!-- Quick Start --> + <li class="nav-item"> + <a class="nav-link" href="//docs/latest/" >Mahout Overview</a> + </li> + + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Key Concepts</a> + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <a class="dropdown-item" href="/docs/latest/index.html">Mahout Overview</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Scala DSL</h6> + <a class="dropdown-item" href="/docs/latest/mahout-samsara/in-core-reference.html">In-core Reference</a> + <a class="dropdown-item" href="/docs/latest/mahout-samsara/out-of-core-reference.html">Out-of-core Reference</a> + <a class="dropdown-item" href="/docs/latest/mahout-samsara/faq.html">Samsara FAQ</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Distributed Engine Bindings</h6> + <a class="dropdown-item" href="/docs/latest/distributed/spark-bindings/">Spark Bindings</a> + <a class="dropdown-item" href="/docs/latest/distributed/flink-bindings.html">Flink Bindings</a> + <a class="dropdown-item" href="/docs/latest/distributed/flink-bindings.html">H20 Bindings</a> + <!--<div class="dropdown-divider"></div> + <h6 class="dropdown-header">Native Solvers</h6> + <a class="dropdown-item" href="/docs/latest/native-solvers/viennacl.html">ViennaCL</a></li> + <a class="dropdown-item" href="/docs/latest/native-solvers/viennacl-omp.html">ViennaCL-OMP</a></li> + <a class="dropdown-item" href="/docs/latest/native-solvers/cuda.html">CUDA</a></li>--> + </div> + </li> + + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Tutorial</a> + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Reccomenders</h6> + <a class="dropdown-item" href="/docs/latest/tutorials/cco-lastfm">CCO Example with Last.FM Data</a> + <a class="dropdown-item" href="/docs/latest/tutorials/intro-cooccurrence-spark">Introduction to Cooccurrence in Spark</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Mahout Samsara</h6> + <a class="dropdown-item" href="/docs/latest/tutorials/samsara/play-with-shell.html">Playing with Samsara in Spark Shell</a> + <a class="dropdown-item" href="/docs/latest/tutorials/samsara/playing-with-samsara-flink-batch.html">Playing with Samsara in Flink Batch</a> + <a class="dropdown-item" href="/docs/latest/tutorials/samsara/classify-a-doc-from-the-shell.html">Text Classification (Shell)</a> + <a class="dropdown-item" href="/docs/latest/tutorials/samsara/spark-naive-bayes.html">Spark Naive Bayes</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Misc</h6> + <a class="dropdown-item" href="/docs/latest/tutorials/misc/mahout-in-zeppelin">Mahout in Apache Zeppelin</a> + <a class="dropdown-item" href="/docs/latest/tutorials/misc/contributing-algos">How To Contribute a New Algorithm</a> + <a class="dropdown-item" href="/docs/latest/tutorials/misc/how-to-build-an-app.html">How To Build An App</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Deprecated</h6> + <a class="dropdown-item" href="/docs/latest/tutorials/map-reduce">MapReduce</a> + </div> + </li> + + + <!-- Algorithms (Samsara / MR) --> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Algorithms</a> + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <a class="dropdown-item" href="/docs/latest/algorithms/linear-algebra">Distributed Linear Algebra</a> + <a class="dropdown-item" href="/docs/latest/algorithms/preprocessors">Preprocessors</a> + <a class="dropdown-item" href="/docs/latest/algorithms/regression">Regression</a> + <a class="dropdown-item" href="/docs/latest/algorithms/reccomenders">Reccomenders</a> + <div class="dropdown-divider"></div> + <h6 class="dropdown-header">Deprecated</h6> + <a class="dropdown-item" href="/docs/latest/algorithms/map-reduce">MapReduce <i>(deprecated)</i></a> + </div> + <!--<a class="dropdown-item" href="/docs/latest/algorithms/reccomenders/recommender-overview.html">Reccomender Overview</a></li> Do we still need? seems like short version of next post--> + <!-- + <a class="dropdown-item" href="/docs/latest/algorithms/reccomenders/intro-cooccurrence-spark.html">Intro to Coocurrence With Spark</a></li> + <li role="separator" class="divider"></li> + <li><span> <a href="/docs/latest/algorithms/map-reduce"><b>MapReduce</b> (deprecated)</a><span></li> + + + --> + </li> + + <!-- Scala /docs --> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">API /docs</a> + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <a class="dropdown-item" href="/docs/latest/0.13.0/api/index.html">0.13.0</a> + </div> + </li> + + <!-- Apache --> + <li class="nav-item dropdown"> + <a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Apache</a> + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <a class="dropdown-item" href="http://www.apache.org/foundation/how-it-works.html">Apache Software Foundation</a> + <a class="dropdown-item" href="http://www.apache.org/licenses/">Apache License</a> + <a class="dropdown-item" href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a> + <a class="dropdown-item" href="http://www.apache.org/foundation/thanks.html">Thanks</a> + </div> + </li> + </ul> - </li> - </ul> -</div><!-- /.navbar-collapse --> + <!--<form class="navbar-form navbar-left">--> + <!--<div class="form-group">--> + <!--<input type="text" class="form-control" placeholder="Search">--> + <!--</div>--> + <!--<button type="submit" class="btn btn-default">Submit</button>--> + <!--</form>--> + <!--<ul class="nav navbar-nav navbar-right">--> + <!--<a class="dropdown-item" href="http://github.com/apache/mahout">Github</a></li>--> - </div><!-- /.container-fluid --> -</nav> -<body> -<div id="wrap"> - <body class=""> + <!--</ul>--> + </div><!-- /.navbar-collapse --> + </div> +</nav> - <div class="container"> - + <div class="container mt-5 pb-4"> -<div class="page-header"> - <h1>Mahout Samsara In Core </h1> -</div> + <div class="row"> -<div class="row"> - <div class="col-xs-12"> - <h2 id="mahout-samsaras-in-core-linear-algebra-dsl-reference">Mahout-Samsaraâs In-Core Linear Algebra DSL Reference</h2> + <div class="col-lg-8"> + <h2 id="mahout-samsaras-in-core-linear-algebra-dsl-reference">Mahout-Samsaraâs In-Core Linear Algebra DSL Reference</h2> <h4 id="imports">Imports</h4> <p>The following imports are used to enable Mahout-Samsaraâs Scala DSL bindings for in-core Linear Algebra:</p> -<pre><code>import org.apache.mahout.math._ +<div class="highlighter-rouge"><pre class="highlight"><code>import org.apache.mahout.math._ import scalabindings._ import RLikeOps._ </code></pre> +</div> <h4 id="inline-initalization">Inline initalization</h4> <p>Dense vectors:</p> -<pre><code>val densVec1: Vector = (1.0, 1.1, 1.2) +<div class="highlighter-rouge"><pre class="highlight"><code>val densVec1: Vector = (1.0, 1.1, 1.2) val denseVec2 = dvec(1, 0, 1,1 ,1,2) </code></pre> +</div> <p>Sparse vectors:</p> -<pre><code>val sparseVec1: Vector = (5 -> 1.0) :: (10 -> 2.0) :: Nil +<div class="highlighter-rouge"><pre class="highlight"><code>val sparseVec1: Vector = (5 -> 1.0) :: (10 -> 2.0) :: Nil val sparseVec1 = svec((5 -> 1.0) :: (10 -> 2.0) :: Nil) // to create a vector with specific cardinality val sparseVec1 = svec((5 -> 1.0) :: (10 -> 2.0) :: Nil, cardinality = 20) </code></pre> +</div> <p>Inline matrix initialization, either sparse or dense, is always done row wise.</p> <p>Dense matrices:</p> -<pre><code>val A = dense((1, 2, 3), (3, 4, 5)) +<div class="highlighter-rouge"><pre class="highlight"><code>val A = dense((1, 2, 3), (3, 4, 5)) </code></pre> +</div> <p>Sparse matrices:</p> -<pre><code>val A = sparse( +<div class="highlighter-rouge"><pre class="highlight"><code>val A = sparse( (1, 3) :: Nil, (0, 2) :: (1, 2.5) :: Nil ) </code></pre> +</div> <p>Diagonal matrix with constant diagonal elements:</p> -<pre><code>diag(3.5, 10) +<div class="highlighter-rouge"><pre class="highlight"><code>diag(3.5, 10) </code></pre> +</div> <p>Diagonal matrix with main diagonal backed by a vector:</p> -<pre><code>diagv((1, 2, 3, 4, 5)) +<div class="highlighter-rouge"><pre class="highlight"><code>diagv((1, 2, 3, 4, 5)) </code></pre> +</div> <p>Identity matrix:</p> -<pre><code>eye(10) +<div class="highlighter-rouge"><pre class="highlight"><code>eye(10) </code></pre> +</div> <p>####Slicing and Assigning</p> <p>Getting a vector element:</p> -<pre><code>val d = vec(5) +<div class="highlighter-rouge"><pre class="highlight"><code>val d = vec(5) </code></pre> +</div> <p>Setting a vector element:</p> -<pre><code>vec(5) = 3.0 +<div class="highlighter-rouge"><pre class="highlight"><code>vec(5) = 3.0 </code></pre> +</div> <p>Getting a matrix element:</p> -<pre><code>val d = m(3,5) +<div class="highlighter-rouge"><pre class="highlight"><code>val d = m(3,5) </code></pre> +</div> <p>Setting a matrix element:</p> -<pre><code>M(3,5) = 3.0 +<div class="highlighter-rouge"><pre class="highlight"><code>M(3,5) = 3.0 </code></pre> +</div> <p>Getting a matrix row or column:</p> -<pre><code>val rowVec = M(3, ::) +<div class="highlighter-rouge"><pre class="highlight"><code>val rowVec = M(3, ::) val colVec = M(::, 3) </code></pre> +</div> <p>Setting a matrix row or column via vector assignment:</p> -<pre><code>M(3, ::) := (1, 2, 3) +<div class="highlighter-rouge"><pre class="highlight"><code>M(3, ::) := (1, 2, 3) M(::, 3) := (1, 2, 3) </code></pre> +</div> <p>Setting a subslices of a matrix row or column:</p> -<pre><code>a(0, 0 to 1) = (3, 5) +<div class="highlighter-rouge"><pre class="highlight"><code>a(0, 0 to 1) = (3, 5) </code></pre> +</div> <p>Setting a subslices of a matrix row or column via vector assignment:</p> -<pre><code>a(0, 0 to 1) := (3, 5) +<div class="highlighter-rouge"><pre class="highlight"><code>a(0, 0 to 1) := (3, 5) </code></pre> +</div> <p>Getting a matrix as from matrix contiguous block:</p> -<pre><code>val B = A(2 to 3, 3 to 4) +<div class="highlighter-rouge"><pre class="highlight"><code>val B = A(2 to 3, 3 to 4) </code></pre> +</div> <p>Assigning a contiguous block to a matrix:</p> -<pre><code>A(0 to 1, 1 to 2) = dense((3, 2), (3 ,3)) +<div class="highlighter-rouge"><pre class="highlight"><code>A(0 to 1, 1 to 2) = dense((3, 2), (3 ,3)) </code></pre> +</div> <p>Assigning a contiguous block to a matrix using the matrix assignment operator:</p> -<pre><code>A(o to 1, 1 to 2) := dense((3, 2), (3, 3)) +<div class="highlighter-rouge"><pre class="highlight"><code>A(o to 1, 1 to 2) := dense((3, 2), (3, 3)) </code></pre> +</div> <p>Assignment operator used for copying between vectors or matrices:</p> -<pre><code>vec1 := vec2 +<div class="highlighter-rouge"><pre class="highlight"><code>vec1 := vec2 M1 := M2 </code></pre> +</div> <p>Assignment operator using assignment through a functional literal for a matrix:</p> -<pre><code>M := ((row, col, x) => if (row == col) 1 else 0 +<div class="highlighter-rouge"><pre class="highlight"><code>M := ((row, col, x) => if (row == col) 1 else 0 </code></pre> +</div> <p>Assignment operator using assignment through a functional literal for a vector:</p> -<pre><code>vec := ((index, x) => sqrt(x) +<div class="highlighter-rouge"><pre class="highlight"><code>vec := ((index, x) => sqrt(x) </code></pre> +</div> <h4 id="blas-like-operations">BLAS-like operations</h4> <p>Plus/minus either vector or numeric with assignment or not:</p> -<pre><code>a + b +<div class="highlighter-rouge"><pre class="highlight"><code>a + b a - b a + 5.0 a - 5.0 </code></pre> +</div> <p>Hadamard (elementwise) product, either vector or matrix or numeric operands:</p> -<pre><code>a * b +<div class="highlighter-rouge"><pre class="highlight"><code>a * b a * 0.5 </code></pre> +</div> <p>Operations with assignment:</p> -<pre><code>a += b +<div class="highlighter-rouge"><pre class="highlight"><code>a += b a -= b a += 5.0 a -= 5.0 a *= b a *= 5 </code></pre> +</div> <p><em>Some nuanced rules</em>:</p> <p>1/x in R (where x is a vector or a matrix) is elementwise inverse. In scala it would be expressed as:</p> -<pre><code>val xInv = 1 /: x +<div class="highlighter-rouge"><pre class="highlight"><code>val xInv = 1 /: x </code></pre> +</div> <p>and Râs 5.0 - x would be:</p> -<pre><code>val x1 = 5.0 -: x +<div class="highlighter-rouge"><pre class="highlight"><code>val x1 = 5.0 -: x </code></pre> +</div> <p><em>note: All assignment operations, including :=, return the assignee just like in C++</em>:</p> -<pre><code>a -= b +<div class="highlighter-rouge"><pre class="highlight"><code>a -= b </code></pre> +</div> <p>assigns <strong>a - b</strong> to <strong>b</strong> (in-place) and returns <strong>b</strong>. Similarly for <strong>a /=: b</strong> or <strong>1 /=: v</strong></p> <p>Dot product:</p> -<pre><code>a dot b +<div class="highlighter-rouge"><pre class="highlight"><code>a dot b </code></pre> +</div> <p>Matrix and vector equivalency (or non-equivalency). <strong>Dangerous, exact equivalence is rarely useful, better to use norm comparisons with an allowance of small errors.</strong></p> -<pre><code>a === b +<div class="highlighter-rouge"><pre class="highlight"><code>a === b a !== b </code></pre> +</div> <p>Matrix multiply:</p> -<pre><code>a %*% b +<div class="highlighter-rouge"><pre class="highlight"><code>a %*% b </code></pre> +</div> <p>Optimized Right Multiply with a diagonal matrix:</p> -<pre><code>diag(5, 5) :%*% b +<div class="highlighter-rouge"><pre class="highlight"><code>diag(5, 5) :%*% b </code></pre> +</div> <p>Optimized Left Multiply with a diagonal matrix:</p> -<pre><code>A %*%: diag(5, 5) +<div class="highlighter-rouge"><pre class="highlight"><code>A %*%: diag(5, 5) </code></pre> +</div> <p>Second norm, of a vector or matrix:</p> -<pre><code>a.norm +<div class="highlighter-rouge"><pre class="highlight"><code>a.norm </code></pre> +</div> <p>Transpose:</p> -<pre><code>val Mt = M.t +<div class="highlighter-rouge"><pre class="highlight"><code>val Mt = M.t </code></pre> +</div> -<p><em>note: Transposition is currently handled via view, i.e. updating a transposed matrix will be updating the original.</em> Also computing something like <code>\(\mathbf{X^\top}\mathbf{X}\)</code>:</p> +<p><em>note: Transposition is currently handled via view, i.e. updating a transposed matrix will be updating the original.</em> Also computing something like <code class="highlighter-rouge">\(\mathbf{X^\top}\mathbf{X}\)</code>:</p> -<pre><code>val XtX = X.t %*% X +<div class="highlighter-rouge"><pre class="highlight"><code>val XtX = X.t %*% X </code></pre> +</div> <p>will not therefore incur any additional data copying.</p> @@ -436,115 +424,134 @@ a !== b <p>Matrix decompositions require an additional import:</p> -<pre><code>import org.apache.mahout.math.decompositions._ +<div class="highlighter-rouge"><pre class="highlight"><code>import org.apache.mahout.math.decompositions._ </code></pre> +</div> <p>All arguments in the following are matricies.</p> <p><strong>Cholesky decomposition</strong></p> -<pre><code>val ch = chol(M) +<div class="highlighter-rouge"><pre class="highlight"><code>val ch = chol(M) </code></pre> +</div> <p><strong>SVD</strong></p> -<pre><code>val (U, V, s) = svd(M) +<div class="highlighter-rouge"><pre class="highlight"><code>val (U, V, s) = svd(M) </code></pre> +</div> <p><strong>EigenDecomposition</strong></p> -<pre><code>val (V, d) = eigen(M) +<div class="highlighter-rouge"><pre class="highlight"><code>val (V, d) = eigen(M) </code></pre> +</div> <p><strong>QR decomposition</strong></p> -<pre><code>val (Q, R) = qr(M) +<div class="highlighter-rouge"><pre class="highlight"><code>val (Q, R) = qr(M) </code></pre> +</div> <p><strong>Rank</strong>: Check for rank deficiency (runs rank-revealing QR)</p> -<pre><code>M.isFullRank +<div class="highlighter-rouge"><pre class="highlight"><code>M.isFullRank </code></pre> +</div> <p><strong>In-core SSVD</strong></p> -<pre><code>Val (U, V, s) = ssvd(A, k = 50, p = 15, q = 1) +<div class="highlighter-rouge"><pre class="highlight"><code>Val (U, V, s) = ssvd(A, k = 50, p = 15, q = 1) </code></pre> +</div> <p><strong>Solving linear equation systems and matrix inversion:</strong> fully similar to R semantics; there are three forms of invocation:</p> -<p>Solve <code>\(\mathbf{AX}=\mathbf{B}\)</code>:</p> +<p>Solve <code class="highlighter-rouge">\(\mathbf{AX}=\mathbf{B}\)</code>:</p> -<pre><code>solve(A, B) +<div class="highlighter-rouge"><pre class="highlight"><code>solve(A, B) </code></pre> +</div> -<p>Solve <code>\(\mathbf{Ax}=\mathbf{b}\)</code>:</p> +<p>Solve <code class="highlighter-rouge">\(\mathbf{Ax}=\mathbf{b}\)</code>:</p> -<pre><code>solve(A, b) +<div class="highlighter-rouge"><pre class="highlight"><code>solve(A, b) </code></pre> +</div> -<p>Compute <code>\(\mathbf{A^{-1}}\)</code>:</p> +<p>Compute <code class="highlighter-rouge">\(\mathbf{A^{-1}}\)</code>:</p> -<pre><code>solve(A) +<div class="highlighter-rouge"><pre class="highlight"><code>solve(A) </code></pre> +</div> <h4 id="misc">Misc</h4> <p>Vector cardinality:</p> -<pre><code>a.length +<div class="highlighter-rouge"><pre class="highlight"><code>a.length </code></pre> +</div> <p>Matrix cardinality:</p> -<pre><code>m.nrow +<div class="highlighter-rouge"><pre class="highlight"><code>m.nrow m.ncol </code></pre> +</div> <p>Means and sums:</p> -<pre><code>m.colSums +<div class="highlighter-rouge"><pre class="highlight"><code>m.colSums m.colMeans m.rowSums m.rowMeans </code></pre> +</div> <p>Copy-By-Value:</p> -<pre><code>val b = a cloned +<div class="highlighter-rouge"><pre class="highlight"><code>val b = a cloned </code></pre> +</div> <h4 id="random-matrices">Random Matrices</h4> -<p><code>\(\mathcal{U}\)</code>(0,1) random matrix view:</p> +<p><code class="highlighter-rouge">\(\mathcal{U}\)</code>(0,1) random matrix view:</p> -<pre><code>val incCoreA = Matrices.uniformView(m, n, seed) +<div class="highlighter-rouge"><pre class="highlight"><code>val incCoreA = Matrices.uniformView(m, n, seed) </code></pre> +</div> -<p><code>\(\mathcal{U}\)</code>(-1,1) random matrix view:</p> +<p><code class="highlighter-rouge">\(\mathcal{U}\)</code>(-1,1) random matrix view:</p> -<pre><code>val incCoreA = Matrices.symmetricUniformView(m, n, seed) +<div class="highlighter-rouge"><pre class="highlight"><code>val incCoreA = Matrices.symmetricUniformView(m, n, seed) </code></pre> +</div> -<p><code>\(\mathcal{N}\)</code>(-1,1) random matrix view:</p> +<p><code class="highlighter-rouge">\(\mathcal{N}\)</code>(-1,1) random matrix view:</p> -<pre><code>val incCoreA = Matrices.gaussianView(m, n, seed) +<div class="highlighter-rouge"><pre class="highlight"><code>val incCoreA = Matrices.gaussianView(m, n, seed) </code></pre> +</div> <h4 id="iterators">Iterators</h4> <p>Mahout-Math already exposes a number of iterators. Scala code just needs the following imports to enable implicit conversions to scala iterators.</p> -<pre><code>import collection._ +<div class="highlighter-rouge"><pre class="highlight"><code>import collection._ import JavaConversions._ </code></pre> +</div> <p>Iterating over rows in a Matrix:</p> -<pre><code>for (row <- m) { +<div class="highlighter-rouge"><pre class="highlight"><code>for (row <- m) { ... do something with row } </code></pre> +</div> <!--Iterating over non-zero and all elements of a vector: *Note that Vector.Element also has some implicit syntatic sugar, e.g to add 5.0 to every non-zero element of a matrix, the following code may be used:* @@ -559,34 +566,26 @@ Similarly **row.all** produces an iterator over all elements in a row (Vector). <p>For more information including information on Mahout-Samsaraâs out-of-core Linear algebra bindings see: <a href="http://mahout.apache.org/users/sparkbindings/ScalaSparkBindings.pdf">Mahout Scala Bindings and Mahout Spark Bindings for Linear Algebra Subroutines</a></p> - </div> -</div> + </div> </div> - -</div> - -<div id="footer"> - <div class="container"> - <p>© 2017 Apache Mahout - with help from <a href="http://jekyllbootstrap.com" target="_blank" title="The Definitive Jekyll Blogging Framework">Jekyll Bootstrap</a> - and <a href="http://getbootstrap.com" target="_blank">Bootstrap</a> - </p> - </div> </div> + <footer class="footer bg-light"> + <div class="container text-center small"> + Copyright © 2014-2017 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. + </div> +</footer> + <script src="/assets/vendor/jquery/jquery-slim.min.js"></script> + <script src="/assets/vendor/popper/popper.min.js"></script> + <script src="/assets/vendor/bootstrap/js/bootstrap.min.js"></script> + <script src="/assets/header.js"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script> - - - -<!-- Latest compiled and minified JavaScript, requires jQuery 1.x (2.x not supported in IE8) --> -<!-- Placed at the end of the document so the pages load faster --> -<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> -<script src="/assets/themes/mahout3/js/bootstrap.min.js"></script> </body> -</html> +</html>
