@DefaultImplementation(value=IdentityVectorNormalizer.class) public interface VectorNormalizer
Normalize vectors by applying a reversible transformation with respect to a reference vector. The reference vector is used to compute the normalization, and it is applied to the target vector; this allows e.g. the user’s average rating to be subtracted from a set of ratings.
Modifier and Type | Method and Description |
---|---|
InvertibleFunction<Long2DoubleMap,Long2DoubleMap> |
makeTransformation(Long2DoubleMap reference)
Create a vector transformation that normalizes and denormalizes vectors with respect to a reference vector.
|
VectorTransformation |
makeTransformation(SparseVector reference)
Deprecated.
|
MutableSparseVector |
normalize(SparseVector reference,
MutableSparseVector target)
Deprecated.
Old vectors are going away.
|
@Deprecated MutableSparseVector normalize(@Nonnull SparseVector reference, @Nullable MutableSparseVector target)
Normalize a vector in-place with a reference vector.
To understand the relationship of reference and vector, consider wanting to subtract the user’s mean rating from a set of ratings. To do that, the user’s rating vector is reference, and the vector of ratings to be adjusted is vector.
This method is equivalent to makeTransformation(reference).apply(target)
.
reference
- The reference used to compute whatever transformation is needed (e.g. the mean value).target
- The vector to normalize. If null
, a new mutable copy of reference is created.null
.@Deprecated VectorTransformation makeTransformation(SparseVector reference)
makeTransformation(Long2DoubleMap)
.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.
reference
- The reference vector.InvertibleFunction<Long2DoubleMap,Long2DoubleMap> makeTransformation(Long2DoubleMap reference)
Create a vector transformation that normalizes and denormalizes vectors with respect to a reference vector. The reference vector is used to compute any data needed for the normalization. For example, a mean-centering normalization will subtract the mean of the reference vector from any vector to which it is applied, and add back the reference mean when it is unapplied.
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.
reference
- The reference vector.