@DefaultProvider(value=ItemItemModelProvider.class) @Shareable public class SimilarityMatrixModel extends Object implements 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(Map<Long,Long2DoubleMap> nbrs)
Construct a new item-item model.
|
SimilarityMatrixModel(SortedKeyIndex items,
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.
|
String |
toString() |
@Deprecated public SimilarityMatrixModel(SortedKeyIndex items, List<Long2DoubleMap> nbrs)
Construct a new item-item model.
items
- The item domain.nbrs
- The item neighborhoods.public SimilarityMatrixModel(Map<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.