org.grouplens.lenskit.transform.normalize

## Class UnitVectorNormalizer

• All Implemented Interfaces:
Serializable, VectorNormalizer

@Shareable
public class UnitVectorNormalizer
extends AbstractVectorNormalizer
implements Serializable
Vector normalizer that scales a vector by the factor needed to scale the reference vector to a unit vector. If the length of the reference vector is 0, no normalization is applied.
Serialized Form
• ### Constructor Summary

Constructors
Constructor and Description
UnitVectorNormalizer()
Create a unit vector normalizer with a tolerance of 1.0e-6.
UnitVectorNormalizer(double t)
Create a unit vector normalizer a specified tolerance around 0.
• ### Method Summary

All Methods
Modifier and Type Method and Description
VectorTransformation makeTransformation(SparseVector reference)
Create a vector transformation that normalizes and denormalizes vectors with respect to the specified entity.
• ### Methods inherited from class org.grouplens.lenskit.transform.normalize.AbstractVectorNormalizer

normalize
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### UnitVectorNormalizer

@Inject
public UnitVectorNormalizer()
Create a unit vector normalizer with a tolerance of 1.0e-6.
• #### UnitVectorNormalizer

public UnitVectorNormalizer(double t)
Create a unit vector normalizer a specified tolerance around 0. Any vector norm whose absolute value is less than t is converted to a no-op.
Parameters:
t - The error tolerance for 0-checking.
• ### Method Detail

• #### makeTransformation

public VectorTransformation makeTransformation(SparseVector reference)
Description copied from interface: VectorNormalizer
Create a vector transformation that normalizes and denormalizes vectors with respect to the specified entity. This allows transformations to be applied multiple times to different vectors and also unapplied.

If the reference vector is empty, the returned transformation should be the identity transform. Results are undefined if the reference vector is not complete or contains NaN values.

If the normalization needs to retain a copy of the sparse vector, it will take an immutable copy.

Specified by:
makeTransformation in interface VectorNormalizer
Parameters:
reference - The reference vector.
Returns:
A transformation built from the reference vector.