Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/6127#discussion_r30862746
--- Diff: docs/ml-features.md ---
@@ -618,5 +634,157 @@ indexedData = indexerModel.transform(data)
</div>
</div>
+
+## Normalizer
+
+`Normalizer` is a `Transformer` which transforms a dataset of `Vector`
rows, normalizing each `Vector` to have unit norm. It takes parameter `p`,
which specifies the
[p-norm](http://en.wikipedia.org/wiki/Norm_%28mathematics%29#p-norm) used for
normalization. ($p = 2$ by default.) This normalization can help standardize
your input data and improve the behavior of learning algorithms.
+
+The following example demonstrates how to load a dataset in libsvm format
and then normalize each row to have unit $L^2$ norm and unit $L^\infty$ norm.
+
+<div class="codetabs">
+<div data-lang="scala">
+{% highlight scala %}
+import org.apache.spark.ml.feature.Normalizer
+import org.apache.spark.mllib.util.MLUtils
+
+val data = MLUtils.loadLibSVMFile(sc, "data/mllib/sample_libsvm_data.txt")
+val dataFrame = sqlContext.createDataFrame(data)
+val normalizer = new
Normalizer().setInputCol("features").setOutputCol("normFeatures")
+
+// Normalize each Vector using $L^2$ norm.
+val l2NormData = normalizer.transform(dataFrame, normalizer.p -> 2)
--- End diff --
`p = 2` is the default value. Maybe we can use `setP(1.0)` for normalizer,
and then `transform(..., normalizer.p -> inf)` in to demo how to use extra
params.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]