Normalizes samples individually to unit Lp norm
For any 1 <= p < float(âinfâ), normalizes samples using sum(abs(vector) p) (1/p) as norm.
For p = float(âinfâ), max(abs(vector)) will be used as norm for normalization.
New in version 1.2.0.
Normalization in L^p^ space, p = 2 by default.
Examples
>>> from pyspark.mllib.linalg import Vectors >>> v = Vectors.dense(range(3)) >>> nor = Normalizer(1) >>> nor.transform(v) DenseVector([0.0, 0.3333, 0.6667])
>>> rdd = sc.parallelize([v]) >>> nor.transform(rdd).collect() [DenseVector([0.0, 0.3333, 0.6667])]
>>> nor2 = Normalizer(float("inf")) >>> nor2.transform(v) DenseVector([0.0, 0.5, 1.0])
Methods
transform
(vector)
Applies unit length normalization on a vector.
Methods Documentation
Applies unit length normalization on a vector.
New in version 1.2.0.
pyspark.mllib.linalg.Vector
or pyspark.RDD
vector or RDD of vector to be normalized.
pyspark.mllib.linalg.Vector
or pyspark.RDD
normalized vector(s). If the norm of the input is zero, it will return the input vector.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4