public interface TranslatingRecommender
This is a variation on the usual ItemBasedRecommender
from Mahout (which uses long values to identify users and items) that instead uses String
as keys. Implementations of this interface perform the same functions, but internally translate from
instances of type String to long and back. In particular, Strings are hashed to
long values using MD5, and the reverse mapping is stored locally for a reverse translation.
To do this, the client must be aware of all item IDs that may be returned. It will receive a hashed
value from the Serving Layer, and must have been initialized with addItemIDs(Iterable) or
addItemIDs(File) first in order to perform the reverse translation. Otherwise the returned item IDs
will be (string representations of) the hashed value only.
| Modifier and Type | Method and Description |
|---|---|
void |
addItemIDs(File idFile)
Like
addItemIDs(Iterable), but accepts a file containing item IDs, one per line. |
void |
addItemIDs(Iterable<String> ids)
"Teaches" the client about item IDs, so that when the underlying recommender returns their hashed
representation, this client can translate them back into true IDs.
|
void |
await()
Blocks indefinitely until
isReady() returns true. |
boolean |
await(long time,
TimeUnit unit)
Blocks until
isReady() returns true, or the given timeout is reached. |
float |
estimateForAnonymous(String toItemID,
String[] itemIDs) |
float |
estimateForAnonymous(String toItemID,
String[] itemIDs,
float[] values) |
float |
estimatePreference(String userID,
String itemID) |
float[] |
estimatePreferences(String userID,
String... itemIDs) |
Collection<String> |
getAllItemIDs() |
Collection<String> |
getItemCluster(int n) |
int |
getNumItemClusters() |
int |
getNumUserClusters() |
Collection<String> |
getUserCluster(int n) |
void |
ingest(File file) |
void |
ingest(Reader reader) |
boolean |
isReady() |
List<TranslatedRecommendedItem> |
mostPopularItems(int howMany) |
List<TranslatedRecommendedItem> |
mostSimilarItems(String[] itemIDs,
int howMany) |
List<TranslatedRecommendedItem> |
mostSimilarItems(String[] itemIDs,
int howMany,
String[] rescorerParams,
String contextUserID) |
List<TranslatedRecommendedItem> |
mostSimilarItems(String itemID,
int howMany) |
List<TranslatedRecommendedItem> |
recommend(String userID,
int howMany) |
List<TranslatedRecommendedItem> |
recommend(String userID,
int howMany,
boolean considerKnownItems,
String[] rescorerParams) |
List<TranslatedRecommendedItem> |
recommendedBecause(String userID,
String itemID,
int howMany) |
List<TranslatedRecommendedItem> |
recommendToAnonymous(String[] itemIDs,
float[] values,
int howMany) |
List<TranslatedRecommendedItem> |
recommendToAnonymous(String[] itemIDs,
float[] values,
int howMany,
String[] rescorerParams,
String contextUserID) |
List<TranslatedRecommendedItem> |
recommendToAnonymous(String[] itemIDs,
int howMany) |
List<TranslatedRecommendedItem> |
recommendToMany(String[] userIDs,
int howMany,
boolean considerKnownItems,
String[] rescorerParams) |
void |
refresh() |
void |
removePreference(String userID,
String itemID) |
void |
setItemTag(String tag,
String itemID) |
void |
setItemTag(String tag,
String itemID,
float value) |
void |
setPreference(String userID,
String itemID) |
void |
setPreference(String userID,
String itemID,
float value) |
void |
setUserTag(String userID,
String tag) |
void |
setUserTag(String userID,
String tag,
float value) |
float[] |
similarityToItem(String toItemID,
String... itemIDs) |
float[] |
similarityToItem(String toItemID,
String[] itemIDs,
String contextUserID) |
List<TranslatedRecommendedItem> recommend(String userID, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.recommend(long, int)List<TranslatedRecommendedItem> recommend(String userID, int howMany, boolean considerKnownItems, String[] rescorerParams) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.recommend(long, int, boolean, String[])List<TranslatedRecommendedItem> recommendToMany(String[] userIDs, int howMany, boolean considerKnownItems, String[] rescorerParams) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.recommendToMany(long[], int, boolean, String[])float estimatePreference(String userID, String itemID) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.estimatePreference(long, long)float[] estimatePreferences(String userID, String... itemIDs) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.estimatePreferences(long, long...)float estimateForAnonymous(String toItemID, String[] itemIDs) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.estimateForAnonymous(long, long[])float estimateForAnonymous(String toItemID, String[] itemIDs, float[] values) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.estimateForAnonymous(long, long[], float[])void setPreference(String userID, String itemID) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setPreference(long, long)void setPreference(String userID, String itemID, float value) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setPreference(long, long, float)void removePreference(String userID, String itemID) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.removePreference(long, long)void setUserTag(String userID, String tag) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setUserTag(long, String)void setUserTag(String userID, String tag, float value) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setUserTag(long, String, float)void setItemTag(String tag, String itemID) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setItemTag(String, long)void setItemTag(String tag, String itemID, float value) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setItemTag(String, long, float)List<TranslatedRecommendedItem> mostSimilarItems(String itemID, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.mostSimilarItems(long, int)List<TranslatedRecommendedItem> mostSimilarItems(String[] itemIDs, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.mostSimilarItems(long[], int)List<TranslatedRecommendedItem> mostSimilarItems(String[] itemIDs, int howMany, String[] rescorerParams, String contextUserID) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.mostSimilarItems(long[], int, String[], Long)float[] similarityToItem(String toItemID, String... itemIDs) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.similarityToItem(long, long...)float[] similarityToItem(String toItemID, String[] itemIDs, String contextUserID) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.similarityToItem(long, long[], Long)List<TranslatedRecommendedItem> recommendedBecause(String userID, String itemID, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.recommendedBecause(long, long, int)List<TranslatedRecommendedItem> recommendToAnonymous(String[] itemIDs, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.recommendToAnonymous(long[], int)List<TranslatedRecommendedItem> recommendToAnonymous(String[] itemIDs, float[] values, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.recommendToAnonymous(long[], float[], int)List<TranslatedRecommendedItem> recommendToAnonymous(String[] itemIDs, float[] values, int howMany, String[] rescorerParams, String contextUserID) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.recommendToAnonymous(long[], float[], int, String[], Long)List<TranslatedRecommendedItem> mostPopularItems(int howMany) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.mostPopularItems(int)void ingest(Reader reader) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.ingest(Reader)void ingest(File file) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.ingest(File)void addItemIDs(Iterable<String> ids)
addItemIDs(File).ids - item IDs that are in use by the systemvoid addItemIDs(File idFile) throws org.apache.mahout.cf.taste.common.TasteException
addItemIDs(Iterable), but accepts a file containing item IDs, one per line.idFile - file with one ID per lineorg.apache.mahout.cf.taste.common.TasteExceptionboolean isReady()
throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionvoid refresh()
MyrrixRecommender.refresh()void await()
throws org.apache.mahout.cf.taste.common.TasteException,
InterruptedException
isReady() returns true.org.apache.mahout.cf.taste.common.TasteException - if an error occurs while checking isReady()InterruptedException - if the thread is interrupted while waitingboolean await(long time,
TimeUnit unit)
throws org.apache.mahout.cf.taste.common.TasteException,
InterruptedException
isReady() returns true, or the given timeout is reached.true if isReady() is true, or false if it timed outorg.apache.mahout.cf.taste.common.TasteException - if an error occurs while checking isReady()InterruptedException - if the thread is interrupted while waitingCollection<String> getAllItemIDs() throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionint getNumUserClusters()
throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.getNumUserClusters()int getNumItemClusters()
throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.getNumItemClusters()Collection<String> getUserCluster(int n) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.getUserCluster(int)Collection<String> getItemCluster(int n) throws org.apache.mahout.cf.taste.common.TasteException
org.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.getItemCluster(int)Copyright © 2012-2013 Myrrix Ltd. All Rights Reserved.