@Shareable public class DefaultUserVectorNormalizer extends Object implements UserVectorNormalizer, Serializable
Default user vector normalizer that delegates to a generic VectorNormalizer
.
Modifier and Type | Field and Description |
---|---|
protected VectorNormalizer |
delegate |
Constructor and Description |
---|
DefaultUserVectorNormalizer()
Construct a new user vector normalizer that uses the identity normalization.
|
DefaultUserVectorNormalizer(VectorNormalizer norm)
Construct a new user vector normalizer wrapping a generic vector normalizer.
|
Modifier and Type | Method and Description |
---|---|
VectorNormalizer |
getVectorNormalizer()
Get the delegate vector normalizer.
|
InvertibleFunction<Long2DoubleMap,Long2DoubleMap> |
makeTransformation(long user,
Long2DoubleMap vector)
Make a vector transformation for a user.
|
VectorTransformation |
makeTransformation(long user,
SparseVector vector)
Make a vector transformation for a user.
|
MutableSparseVector |
normalize(long user,
SparseVector vector,
MutableSparseVector target)
Normalize a vector with respect to a user vector.
|
protected final VectorNormalizer delegate
public DefaultUserVectorNormalizer()
Construct a new user vector normalizer that uses the identity normalization.
@Inject public DefaultUserVectorNormalizer(VectorNormalizer norm)
Construct a new user vector normalizer wrapping a generic vector normalizer.
norm
- The generic normalizer to use.public VectorNormalizer getVectorNormalizer()
Get the delegate vector normalizer.
public MutableSparseVector normalize(long user, @Nonnull SparseVector vector, @Nullable MutableSparseVector target)
UserVectorNormalizer
Normalize a vector with respect to a user vector.
normalize
in interface UserVectorNormalizer
user
- The user to normalize a vector for.vector
- The user’s vector for reference.target
- The vector to normalize. If null
, the user vector is normalized.target
vector, if specified. Otherwise, a fresh mutable vector containing a normalized copy of the user vector is returned.public VectorTransformation makeTransformation(long user, SparseVector vector)
UserVectorNormalizer
Make a vector transformation for a user. The resulting transformation will be applied to user vectors to normalize and denormalize them.
makeTransformation
in interface UserVectorNormalizer
user
- The user ID to normalize for.vector
- The user’s vector to use as the reference vector.public InvertibleFunction<Long2DoubleMap,Long2DoubleMap> makeTransformation(long user, Long2DoubleMap vector)
UserVectorNormalizer
Make a vector transformation for a user. The resulting transformation will be applied to user vectors to normalize and denormalize them.
makeTransformation
in interface UserVectorNormalizer
user
- The user ID to normalize for.vector
- The user’s vector to use as the reference vector.