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