|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.planetj.taste.impl.correlation.GenericItemCorrelation
public final class GenericItemCorrelation
A "generic" GenericItemCorrelation.ItemItemCorrelation which takes a static list of precomputed Item
correlations and bases its responses on that alone. The values may have been precomputed
offline by another process, stored in a file, and then read and fed into an instance of this class.
This is perhaps the best GenericItemCorrelation.ItemItemCorrelation to use with
GenericItemBasedRecommender, for now, since the point of item-based
recommenders is that they can take advantage of the fact that item similarity is relatively static,
can be precomputed, and then used in computation to gain a significant performance advantage.
| Nested Class Summary | |
|---|---|
static class |
GenericItemCorrelation.ItemItemCorrelation
Encapsulates a correlation between two items. |
| Constructor Summary | |
|---|---|
GenericItemCorrelation(ItemCorrelation otherCorrelation,
DataModel dataModel)
Builds a list of item-item correlations given an GenericItemCorrelation.ItemItemCorrelation implementation and a
DataModel, rather than a list of GenericItemCorrelation.ItemItemCorrelations. |
|
GenericItemCorrelation(ItemCorrelation otherCorrelation,
DataModel dataModel,
int maxToKeep)
Like GenericItemCorrelation(ItemCorrelation, DataModel) )}, but will only
keep the specified number of correlations from the given DataModel. |
|
GenericItemCorrelation(java.lang.Iterable<GenericItemCorrelation.ItemItemCorrelation> correlations)
Creates a GenericItemCorrelation from a precomputed list of GenericItemCorrelation.ItemItemCorrelations. |
|
GenericItemCorrelation(java.lang.Iterable<GenericItemCorrelation.ItemItemCorrelation> correlations,
int maxToKeep)
Like GenericItemCorrelation(Iterable), but will only keep the specified number of correlations
from the given Iterable of correlations. |
|
| Method Summary | |
|---|---|
double |
itemCorrelation(Item item1,
Item item2)
Returns the correlation between two items. |
void |
refresh()
Triggers "refresh" -- whatever that means -- of the implementation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GenericItemCorrelation(java.lang.Iterable<GenericItemCorrelation.ItemItemCorrelation> correlations)
Creates a GenericItemCorrelation from a precomputed list of GenericItemCorrelation.ItemItemCorrelations. Each
represents the correlation between two distinct items. Since correlation is assumed to be symmetric,
it is not necessary to specify correlation between item1 and item2, and item2 and item1. Both are the same.
It is also not necessary to specify a correlation between any item and itself; these are assumed to be 1.0.
Note that specifying a correlation between two items twice is not an error, but, the later value will win.
correlations - set of GenericItemCorrelation.ItemItemCorrelations on which to base this instance
public GenericItemCorrelation(java.lang.Iterable<GenericItemCorrelation.ItemItemCorrelation> correlations,
int maxToKeep)
Like GenericItemCorrelation(Iterable), but will only keep the specified number of correlations
from the given Iterable of correlations. It will keep those with the highest correlation --
those that are therefore most important.
Thanks to tsmorton for suggesting this and providing part of the implementation.
correlations - set of GenericItemCorrelation.ItemItemCorrelations on which to base this instancemaxToKeep - maximum number of correlations to keep
public GenericItemCorrelation(ItemCorrelation otherCorrelation,
DataModel dataModel)
throws TasteException
Builds a list of item-item correlations given an GenericItemCorrelation.ItemItemCorrelation implementation and a
DataModel, rather than a list of GenericItemCorrelation.ItemItemCorrelations.
It's valid to build a GenericItemCorrelation this way, but perhaps missing some of the point
of an item-based recommender. Item-based recommenders use the assumption that item-item correlations
are relatively fixed, and might be known already independent of user preferences. Hence it is useful
to inject that information, using GenericItemCorrelation(Iterable).
otherCorrelation - other GenericItemCorrelation.ItemItemCorrelation to get correlations fromdataModel - data model to get Items from
TasteException - if an error occurs while accessing the DataModel items
public GenericItemCorrelation(ItemCorrelation otherCorrelation,
DataModel dataModel,
int maxToKeep)
throws TasteException
Like GenericItemCorrelation(ItemCorrelation, DataModel) )}, but will only
keep the specified number of correlations from the given DataModel.
It will keep those with the highest correlation -- those that are therefore most important.
Thanks to tsmorton for suggesting this and providing part of the implementation.
otherCorrelation - other GenericItemCorrelation.ItemItemCorrelation to get correlations fromdataModel - data model to get Items frommaxToKeep - maximum number of correlations to keep
TasteException - if an error occurs while accessing the DataModel items| Method Detail |
|---|
public double itemCorrelation(Item item1,
Item item2)
Returns the correlation between two items. Note that correlation is assumed to be symmetric, that
itemCorrelation(item1, item2) == itemCorrelation(item2, item1), and that
itemCorrelation(item1, item1) == 1.0 for all items.
itemCorrelation in interface ItemCorrelationitem1 - first itemitem2 - second item
public void refresh()
Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that
any Refreshable should always leave itself in a consistent, operational state, and that
the refresh atomically updates internal state from old to new.
refresh in interface Refreshable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||