@DefaultProvider(value=ItemItemModelProvider.class) @Shareable public class SimilarityMatrixModel extends java.lang.Object implements java.io.Serializable, ItemItemModel
Item-item similarity model using an in-memory similarity matrix.
These similarities are post-normalization, so code using them should use the same normalizations used by the builder to make use of the similarity scores.
Constructor and Description |
---|
SimilarityMatrixModel(java.util.Map<java.lang.Long,Long2DoubleMap> nbrs)
Construct a new item-item model.
|
SimilarityMatrixModel(SortedKeyIndex items,
java.util.List<Long2DoubleMap> nbrs)
Deprecated.
This is deprecated for public usage. It is better to use the other constructor.
|
Modifier and Type | Method and Description |
---|---|
LongSortedSet |
getItemUniverse()
Get the set of all items in the model.
|
Long2DoubleMap |
getNeighbors(long item)
Get the neighbors of an item scored by similarity.
|
java.lang.String |
toString() |
@Deprecated public SimilarityMatrixModel(SortedKeyIndex items, java.util.List<Long2DoubleMap> nbrs)
Construct a new item-item model.
items
- The item domain.nbrs
- The item neighborhoods.public SimilarityMatrixModel(java.util.Map<java.lang.Long,Long2DoubleMap> nbrs)
Construct a new item-item model.
nbrs
- The item neighborhoods. The item neighborhood lists are not copied.public LongSortedSet getItemUniverse()
ItemItemModel
Get the set of all items in the model.
getItemUniverse
in interface ItemItemModel
@Nonnull public Long2DoubleMap getNeighbors(long item)
ItemItemModel
Get the neighbors of an item scored by similarity. This is the corresponding row of the item-item similarity matrix (see org.lenskit.knn.item
).
getNeighbors
in interface ItemItemModel
item
- The item to get the neighborhood for.public java.lang.String toString()
toString
in class java.lang.Object