http://git-wip-us.apache.org/repos/asf/flink-web/blob/f0ac0cdb/content/docs/0.9/libs/ml/index.html ---------------------------------------------------------------------- diff --git a/content/docs/0.9/libs/ml/index.html b/content/docs/0.9/libs/ml/index.html deleted file mode 100644 index 9441f3e..0000000 --- a/content/docs/0.9/libs/ml/index.html +++ /dev/null @@ -1,322 +0,0 @@ -<!-- -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. ---> -<!DOCTYPE html> - -<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"> - <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> - - <title>Apache Flink 0.9.0 Documentation: FlinkML - Machine Learning for Flink</title> - - <link rel="shortcut icon" href="http://flink.apache.org/docs/0.9/page/favicon.ico" type="image/x-icon"> - <link rel="icon" href="http://flink.apache.org/docs/0.9/page/favicon.ico" type="image/x-icon"> - - <!-- Bootstrap --> - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/flink.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/syntax.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/codetabs.css"> - - <!-- HTML5 shim and Respond.js for 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/html5shiv/3.7.2/html5shiv.min.js"></script> - <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> - <![endif]--> - </head> - <body> - - - - - - - <!-- Top navbar. --> - <nav class="navbar navbar-default navbar-fixed-top"> - <div class="container"> - <!-- The logo. --> - <div class="navbar-header"> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> - <div class="navbar-logo"> - <a href="http://flink.apache.org"><img alt="Apache Flink" src="http://flink.apache.org/docs/0.9/page/img/navbar-brand-logo.jpg"></a> - </div> - </div><!-- /.navbar-header --> - - <!-- The navigation links. --> - <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> - <ul class="nav navbar-nav"> - <li><a href="http://flink.apache.org/docs/0.9/index.html">Overview<span class="hidden-sm hidden-xs"> 0.9.0</span></a></li> - - <!-- Setup --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/setup" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Setup <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/setup/building.html">Get Flink 0.9-SNAPSHOT</a></li> - - <li class="divider"></li> - <li role="presentation" class="dropdown-header"><strong>Deployment</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/local_setup.html" class="active">Local</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/cluster_setup.html">Cluster (Standalone)</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/yarn_setup.html">YARN</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/gce_setup.html">GCloud</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/flink_on_tez.html">Flink on Tez <span class="badge">Beta</span></a></li> - - <li class="divider"></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/config.html">Configuration</a></li> - </ul> - </li> - - <!-- Programming Guides --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/apis" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Programming Guides <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/apis/programming_guide.html"><strong>Batch: DataSet API</strong></a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/streaming_guide.html"><strong>Streaming: DataStream API</strong> <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/python.html">Python API <span class="badge">Beta</span></a></li> - - <li class="divider"></li> - <li><a href="scala_shell.html">Interactive Scala Shell</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/dataset_transformations.html">Dataset Transformations</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/best_practices.html">Best Practices</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/example_connectors.html">Connectors</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/examples.html">Examples</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/local_execution.html">Local Execution</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/cluster_execution.html">Cluster Execution</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/cli.html">Command Line Interface</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/web_client.html">Web Client</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/iterations.html">Iterations</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/java8.html">Java 8</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/hadoop_compatibility.html">Hadoop Compatability <span class="badge">Beta</span></a></li> - </ul> - </li> - - <!-- Libraries --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/libs" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Libraries <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/libs/spargel_guide.html">Graphs: Spargel</a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/gelly_guide.html">Graphs: Gelly <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/ml/">Machine Learning <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/table.html">Relational: Table <span class="badge">Beta</span></a></li> - </ul> - </li> - - <!-- Internals --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/internals" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Internals <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li role="presentation" class="dropdown-header"><strong>Contribute</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/how_to_contribute.html">How to Contribute</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/coding_guidelines.html">Coding Guidelines</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/ide_setup.html">IDE Setup</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/logging.html">Logging</a></li> - <li class="divider"></li> - <li role="presentation" class="dropdown-header"><strong>Internals</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/general_arch.html">Architecture & Process Model</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/types_serialization.html">Type Extraction & Serialization</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/job_scheduling.html">Jobs & Scheduling</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/add_operator.html">How-To: Add an Operator</a></li> - </ul> - </li> - </ul> - <form class="navbar-form navbar-right hidden-sm hidden-md" role="search" action="http://flink.apache.org/docs/0.9/search-results.html"> - <div class="form-group"> - <input type="text" class="form-control" name="q" placeholder="Search all pages"> - </div> - <button type="submit" class="btn btn-default">Search</button> - </form> - </div><!-- /.navbar-collapse --> - </div><!-- /.container --> - </nav> - - - - - <!-- Main content. --> - <div class="container"> - - -<div class="row"> - <div class="col-sm-10 col-sm-offset-1"> - <h1>FlinkML - Machine Learning for Flink</h1> - - - -<p>FlinkML is the Machine Learning (ML) library for Flink. It is a new effort in the Flink community, -with a growing list of algorithms and contributors. With FlinkML we aim to provide -scalable ML algorithms, an intuitive API, and tools that help minimize glue code in end-to-end ML -systems. You can see more details about our goals and where the library is headed in our <a href="vision_roadmap.html">vision -and roadmap here</a>.</p> - -<ul id="markdown-toc"> - <li><a href="#supported-algorithms" id="markdown-toc-supported-algorithms">Supported Algorithms</a> <ul> - <li><a href="#supervised-learning" id="markdown-toc-supervised-learning">Supervised Learning</a></li> - <li><a href="#data-preprocessing" id="markdown-toc-data-preprocessing">Data Preprocessing</a></li> - <li><a href="#recommendation" id="markdown-toc-recommendation">Recommendation</a></li> - <li><a href="#utilities" id="markdown-toc-utilities">Utilities</a></li> - </ul> - </li> - <li><a href="#getting-started" id="markdown-toc-getting-started">Getting Started</a></li> - <li><a href="#pipelines" id="markdown-toc-pipelines">Pipelines</a></li> - <li><a href="#how-to-contribute" id="markdown-toc-how-to-contribute">How to contribute</a></li> -</ul> - -<h2 id="supported-algorithms">Supported Algorithms</h2> - -<p>FlinkML currently supports the following algorithms:</p> - -<h3 id="supervised-learning">Supervised Learning</h3> - -<ul> - <li><a href="svm.html">SVM using Communication efficient distributed dual coordinate ascent (CoCoA)</a></li> - <li><a href="multiple_linear_regression.html">Multiple linear regression</a></li> - <li><a href="optimization.html">Optimization Framework</a></li> -</ul> - -<h3 id="data-preprocessing">Data Preprocessing</h3> - -<ul> - <li><a href="polynomial_features.html">Polynomial Features</a></li> - <li><a href="standard_scaler.html">Standard Scaler</a></li> - <li><a href="min_max_scaler.html">MinMax Scaler</a></li> -</ul> - -<h3 id="recommendation">Recommendation</h3> - -<ul> - <li><a href="als.html">Alternating Least Squares (ALS)</a></li> -</ul> - -<h3 id="utilities">Utilities</h3> - -<ul> - <li><a href="distance_metrics.html">Distance Metrics</a></li> -</ul> - -<h2 id="getting-started">Getting Started</h2> - -<p>You can check out our <a href="quickstart.html">quickstart guide</a> for a comprehensive getting started -example.</p> - -<p>If you want to jump right in, you have to <a href="http://ci.apache.org/projects/flink/flink-docs-master/apis/programming_guide.html#linking-with-flink">set up a Flink program</a>. -Next, you have to add the FlinkML dependency to the <code>pom.xml</code> of your project.</p> - -<div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt"><dependency></span> - <span class="nt"><groupId></span>org.apache.flink<span class="nt"></groupId></span> - <span class="nt"><artifactId></span>flink-ml<span class="nt"></artifactId></span> - <span class="nt"><version></span>0.9.0<span class="nt"></version></span> -<span class="nt"></dependency></span></code></pre></div> - -<p>Note that FlinkML is currently not part of the binary distribution. See linking with it for cluster execution <a href="../apis/cluster_execution.html#linking-with-modules-not-contained-in-the-binary-distribution">here</a>.</p> - -<p>Now you can start solving your analysis task. -The following code snippet shows how easy it is to train a multiple linear regression model.</p> - -<div class="highlight"><pre><code class="language-scala" data-lang="scala"><span class="c1">// LabeledVector is a feature vector with a label (class or real value)</span> -<span class="k">val</span> <span class="n">trainingData</span><span class="k">:</span> <span class="kt">DataSet</span><span class="o">[</span><span class="kt">LabeledVector</span><span class="o">]</span> <span class="k">=</span> <span class="o">...</span> -<span class="k">val</span> <span class="n">testingData</span><span class="k">:</span> <span class="kt">DataSet</span><span class="o">[</span><span class="kt">Vector</span><span class="o">]</span> <span class="k">=</span> <span class="o">...</span> - -<span class="k">val</span> <span class="n">mlr</span> <span class="k">=</span> <span class="nc">MultipleLinearRegression</span><span class="o">()</span> - <span class="o">.</span><span class="n">setStepsize</span><span class="o">(</span><span class="mf">1.0</span><span class="o">)</span> - <span class="o">.</span><span class="n">setIterations</span><span class="o">(</span><span class="mi">100</span><span class="o">)</span> - <span class="o">.</span><span class="n">setConvergenceThreshold</span><span class="o">(</span><span class="mf">0.001</span><span class="o">)</span> - -<span class="n">mlr</span><span class="o">.</span><span class="n">fit</span><span class="o">(</span><span class="n">trainingData</span><span class="o">,</span> <span class="n">parameters</span><span class="o">)</span> - -<span class="c1">// The fitted model can now be used to make predictions</span> -<span class="k">val</span> <span class="n">predictions</span><span class="k">:</span> <span class="kt">DataSet</span><span class="o">[</span><span class="kt">LabeledVector</span><span class="o">]</span> <span class="k">=</span> <span class="n">mlr</span><span class="o">.</span><span class="n">predict</span><span class="o">(</span><span class="n">testingData</span><span class="o">)</span></code></pre></div> - -<h2 id="pipelines">Pipelines</h2> - -<p>A key concept of FlinkML is its <a href="http://scikit-learn.org">scikit-learn</a> inspired pipelining mechanism. -It allows you to quickly build complex data analysis pipelines how they appear in every data scientistâs daily work. -An in-depth description of FlinkMLâs pipelines and their internal workings can be found <a href="pipelines.html">here</a>.</p> - -<p>The following example code shows how easy it is to set up an analysis pipeline with FlinkML.</p> - -<div class="highlight"><pre><code class="language-scala" data-lang="scala"><span class="k">val</span> <span class="n">trainingData</span><span class="k">:</span> <span class="kt">DataSet</span><span class="o">[</span><span class="kt">LabeledVector</span><span class="o">]</span> <span class="k">=</span> <span class="o">...</span> -<span class="k">val</span> <span class="n">testingData</span><span class="k">:</span> <span class="kt">DataSet</span><span class="o">[</span><span class="kt">Vector</span><span class="o">]</span> <span class="k">=</span> <span class="o">...</span> - -<span class="k">val</span> <span class="n">scaler</span> <span class="k">=</span> <span class="nc">StandardScaler</span><span class="o">()</span> -<span class="k">val</span> <span class="n">polyFeatures</span> <span class="k">=</span> <span class="nc">PolynomialFeatures</span><span class="o">().</span><span class="n">setDegree</span><span class="o">(</span><span class="mi">3</span><span class="o">)</span> -<span class="k">val</span> <span class="n">mlr</span> <span class="k">=</span> <span class="nc">MultipleLinearRegression</span><span class="o">()</span> - -<span class="c1">// Construct pipeline of standard scaler, polynomial features and multiple linear regression</span> -<span class="k">val</span> <span class="n">pipeline</span> <span class="k">=</span> <span class="n">scaler</span><span class="o">.</span><span class="n">chainTransformer</span><span class="o">(</span><span class="n">polyFeatures</span><span class="o">).</span><span class="n">chainPredictor</span><span class="o">(</span><span class="n">mlr</span><span class="o">)</span> - -<span class="c1">// Train pipeline</span> -<span class="n">pipeline</span><span class="o">.</span><span class="n">fit</span><span class="o">(</span><span class="n">trainingData</span><span class="o">)</span> - -<span class="c1">// Calculate predictions</span> -<span class="k">val</span> <span class="n">predictions</span><span class="k">:</span> <span class="kt">DataSet</span><span class="o">[</span><span class="kt">LabeledVector</span><span class="o">]</span> <span class="k">=</span> <span class="n">pipeline</span><span class="o">.</span><span class="n">predict</span><span class="o">(</span><span class="n">testingData</span><span class="o">)</span></code></pre></div> - -<p>One can chain a <code>Transformer</code> to another <code>Transformer</code> or a set of chained <code>Transformers</code> by calling the method <code>chainTransformer</code>. -If one wants to chain a <code>Predictor</code> to a <code>Transformer</code> or a set of chained <code>Transformers</code>, one has to call the method <code>chainPredictor</code>.</p> - -<h2 id="how-to-contribute">How to contribute</h2> - -<p>The Flink community welcomes all contributors who want to get involved in the development of Flink and its libraries. -In order to get quickly started with contributing to FlinkML, please read our official -<a href="http://flink.apache.org/docs/0.9/libs/ml/contribution_guide.html">contribution guide</a>.</p> - - </div> - - <div class="col-sm-10 col-sm-offset-1"> - <!-- Disqus thread and some vertical offset --> - <div style="margin-top: 75px; margin-bottom: 50px" id="disqus_thread"></div> - </div> -</div> - - </div><!-- /.container --> - - <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> - <!-- Include all compiled plugins (below), or include individual files as needed --> - <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> - <script src="http://flink.apache.org/docs/0.9/page/js/codetabs.js"></script> - - <!-- Google Analytics --> - <script> - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', 'UA-52545728-1', 'auto'); - ga('send', 'pageview'); - </script> - - <!-- Disqus --> - <script type="text/javascript"> - var disqus_shortname = 'stratosphere-eu'; - (function() { - var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; - dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; - (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); - })(); -</script> - </body> -</html>
http://git-wip-us.apache.org/repos/asf/flink-web/blob/f0ac0cdb/content/docs/0.9/libs/ml/min_max_scaler.html ---------------------------------------------------------------------- diff --git a/content/docs/0.9/libs/ml/min_max_scaler.html b/content/docs/0.9/libs/ml/min_max_scaler.html deleted file mode 100644 index ce4b290..0000000 --- a/content/docs/0.9/libs/ml/min_max_scaler.html +++ /dev/null @@ -1,339 +0,0 @@ -<!-- -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. ---> -<!DOCTYPE html> - -<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"> - <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> - - <title>Apache Flink 0.9.0 Documentation: FlinkML - MinMax Scaler</title> - - <link rel="shortcut icon" href="http://flink.apache.org/docs/0.9/page/favicon.ico" type="image/x-icon"> - <link rel="icon" href="http://flink.apache.org/docs/0.9/page/favicon.ico" type="image/x-icon"> - - <!-- Bootstrap --> - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/flink.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/syntax.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/codetabs.css"> - - <script type="text/x-mathjax-config"> - MathJax.Hub.Config({ - tex2jax: { - inlineMath: [['$','$'], ['\\(','\\)']] }, - TeX: { - equationNumbers: { autoNumber: "AMS" } } - }); - </script> - <script type="text/javascript" - src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> - </script> - - <!-- HTML5 shim and Respond.js for 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/html5shiv/3.7.2/html5shiv.min.js"></script> - <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> - <![endif]--> - </head> - <body> - - - - - - - <!-- Top navbar. --> - <nav class="navbar navbar-default navbar-fixed-top"> - <div class="container"> - <!-- The logo. --> - <div class="navbar-header"> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> - <div class="navbar-logo"> - <a href="http://flink.apache.org"><img alt="Apache Flink" src="http://flink.apache.org/docs/0.9/page/img/navbar-brand-logo.jpg"></a> - </div> - </div><!-- /.navbar-header --> - - <!-- The navigation links. --> - <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> - <ul class="nav navbar-nav"> - <li><a href="http://flink.apache.org/docs/0.9/index.html">Overview<span class="hidden-sm hidden-xs"> 0.9.0</span></a></li> - - <!-- Setup --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/setup" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Setup <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/setup/building.html">Get Flink 0.9-SNAPSHOT</a></li> - - <li class="divider"></li> - <li role="presentation" class="dropdown-header"><strong>Deployment</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/local_setup.html" class="active">Local</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/cluster_setup.html">Cluster (Standalone)</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/yarn_setup.html">YARN</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/gce_setup.html">GCloud</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/flink_on_tez.html">Flink on Tez <span class="badge">Beta</span></a></li> - - <li class="divider"></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/config.html">Configuration</a></li> - </ul> - </li> - - <!-- Programming Guides --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/apis" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Programming Guides <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/apis/programming_guide.html"><strong>Batch: DataSet API</strong></a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/streaming_guide.html"><strong>Streaming: DataStream API</strong> <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/python.html">Python API <span class="badge">Beta</span></a></li> - - <li class="divider"></li> - <li><a href="scala_shell.html">Interactive Scala Shell</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/dataset_transformations.html">Dataset Transformations</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/best_practices.html">Best Practices</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/example_connectors.html">Connectors</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/examples.html">Examples</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/local_execution.html">Local Execution</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/cluster_execution.html">Cluster Execution</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/cli.html">Command Line Interface</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/web_client.html">Web Client</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/iterations.html">Iterations</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/java8.html">Java 8</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/hadoop_compatibility.html">Hadoop Compatability <span class="badge">Beta</span></a></li> - </ul> - </li> - - <!-- Libraries --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/libs" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Libraries <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/libs/spargel_guide.html">Graphs: Spargel</a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/gelly_guide.html">Graphs: Gelly <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/ml/">Machine Learning <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/table.html">Relational: Table <span class="badge">Beta</span></a></li> - </ul> - </li> - - <!-- Internals --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/internals" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Internals <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li role="presentation" class="dropdown-header"><strong>Contribute</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/how_to_contribute.html">How to Contribute</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/coding_guidelines.html">Coding Guidelines</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/ide_setup.html">IDE Setup</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/logging.html">Logging</a></li> - <li class="divider"></li> - <li role="presentation" class="dropdown-header"><strong>Internals</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/general_arch.html">Architecture & Process Model</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/types_serialization.html">Type Extraction & Serialization</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/job_scheduling.html">Jobs & Scheduling</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/add_operator.html">How-To: Add an Operator</a></li> - </ul> - </li> - </ul> - <form class="navbar-form navbar-right hidden-sm hidden-md" role="search" action="http://flink.apache.org/docs/0.9/search-results.html"> - <div class="form-group"> - <input type="text" class="form-control" name="q" placeholder="Search all pages"> - </div> - <button type="submit" class="btn btn-default">Search</button> - </form> - </div><!-- /.navbar-collapse --> - </div><!-- /.container --> - </nav> - - - - - -<!--Some of the Latex math notation has been adapted from Apache Spark MLlib's documentation--> -$$ -\newcommand{\R}{\mathbb{R}} -\newcommand{\E}{\mathbb{E}} -\newcommand{\x}{\mathbf{x}} -\newcommand{\y}{\mathbf{y}} -\newcommand{\wv}{\mathbf{w}} -\newcommand{\av}{\mathbf{\alpha}} -\newcommand{\bv}{\mathbf{b}} -\newcommand{\N}{\mathbb{N}} -\newcommand{\id}{\mathbf{I}} -\newcommand{\ind}{\mathbf{1}} -\newcommand{\0}{\mathbf{0}} -\newcommand{\unit}{\mathbf{e}} -\newcommand{\one}{\mathbf{1}} -\newcommand{\zero}{\mathbf{0}} -\newcommand\rfrac[2]{^{#1}\!/_{#2}} -\newcommand{\norm}[1]{\left\lVert#1\right\rVert} -$$ - - - <!-- Main content. --> - <div class="container"> - - -<div class="row"> - <div class="col-sm-10 col-sm-offset-1"> - <h1><a href="../ml">FlinkML</a> - MinMax Scaler</h1> - - - -<ul id="markdown-toc"> - <li><a href="#description" id="markdown-toc-description">Description</a></li> - <li><a href="#operations" id="markdown-toc-operations">Operations</a> <ul> - <li><a href="#fit" id="markdown-toc-fit">Fit</a></li> - <li><a href="#transform" id="markdown-toc-transform">Transform</a></li> - </ul> - </li> - <li><a href="#parameters" id="markdown-toc-parameters">Parameters</a></li> - <li><a href="#examples" id="markdown-toc-examples">Examples</a></li> -</ul> - -<h2 id="description">Description</h2> - -<p>The MinMax scaler scales the given data set, so that all values will lie between a user specified range [min,max]. - In case the user does not provide a specific minimum and maximum value for the scaling range, the MinMax scaler transforms the features of the input data set to lie in the [0,1] interval. - Given a set of input data $x_1, x_2,⦠x_n$, with minimum value:</p> - -<script type="math/tex; mode=display">x_{min} = min({x_1, x_2,..., x_n})</script> - -<p>and maximum value:</p> - -<script type="math/tex; mode=display">x_{max} = max({x_1, x_2,..., x_n})</script> - -<p>The scaled data set $z_1, z_2,â¦,z_n$ will be:</p> - -<script type="math/tex; mode=display">z_{i}= \frac{x_{i} - x_{min}}{x_{max} - x_{min}} \left ( max - min \right ) + min</script> - -<p>where $\textit{min}$ and $\textit{max}$ are the user specified minimum and maximum values of the range to scale.</p> - -<h2 id="operations">Operations</h2> - -<p><code>MinMaxScaler</code> is a <code>Transformer</code>. -As such, it supports the <code>fit</code> and <code>transform</code> operation.</p> - -<h3 id="fit">Fit</h3> - -<p>MinMaxScaler is trained on all subtypes of <code>Vector</code> or <code>LabeledVector</code>:</p> - -<ul> - <li><code>fit[T <: Vector]: DataSet[T] => Unit</code></li> - <li><code>fit: DataSet[LabeledVector] => Unit</code></li> -</ul> - -<h3 id="transform">Transform</h3> - -<p>MinMaxScaler transforms all subtypes of <code>Vector</code> or <code>LabeledVector</code> into the respective type:</p> - -<ul> - <li><code>transform[T <: Vector]: DataSet[T] => DataSet[T]</code></li> - <li><code>transform: DataSet[LabeledVector] => DataSet[LabeledVector]</code></li> -</ul> - -<h2 id="parameters">Parameters</h2> - -<p>The MinMax scaler implementation can be controlled by the following two parameters:</p> - -<table class="table table-bordered"> - <thead> - <tr> - <th class="text-left" style="width: 20%">Parameters</th> - <th class="text-center">Description</th> - </tr> - </thead> - - <tbody> - <tr> - <td><strong>Min</strong></td> - <td> - <p> - The minimum value of the range for the scaled data set. (Default value: <strong>0.0</strong>) - </p> - </td> - </tr> - <tr> - <td><strong>Max</strong></td> - <td> - <p> - The maximum value of the range for the scaled data set. (Default value: <strong>1.0</strong>) - </p> - </td> - </tr> - </tbody> -</table> - -<h2 id="examples">Examples</h2> - -<div class="highlight"><pre><code class="language-scala" data-lang="scala"><span class="c1">// Create MinMax scaler transformer</span> -<span class="k">val</span> <span class="n">minMaxscaler</span> <span class="k">=</span> <span class="nc">MinMaxScaler</span><span class="o">()</span> - <span class="o">.</span><span class="n">setMin</span><span class="o">(-</span><span class="mf">1.0</span><span class="o">)</span> - -<span class="c1">// Obtain data set to be scaled</span> -<span class="k">val</span> <span class="n">dataSet</span><span class="k">:</span> <span class="kt">DataSet</span><span class="o">[</span><span class="kt">Vector</span><span class="o">]</span> <span class="k">=</span> <span class="o">...</span> - -<span class="c1">// Learn the minimum and maximum values of the training data</span> -<span class="n">minMaxscaler</span><span class="o">.</span><span class="n">fit</span><span class="o">(</span><span class="n">dataSet</span><span class="o">)</span> - -<span class="c1">// Scale the provided data set to have min=-1.0 and max=1.0</span> -<span class="k">val</span> <span class="n">scaledDS</span> <span class="k">=</span> <span class="n">minMaxscaler</span><span class="o">.</span><span class="n">transform</span><span class="o">(</span><span class="n">dataSet</span><span class="o">)</span></code></pre></div> - - - </div> - - <div class="col-sm-10 col-sm-offset-1"> - <!-- Disqus thread and some vertical offset --> - <div style="margin-top: 75px; margin-bottom: 50px" id="disqus_thread"></div> - </div> -</div> - - </div><!-- /.container --> - - <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> - <!-- Include all compiled plugins (below), or include individual files as needed --> - <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> - <script src="http://flink.apache.org/docs/0.9/page/js/codetabs.js"></script> - - <!-- Google Analytics --> - <script> - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', 'UA-52545728-1', 'auto'); - ga('send', 'pageview'); - </script> - - <!-- Disqus --> - <script type="text/javascript"> - var disqus_shortname = 'stratosphere-eu'; - (function() { - var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; - dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; - (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); - })(); -</script> - </body> -</html> http://git-wip-us.apache.org/repos/asf/flink-web/blob/f0ac0cdb/content/docs/0.9/libs/ml/multiple_linear_regression.html ---------------------------------------------------------------------- diff --git a/content/docs/0.9/libs/ml/multiple_linear_regression.html b/content/docs/0.9/libs/ml/multiple_linear_regression.html deleted file mode 100644 index b4e8f29..0000000 --- a/content/docs/0.9/libs/ml/multiple_linear_regression.html +++ /dev/null @@ -1,380 +0,0 @@ -<!-- -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. ---> -<!DOCTYPE html> - -<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"> - <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> - - <title>Apache Flink 0.9.0 Documentation: FlinkML - Multiple linear regression</title> - - <link rel="shortcut icon" href="http://flink.apache.org/docs/0.9/page/favicon.ico" type="image/x-icon"> - <link rel="icon" href="http://flink.apache.org/docs/0.9/page/favicon.ico" type="image/x-icon"> - - <!-- Bootstrap --> - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/flink.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/syntax.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/codetabs.css"> - - <script type="text/x-mathjax-config"> - MathJax.Hub.Config({ - tex2jax: { - inlineMath: [['$','$'], ['\\(','\\)']] }, - TeX: { - equationNumbers: { autoNumber: "AMS" } } - }); - </script> - <script type="text/javascript" - src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> - </script> - - <!-- HTML5 shim and Respond.js for 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/html5shiv/3.7.2/html5shiv.min.js"></script> - <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> - <![endif]--> - </head> - <body> - - - - - - - <!-- Top navbar. --> - <nav class="navbar navbar-default navbar-fixed-top"> - <div class="container"> - <!-- The logo. --> - <div class="navbar-header"> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> - <div class="navbar-logo"> - <a href="http://flink.apache.org"><img alt="Apache Flink" src="http://flink.apache.org/docs/0.9/page/img/navbar-brand-logo.jpg"></a> - </div> - </div><!-- /.navbar-header --> - - <!-- The navigation links. --> - <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> - <ul class="nav navbar-nav"> - <li><a href="http://flink.apache.org/docs/0.9/index.html">Overview<span class="hidden-sm hidden-xs"> 0.9.0</span></a></li> - - <!-- Setup --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/setup" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Setup <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/setup/building.html">Get Flink 0.9-SNAPSHOT</a></li> - - <li class="divider"></li> - <li role="presentation" class="dropdown-header"><strong>Deployment</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/local_setup.html" class="active">Local</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/cluster_setup.html">Cluster (Standalone)</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/yarn_setup.html">YARN</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/gce_setup.html">GCloud</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/flink_on_tez.html">Flink on Tez <span class="badge">Beta</span></a></li> - - <li class="divider"></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/config.html">Configuration</a></li> - </ul> - </li> - - <!-- Programming Guides --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/apis" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Programming Guides <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/apis/programming_guide.html"><strong>Batch: DataSet API</strong></a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/streaming_guide.html"><strong>Streaming: DataStream API</strong> <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/python.html">Python API <span class="badge">Beta</span></a></li> - - <li class="divider"></li> - <li><a href="scala_shell.html">Interactive Scala Shell</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/dataset_transformations.html">Dataset Transformations</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/best_practices.html">Best Practices</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/example_connectors.html">Connectors</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/examples.html">Examples</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/local_execution.html">Local Execution</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/cluster_execution.html">Cluster Execution</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/cli.html">Command Line Interface</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/web_client.html">Web Client</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/iterations.html">Iterations</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/java8.html">Java 8</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/hadoop_compatibility.html">Hadoop Compatability <span class="badge">Beta</span></a></li> - </ul> - </li> - - <!-- Libraries --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/libs" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Libraries <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/libs/spargel_guide.html">Graphs: Spargel</a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/gelly_guide.html">Graphs: Gelly <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/ml/">Machine Learning <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/table.html">Relational: Table <span class="badge">Beta</span></a></li> - </ul> - </li> - - <!-- Internals --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/internals" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Internals <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li role="presentation" class="dropdown-header"><strong>Contribute</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/how_to_contribute.html">How to Contribute</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/coding_guidelines.html">Coding Guidelines</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/ide_setup.html">IDE Setup</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/logging.html">Logging</a></li> - <li class="divider"></li> - <li role="presentation" class="dropdown-header"><strong>Internals</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/general_arch.html">Architecture & Process Model</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/types_serialization.html">Type Extraction & Serialization</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/job_scheduling.html">Jobs & Scheduling</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/add_operator.html">How-To: Add an Operator</a></li> - </ul> - </li> - </ul> - <form class="navbar-form navbar-right hidden-sm hidden-md" role="search" action="http://flink.apache.org/docs/0.9/search-results.html"> - <div class="form-group"> - <input type="text" class="form-control" name="q" placeholder="Search all pages"> - </div> - <button type="submit" class="btn btn-default">Search</button> - </form> - </div><!-- /.navbar-collapse --> - </div><!-- /.container --> - </nav> - - - - - -<!--Some of the Latex math notation has been adapted from Apache Spark MLlib's documentation--> -$$ -\newcommand{\R}{\mathbb{R}} -\newcommand{\E}{\mathbb{E}} -\newcommand{\x}{\mathbf{x}} -\newcommand{\y}{\mathbf{y}} -\newcommand{\wv}{\mathbf{w}} -\newcommand{\av}{\mathbf{\alpha}} -\newcommand{\bv}{\mathbf{b}} -\newcommand{\N}{\mathbb{N}} -\newcommand{\id}{\mathbf{I}} -\newcommand{\ind}{\mathbf{1}} -\newcommand{\0}{\mathbf{0}} -\newcommand{\unit}{\mathbf{e}} -\newcommand{\one}{\mathbf{1}} -\newcommand{\zero}{\mathbf{0}} -\newcommand\rfrac[2]{^{#1}\!/_{#2}} -\newcommand{\norm}[1]{\left\lVert#1\right\rVert} -$$ - - - <!-- Main content. --> - <div class="container"> - - -<div class="row"> - <div class="col-sm-10 col-sm-offset-1"> - <h1><a href="../ml">FlinkML</a> - Multiple linear regression</h1> - - - -<ul id="markdown-toc"> - <li><a href="#description" id="markdown-toc-description">Description</a></li> - <li><a href="#operations" id="markdown-toc-operations">Operations</a> <ul> - <li><a href="#fit" id="markdown-toc-fit">Fit</a></li> - <li><a href="#predict" id="markdown-toc-predict">Predict</a></li> - </ul> - </li> - <li><a href="#parameters" id="markdown-toc-parameters">Parameters</a></li> - <li><a href="#examples" id="markdown-toc-examples">Examples</a></li> -</ul> - -<h2 id="description">Description</h2> - -<p>Multiple linear regression tries to find a linear function which best fits the provided input data. - Given a set of input data with its value $(\mathbf{x}, y)$, multiple linear regression finds - a vector $\mathbf{w}$ such that the sum of the squared residuals is minimized:</p> - -<script type="math/tex; mode=display">S(\mathbf{w}) = \sum_{i=1} \left(y - \mathbf{w}^T\mathbf{x_i} \right)^2</script> - -<p>Written in matrix notation, we obtain the following formulation:</p> - -<script type="math/tex; mode=display">\mathbf{w}^* = \arg \min_{\mathbf{w}} (\mathbf{y} - X\mathbf{w})^2</script> - -<p>This problem has a closed form solution which is given by:</p> - -<script type="math/tex; mode=display">\mathbf{w}^* = \left(X^TX\right)^{-1}X^T\mathbf{y}</script> - -<p>However, in cases where the input data set is so huge that a complete parse over the whole data - set is prohibitive, one can apply stochastic gradient descent (SGD) to approximate the solution. - SGD first calculates for a random subset of the input data set the gradients. The gradient - for a given point $\mathbf{x}_i$ is given by:</p> - -<script type="math/tex; mode=display">\nabla_{\mathbf{w}} S(\mathbf{w}, \mathbf{x_i}) = 2\left(\mathbf{w}^T\mathbf{x_i} - - y\right)\mathbf{x_i}</script> - -<p>The gradients are averaged and scaled. The scaling is defined by $\gamma = \frac{s}{\sqrt{j}}$ - with $s$ being the initial step size and $j$ being the current iteration number. The resulting gradient is subtracted from the - current weight vector giving the new weight vector for the next iteration:</p> - -<script type="math/tex; mode=display">\mathbf{w}_{t+1} = \mathbf{w}_t - \gamma \frac{1}{n}\sum_{i=1}^n \nabla_{\mathbf{w}} S(\mathbf{w}, \mathbf{x_i})</script> - -<p>The multiple linear regression algorithm computes either a fixed number of SGD iterations or terminates based on a dynamic convergence criterion. - The convergence criterion is the relative change in the sum of squared residuals:</p> - -<script type="math/tex; mode=display">% <![CDATA[ -\frac{S_{k-1} - S_k}{S_{k-1}} < \rho %]]></script> - -<h2 id="operations">Operations</h2> - -<p><code>MultipleLinearRegression</code> is a <code>Predictor</code>. -As such, it supports the <code>fit</code> and <code>predict</code> operation.</p> - -<h3 id="fit">Fit</h3> - -<p>MultipleLinearRegression is trained on a set of <code>LabeledVector</code>:</p> - -<ul> - <li><code>fit: DataSet[LabeledVector] => Unit</code></li> -</ul> - -<h3 id="predict">Predict</h3> - -<p>MultipleLinearRegression predicts for all subtypes of <code>Vector</code> the corresponding regression value:</p> - -<ul> - <li><code>predict[T <: Vector]: DataSet[T] => DataSet[LabeledVector]</code></li> -</ul> - -<p>If we call predict with a <code>DataSet[LabeledVector]</code>, we make a prediction on the regression value -for each example, and return a <code>DataSet[(Double, Double)]</code>. In each tuple the first element -is the true value, as was provided from the input <code>DataSet[LabeledVector]</code> and the second element -is the predicted value. You can then use these <code>(truth, prediction)</code> tuples to evaluate -the algorithmâs performance.</p> - -<ul> - <li><code>predict: DataSet[LabeledVector] => DataSet[(Double, Double)]</code></li> -</ul> - -<h2 id="parameters">Parameters</h2> - -<p>The multiple linear regression implementation can be controlled by the following parameters:</p> - -<table class="table table-bordered"> - <thead> - <tr> - <th class="text-left" style="width: 20%">Parameters</th> - <th class="text-center">Description</th> - </tr> - </thead> - - <tbody> - <tr> - <td><strong>Iterations</strong></td> - <td> - <p> - The maximum number of iterations. (Default value: <strong>10</strong>) - </p> - </td> - </tr> - <tr> - <td><strong>Stepsize</strong></td> - <td> - <p> - Initial step size for the gradient descent method. - This value controls how far the gradient descent method moves in the opposite direction of the gradient. - Tuning this parameter might be crucial to make it stable and to obtain a better performance. - (Default value: <strong>0.1</strong>) - </p> - </td> - </tr> - <tr> - <td><strong>ConvergenceThreshold</strong></td> - <td> - <p> - Threshold for relative change of the sum of squared residuals until the iteration is stopped. - (Default value: <strong>None</strong>) - </p> - </td> - </tr> - </tbody> - </table> - -<h2 id="examples">Examples</h2> - -<div class="highlight"><pre><code class="language-scala" data-lang="scala"><span class="c1">// Create multiple linear regression learner</span> -<span class="k">val</span> <span class="n">mlr</span> <span class="k">=</span> <span class="nc">MultipleLinearRegression</span><span class="o">()</span> -<span class="o">.</span><span class="n">setIterations</span><span class="o">(</span><span class="mi">10</span><span class="o">)</span> -<span class="o">.</span><span class="n">setStepsize</span><span class="o">(</span><span class="mf">0.5</span><span class="o">)</span> -<span class="o">.</span><span class="n">setConvergenceThreshold</span><span class="o">(</span><span class="mf">0.001</span><span class="o">)</span> - -<span class="c1">// Obtain training and testing data set</span> -<span class="k">val</span> <span class="n">trainingDS</span><span class="k">:</span> <span class="kt">DataSet</span><span class="o">[</span><span class="kt">LabeledVector</span><span class="o">]</span> <span class="k">=</span> <span class="o">...</span> -<span class="k">val</span> <span class="n">testingDS</span><span class="k">:</span> <span class="kt">DataSet</span><span class="o">[</span><span class="kt">Vector</span><span class="o">]</span> <span class="k">=</span> <span class="o">...</span> - -<span class="c1">// Fit the linear model to the provided data</span> -<span class="n">mlr</span><span class="o">.</span><span class="n">fit</span><span class="o">(</span><span class="n">trainingDS</span><span class="o">)</span> - -<span class="c1">// Calculate the predictions for the test data</span> -<span class="k">val</span> <span class="n">predictions</span> <span class="k">=</span> <span class="n">mlr</span><span class="o">.</span><span class="n">predict</span><span class="o">(</span><span class="n">testingDS</span><span class="o">)</span></code></pre></div> - - - </div> - - <div class="col-sm-10 col-sm-offset-1"> - <!-- Disqus thread and some vertical offset --> - <div style="margin-top: 75px; margin-bottom: 50px" id="disqus_thread"></div> - </div> -</div> - - </div><!-- /.container --> - - <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> - <!-- Include all compiled plugins (below), or include individual files as needed --> - <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> - <script src="http://flink.apache.org/docs/0.9/page/js/codetabs.js"></script> - - <!-- Google Analytics --> - <script> - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', 'UA-52545728-1', 'auto'); - ga('send', 'pageview'); - </script> - - <!-- Disqus --> - <script type="text/javascript"> - var disqus_shortname = 'stratosphere-eu'; - (function() { - var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; - dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; - (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); - })(); -</script> - </body> -</html> http://git-wip-us.apache.org/repos/asf/flink-web/blob/f0ac0cdb/content/docs/0.9/libs/ml/optimization.html ---------------------------------------------------------------------- diff --git a/content/docs/0.9/libs/ml/optimization.html b/content/docs/0.9/libs/ml/optimization.html deleted file mode 100644 index bdec003..0000000 --- a/content/docs/0.9/libs/ml/optimization.html +++ /dev/null @@ -1,513 +0,0 @@ -<!-- -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. ---> -<!DOCTYPE html> - -<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"> - <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> - - <title>Apache Flink 0.9.0 Documentation: FlinkML - Optimization</title> - - <link rel="shortcut icon" href="http://flink.apache.org/docs/0.9/page/favicon.ico" type="image/x-icon"> - <link rel="icon" href="http://flink.apache.org/docs/0.9/page/favicon.ico" type="image/x-icon"> - - <!-- Bootstrap --> - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/flink.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/syntax.css"> - <link rel="stylesheet" href="http://flink.apache.org/docs/0.9/page/css/codetabs.css"> - - <script type="text/x-mathjax-config"> - MathJax.Hub.Config({ - tex2jax: { - inlineMath: [['$','$'], ['\\(','\\)']] }, - TeX: { - equationNumbers: { autoNumber: "AMS" } } - }); - </script> - <script type="text/javascript" - src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> - </script> - - <!-- HTML5 shim and Respond.js for 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/html5shiv/3.7.2/html5shiv.min.js"></script> - <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> - <![endif]--> - </head> - <body> - - - - - - - <!-- Top navbar. --> - <nav class="navbar navbar-default navbar-fixed-top"> - <div class="container"> - <!-- The logo. --> - <div class="navbar-header"> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> - <div class="navbar-logo"> - <a href="http://flink.apache.org"><img alt="Apache Flink" src="http://flink.apache.org/docs/0.9/page/img/navbar-brand-logo.jpg"></a> - </div> - </div><!-- /.navbar-header --> - - <!-- The navigation links. --> - <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> - <ul class="nav navbar-nav"> - <li><a href="http://flink.apache.org/docs/0.9/index.html">Overview<span class="hidden-sm hidden-xs"> 0.9.0</span></a></li> - - <!-- Setup --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/setup" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Setup <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/setup/building.html">Get Flink 0.9-SNAPSHOT</a></li> - - <li class="divider"></li> - <li role="presentation" class="dropdown-header"><strong>Deployment</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/local_setup.html" class="active">Local</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/cluster_setup.html">Cluster (Standalone)</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/yarn_setup.html">YARN</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/gce_setup.html">GCloud</a></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/flink_on_tez.html">Flink on Tez <span class="badge">Beta</span></a></li> - - <li class="divider"></li> - <li><a href="http://flink.apache.org/docs/0.9/setup/config.html">Configuration</a></li> - </ul> - </li> - - <!-- Programming Guides --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/apis" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Programming Guides <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/apis/programming_guide.html"><strong>Batch: DataSet API</strong></a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/streaming_guide.html"><strong>Streaming: DataStream API</strong> <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/python.html">Python API <span class="badge">Beta</span></a></li> - - <li class="divider"></li> - <li><a href="scala_shell.html">Interactive Scala Shell</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/dataset_transformations.html">Dataset Transformations</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/best_practices.html">Best Practices</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/example_connectors.html">Connectors</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/examples.html">Examples</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/local_execution.html">Local Execution</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/cluster_execution.html">Cluster Execution</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/cli.html">Command Line Interface</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/web_client.html">Web Client</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/iterations.html">Iterations</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/java8.html">Java 8</a></li> - <li><a href="http://flink.apache.org/docs/0.9/apis/hadoop_compatibility.html">Hadoop Compatability <span class="badge">Beta</span></a></li> - </ul> - </li> - - <!-- Libraries --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/libs" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Libraries <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li><a href="http://flink.apache.org/docs/0.9/libs/spargel_guide.html">Graphs: Spargel</a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/gelly_guide.html">Graphs: Gelly <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/ml/">Machine Learning <span class="badge">Beta</span></a></li> - <li><a href="http://flink.apache.org/docs/0.9/libs/table.html">Relational: Table <span class="badge">Beta</span></a></li> - </ul> - </li> - - <!-- Internals --> - <li class="dropdown"> - <a href="http://flink.apache.org/docs/0.9/internals" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Internals <span class="caret"></span></a> - <ul class="dropdown-menu" role="menu"> - <li role="presentation" class="dropdown-header"><strong>Contribute</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/how_to_contribute.html">How to Contribute</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/coding_guidelines.html">Coding Guidelines</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/ide_setup.html">IDE Setup</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/logging.html">Logging</a></li> - <li class="divider"></li> - <li role="presentation" class="dropdown-header"><strong>Internals</strong></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/general_arch.html">Architecture & Process Model</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/types_serialization.html">Type Extraction & Serialization</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/job_scheduling.html">Jobs & Scheduling</a></li> - <li><a href="http://flink.apache.org/docs/0.9/internals/add_operator.html">How-To: Add an Operator</a></li> - </ul> - </li> - </ul> - <form class="navbar-form navbar-right hidden-sm hidden-md" role="search" action="http://flink.apache.org/docs/0.9/search-results.html"> - <div class="form-group"> - <input type="text" class="form-control" name="q" placeholder="Search all pages"> - </div> - <button type="submit" class="btn btn-default">Search</button> - </form> - </div><!-- /.navbar-collapse --> - </div><!-- /.container --> - </nav> - - - - - -<!--Some of the Latex math notation has been adapted from Apache Spark MLlib's documentation--> -$$ -\newcommand{\R}{\mathbb{R}} -\newcommand{\E}{\mathbb{E}} -\newcommand{\x}{\mathbf{x}} -\newcommand{\y}{\mathbf{y}} -\newcommand{\wv}{\mathbf{w}} -\newcommand{\av}{\mathbf{\alpha}} -\newcommand{\bv}{\mathbf{b}} -\newcommand{\N}{\mathbb{N}} -\newcommand{\id}{\mathbf{I}} -\newcommand{\ind}{\mathbf{1}} -\newcommand{\0}{\mathbf{0}} -\newcommand{\unit}{\mathbf{e}} -\newcommand{\one}{\mathbf{1}} -\newcommand{\zero}{\mathbf{0}} -\newcommand\rfrac[2]{^{#1}\!/_{#2}} -\newcommand{\norm}[1]{\left\lVert#1\right\rVert} -$$ - - - <!-- Main content. --> - <div class="container"> - - -<div class="row"> - <div class="col-sm-10 col-sm-offset-1"> - <h1><a href="../ml">FlinkML</a> - Optimization</h1> - - - -<ul id="markdown-toc"> - <li><a href="#mathematical-formulation" id="markdown-toc-mathematical-formulation">Mathematical Formulation</a> <ul> - <li><a href="#loss-functions" id="markdown-toc-loss-functions">Loss Functions</a></li> - <li><a href="#regularization-types" id="markdown-toc-regularization-types">Regularization Types</a></li> - </ul> - </li> - <li><a href="#stochastic-gradient-descent" id="markdown-toc-stochastic-gradient-descent">Stochastic Gradient Descent</a> <ul> - <li><a href="#regularization" id="markdown-toc-regularization">Regularization</a></li> - <li><a href="#parameters" id="markdown-toc-parameters">Parameters</a></li> - <li><a href="#loss-function" id="markdown-toc-loss-function">Loss Function</a></li> - <li><a href="#examples" id="markdown-toc-examples">Examples</a></li> - </ul> - </li> -</ul> - -<h2 id="mathematical-formulation">Mathematical Formulation</h2> - -<p>The optimization framework in FlinkML is a developer-oriented package that can be used to solve -<a href="https://en.wikipedia.org/wiki/Mathematical_optimization">optimization</a> -problems common in Machine Learning (ML) tasks. In the supervised learning context, this usually -involves finding a model, as defined by a set of parameters $w$, that minimize a function $f(\wv)$ -given a set of $(\x, y)$ examples, -where $\x$ is a feature vector and $y$ is a real number, which can represent either a real value in -the regression case, or a class label in the classification case. In supervised learning, the -function to be minimized is usually of the form:</p> - -<p>\begin{equation} \label{eq:objectiveFunc} - f(\wv) := - \frac1n \sum_{i=1}^n L(\wv;\x_i,y_i) + - \lambda\, R(\wv) - \ . -\end{equation}</p> - -<p>where $L$ is the loss function and $R(\wv)$ the regularization penalty. We use $L$ to measure how -well the model fits the observed data, and we use $R$ in order to impose a complexity cost to the -model, with $\lambda > 0$ being the regularization parameter.</p> - -<h3 id="loss-functions">Loss Functions</h3> - -<p>In supervised learning, we use loss functions in order to measure the model fit, by -penalizing errors in the predictions $p$ made by the model compared to the true $y$ for each -example. Different loss functions can be used for regression (e.g. Squared Loss) and classification -(e.g. Hinge Loss) tasks.</p> - -<p>Some common loss functions are:</p> - -<ul> - <li>Squared Loss: $ \frac{1}{2} \left(\wv^T \cdot \x - y\right)^2, \quad y \in \R $</li> - <li>Hinge Loss: $ \max \left(0, 1 - y ~ \wv^T \cdot \x\right), \quad y \in {-1, +1} $</li> - <li>Logistic Loss: $ \log\left(1+\exp\left( -y ~ \wv^T \cdot \x\right)\right), \quad y \in {-1, +1}$</li> -</ul> - -<h3 id="regularization-types">Regularization Types</h3> - -<p><a href="https://en.wikipedia.org/wiki/Regularization_(mathematics)">Regularization</a> in machine learning -imposes penalties to the estimated models, in order to reduce overfitting. The most common penalties -are the $L_1$ and $L_2$ penalties, defined as:</p> - -<ul> - <li>$L_1$: $R(\wv) = \norm{\wv}_1$</li> - <li>$L_2$: $R(\wv) = \frac{1}{2}\norm{\wv}_2^2$</li> -</ul> - -<p>The $L_2$ penalty penalizes large weights, favoring solutions with more small weights rather than -few large ones. -The $L_1$ penalty can be used to drive a number of the solution coefficients to 0, thereby -producing sparse solutions. -The regularization constant $\lambda$ in $\eqref{eq:objectiveFunc}$ determines the amount of regularization applied to the model, -and is usually determined through model cross-validation. -A good comparison of regularization types can be found in <a href="http://www.robotics.stanford.edu/~ang/papers/icml04-l1l2.pdf">this</a> paper by Andrew Ng. -Which regularization type is supported depends on the actually used optimization algorithm.</p> - -<h2 id="stochastic-gradient-descent">Stochastic Gradient Descent</h2> - -<p>In order to find a (local) minimum of a function, Gradient Descent methods take steps in the -direction opposite to the gradient of the function $\eqref{eq:objectiveFunc}$ taken with -respect to the current parameters (weights). -In order to compute the exact gradient we need to perform one pass through all the points in -a dataset, making the process computationally expensive. -An alternative is Stochastic Gradient Descent (SGD) where at each iteration we sample one point -from the complete dataset and update the parameters for each point, in an online manner.</p> - -<p>In mini-batch SGD we instead sample random subsets of the dataset, and compute the gradient -over each batch. At each iteration of the algorithm we update the weights once, based on -the average of the gradients computed from each mini-batch.</p> - -<p>An important parameter is the learning rate $\eta$, or step size, which is currently determined as -$\eta = \eta_0/\sqrt{j}$, where $\eta_0$ is the initial step size and $j$ is the iteration -number. The setting of the initial step size can significantly affect the performance of the -algorithm. For some practical tips on tuning SGD see Leon Botouâs -â<a href="http://research.microsoft.com/pubs/192769/tricks-2012.pdf">Stochastic Gradient Descent Tricks</a>â.</p> - -<p>The current implementation of SGD uses the whole partition, making it -effectively a batch gradient descent. Once a sampling operator has been introduced in Flink, true -mini-batch SGD will be performed.</p> - -<h3 id="regularization">Regularization</h3> - -<p>FlinkML supports Stochastic Gradient Descent with L1, L2 and no regularization. -The following list contains a mapping between the implementing classes and the regularization function.</p> - -<table class="table table-bordered"> - <thead> - <tr> - <th class="text-left" style="width: 20%">Class Name</th> - <th class="text-center">Regularization function $R(\wv)$</th> - </tr> - </thead> - <tbody> - <tr> - <td><code>SimpleGradient</code></td> - <td>$R(\wv) = 0$</td> - </tr> - <tr> - <td><code>GradientDescentL1</code></td> - <td>$R(\wv) = \norm{\wv}_1$</td> - </tr> - <tr> - <td><code>GradientDescentL2</code></td> - <td>$R(\wv) = \frac{1}{2}\norm{\wv}_2^2$</td> - </tr> - </tbody> -</table> - -<h3 id="parameters">Parameters</h3> - -<p>The stochastic gradient descent implementation can be controlled by the following parameters:</p> - -<table class="table table-bordered"> - <thead> - <tr> - <th class="text-left" style="width: 20%">Parameter</th> - <th class="text-center">Description</th> - </tr> - </thead> - <tbody> - <tr> - <td><strong>LossFunction</strong></td> - <td> - <p> - The loss function to be optimized. (Default value: <strong>None</strong>) - </p> - </td> - </tr> - <tr> - <td><strong>RegularizationConstant</strong></td> - <td> - <p> - The amount of regularization to apply. (Default value: <strong>0.0</strong>) - </p> - </td> - </tr> - <tr> - <td><strong>Iterations</strong></td> - <td> - <p> - The maximum number of iterations. (Default value: <strong>10</strong>) - </p> - </td> - </tr> - <tr> - <td><strong>LearningRate</strong></td> - <td> - <p> - Initial learning rate for the gradient descent method. - This value controls how far the gradient descent method moves in the opposite direction - of the gradient. - (Default value: <strong>0.1</strong>) - </p> - </td> - </tr> - <tr> - <td><strong>ConvergenceThreshold</strong></td> - <td> - <p> - When set, iterations stop if the relative change in the value of the objective function $\eqref{eq:objectiveFunc}$ is less than the provided threshold, $\tau$. - The convergence criterion is defined as follows: $\left| \frac{f(\wv)_{i-1} - f(\wv)_i}{f(\wv)_{i-1}}\right| < \tau$. - (Default value: <strong>None</strong>) - </p> - </td> - </tr> - </tbody> - </table> - -<h3 id="loss-function">Loss Function</h3> - -<p>The loss function which is minimized has to implement the <code>LossFunction</code> interface, which defines methods to compute the loss and the gradient of it. -Either one defines ones own <code>LossFunction</code> or one uses the <code>GenericLossFunction</code> class which constructs the loss function from an outer loss function and a prediction function. -An example can be seen here</p> - -<p><code>Scala -val lossFunction = GenericLossFunction(SquaredLoss, LinearPrediction) -</code></p> - -<p>The full list of supported outer loss functions can be found <a href="#partial-loss-function-values">here</a>. -The full list of supported prediction functions can be found <a href="#prediction-function-values">here</a>.</p> - -<h4 id="partial-loss-function-values">Partial Loss Function Values</h4> - -<table class="table table-bordered"> - <thead> - <tr> - <th class="text-left" style="width: 20%">Function Name</th> - <th class="text-center">Description</th> - <th class="text-center">Loss</th> - <th class="text-center">Loss Derivative</th> - </tr> - </thead> - <tbody> - <tr> - <td><strong>SquaredLoss</strong></td> - <td> - <p> - Loss function most commonly used for regression tasks. - </p> - </td> - <td class="text-center">$\frac{1}{2} (\wv^T \cdot \x - y)^2$</td> - <td class="text-center">$\wv^T \cdot \x - y$</td> - </tr> - </tbody> - </table> - -<h4 id="prediction-function-values">Prediction Function Values</h4> - -<table class="table table-bordered"> - <thead> - <tr> - <th class="text-left" style="width: 20%">Function Name</th> - <th class="text-center">Description</th> - <th class="text-center">Prediction</th> - <th class="text-center">Prediction Gradient</th> - </tr> - </thead> - <tbody> - <tr> - <td><strong>LinearPrediction</strong></td> - <td> - <p> - The function most commonly used for linear models, such as linear regression and - linear classifiers. - </p> - </td> - <td class="text-center">$\x^T \cdot \wv$</td> - <td class="text-center">$\x$</td> - </tr> - </tbody> - </table> - -<h3 id="examples">Examples</h3> - -<p>In the Flink implementation of SGD, given a set of examples in a <code>DataSet[LabeledVector]</code> and -optionally some initial weights, we can use <code>GradientDescentL1.optimize()</code> in order to optimize -the weights for the given data.</p> - -<p>The user can provide an initial <code>DataSet[WeightVector]</code>, -which contains one <code>WeightVector</code> element, or use the default weights which are all set to 0. -A <code>WeightVector</code> is a container class for the weights, which separates the intercept from the -weight vector. This allows us to avoid applying regularization to the intercept.</p> - -<div class="highlight"><pre><code class="language-scala" data-lang="scala"><span class="c1">// Create stochastic gradient descent solver</span> -<span class="k">val</span> <span class="n">sgd</span> <span class="k">=</span> <span class="nc">GradientDescentL1</span><span class="o">()</span> - <span class="o">.</span><span class="n">setLossFunction</span><span class="o">(</span><span class="nc">SquaredLoss</span><span class="o">())</span> - <span class="o">.</span><span class="n">setRegularizationConstant</span><span class="o">(</span><span class="mf">0.2</span><span class="o">)</span> - <span class="o">.</span><span class="n">setIterations</span><span class="o">(</span><span class="mi">100</span><span class="o">)</span> - <span class="o">.</span><span class="n">setLearningRate</span><span class="o">(</span><span class="mf">0.01</span><span class="o">)</span> - - -<span class="c1">// Obtain data</span> -<span class="k">val</span> <span class="n">trainingDS</span><span class="k">:</span> <span class="kt">DataSet</span><span class="o">[</span><span class="kt">LabeledVector</span><span class="o">]</span> <span class="k">=</span> <span class="o">...</span> - -<span class="c1">// Optimize the weights, according to the provided data</span> -<span class="k">val</span> <span class="n">weightDS</span> <span class="k">=</span> <span class="n">sgd</span><span class="o">.</span><span class="n">optimize</span><span class="o">(</span><span class="n">trainingDS</span><span class="o">)</span></code></pre></div> - - - </div> - - <div class="col-sm-10 col-sm-offset-1"> - <!-- Disqus thread and some vertical offset --> - <div style="margin-top: 75px; margin-bottom: 50px" id="disqus_thread"></div> - </div> -</div> - - </div><!-- /.container --> - - <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> - <!-- Include all compiled plugins (below), or include individual files as needed --> - <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> - <script src="http://flink.apache.org/docs/0.9/page/js/codetabs.js"></script> - - <!-- Google Analytics --> - <script> - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', 'UA-52545728-1', 'auto'); - ga('send', 'pageview'); - </script> - - <!-- Disqus --> - <script type="text/javascript"> - var disqus_shortname = 'stratosphere-eu'; - (function() { - var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; - dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; - (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); - })(); -</script> - </body> -</html>
