public final class TranslatingClientRecommender extends Object implements TranslatingRecommender
TranslatingRecommender. It delegates to an underlying ClientRecommender
which must be created and configured first.| Constructor and Description |
|---|
TranslatingClientRecommender(ClientRecommender delegate) |
TranslatingClientRecommender(ClientRecommender delegate,
org.apache.mahout.cf.taste.model.IDMigrator userTranslator,
MemoryIDMigrator itemTranslator) |
| Modifier and Type | Method and Description |
|---|---|
void |
addItemIDs(File idFile)
Like
TranslatingRecommender.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
TranslatingRecommender.isReady() returns true. |
boolean |
await(long time,
TimeUnit unit)
Blocks until
TranslatingRecommender.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) |
public TranslatingClientRecommender(ClientRecommender delegate)
delegate - underlying ClientRecommender to use with translationpublic TranslatingClientRecommender(ClientRecommender delegate, org.apache.mahout.cf.taste.model.IDMigrator userTranslator, MemoryIDMigrator itemTranslator)
delegate - underlying ClientRecommender to use with translationuserTranslator - IDMigrator that translates users (need not translate back), or null to disable
user translationitemTranslator - MemoryIDMigrator to use to translate items and back, or null to disable item
translationpublic List<TranslatedRecommendedItem> recommend(String userID, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
recommend in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.recommend(long, int)public List<TranslatedRecommendedItem> recommend(String userID, int howMany, boolean considerKnownItems, String[] rescorerParams) throws org.apache.mahout.cf.taste.common.TasteException
recommend in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.recommend(long, int, boolean, String[])public List<TranslatedRecommendedItem> recommendToMany(String[] userIDs, int howMany, boolean considerKnownItems, String[] rescorerParams) throws org.apache.mahout.cf.taste.common.TasteException
recommendToMany in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.recommendToMany(long[], int, boolean, String[])public float estimatePreference(String userID, String itemID) throws org.apache.mahout.cf.taste.common.TasteException
estimatePreference in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.estimatePreference(long, long)public float[] estimatePreferences(String userID, String... itemIDs) throws org.apache.mahout.cf.taste.common.TasteException
estimatePreferences in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.estimatePreferences(long, long...)public float estimateForAnonymous(String toItemID, String[] itemIDs) throws org.apache.mahout.cf.taste.common.TasteException
estimateForAnonymous in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.estimateForAnonymous(long, long[])public float estimateForAnonymous(String toItemID, String[] itemIDs, float[] values) throws org.apache.mahout.cf.taste.common.TasteException
estimateForAnonymous in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.estimateForAnonymous(long, long[], float[])public void setPreference(String userID, String itemID) throws org.apache.mahout.cf.taste.common.TasteException
setPreference in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setPreference(long, long)public void setPreference(String userID, String itemID, float value) throws org.apache.mahout.cf.taste.common.TasteException
setPreference in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setPreference(long, long, float)public void removePreference(String userID, String itemID) throws org.apache.mahout.cf.taste.common.TasteException
removePreference in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.removePreference(long, long)public void setUserTag(String userID, String tag) throws org.apache.mahout.cf.taste.common.TasteException
setUserTag in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setUserTag(long, String)public void setUserTag(String userID, String tag, float value) throws org.apache.mahout.cf.taste.common.TasteException
setUserTag in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setUserTag(long, String, float)public void setItemTag(String tag, String itemID) throws org.apache.mahout.cf.taste.common.TasteException
setItemTag in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setItemTag(String, long)public void setItemTag(String tag, String itemID, float value) throws org.apache.mahout.cf.taste.common.TasteException
setItemTag in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.setItemTag(String, long, float)public List<TranslatedRecommendedItem> mostSimilarItems(String itemID, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
mostSimilarItems in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.mostSimilarItems(long, int)public List<TranslatedRecommendedItem> mostSimilarItems(String[] itemIDs, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
mostSimilarItems in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.mostSimilarItems(long[], int)public List<TranslatedRecommendedItem> mostSimilarItems(String[] itemIDs, int howMany, String[] rescorerParams, String contextUserID) throws org.apache.mahout.cf.taste.common.TasteException
mostSimilarItems in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.mostSimilarItems(long[], int, String[], Long)public float[] similarityToItem(String toItemID, String... itemIDs) throws org.apache.mahout.cf.taste.common.TasteException
similarityToItem in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.similarityToItem(long, long...)public float[] similarityToItem(String toItemID, String[] itemIDs, String contextUserID) throws org.apache.mahout.cf.taste.common.TasteException
similarityToItem in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.similarityToItem(long, long[], Long)public List<TranslatedRecommendedItem> recommendedBecause(String userID, String itemID, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
recommendedBecause in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.recommendedBecause(long, long, int)public List<TranslatedRecommendedItem> recommendToAnonymous(String[] itemIDs, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
recommendToAnonymous in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.recommendToAnonymous(long[], int)public List<TranslatedRecommendedItem> recommendToAnonymous(String[] itemIDs, float[] values, int howMany) throws org.apache.mahout.cf.taste.common.TasteException
recommendToAnonymous in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.recommendToAnonymous(long[], float[], int)public List<TranslatedRecommendedItem> recommendToAnonymous(String[] itemIDs, float[] values, int howMany, String[] rescorerParams, String contextUserID) throws org.apache.mahout.cf.taste.common.TasteException
recommendToAnonymous in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionClientRecommender.recommendToAnonymous(long[], float[], int, String[], Long)public List<TranslatedRecommendedItem> mostPopularItems(int howMany) throws org.apache.mahout.cf.taste.common.TasteException
mostPopularItems in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.mostPopularItems(int)public void ingest(Reader reader) throws org.apache.mahout.cf.taste.common.TasteException
ingest in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.ingest(Reader)public void ingest(File file) throws org.apache.mahout.cf.taste.common.TasteException
ingest in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.ingest(File)public void addItemIDs(Iterable<String> ids)
TranslatingRecommenderTranslatingRecommender.addItemIDs(File).addItemIDs in interface TranslatingRecommenderids - item IDs that are in use by the systempublic void addItemIDs(File idFile) throws org.apache.mahout.cf.taste.common.TasteException
TranslatingRecommenderTranslatingRecommender.addItemIDs(Iterable), but accepts a file containing item IDs, one per line.addItemIDs in interface TranslatingRecommenderidFile - file with one ID per lineorg.apache.mahout.cf.taste.common.TasteExceptionpublic boolean isReady()
throws org.apache.mahout.cf.taste.common.TasteException
isReady in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionpublic void refresh()
refresh in interface TranslatingRecommenderMyrrixRecommender.refresh()public void await()
throws org.apache.mahout.cf.taste.common.TasteException,
InterruptedException
TranslatingRecommenderTranslatingRecommender.isReady() returns true.await in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteException - if an error occurs while checking TranslatingRecommender.isReady()InterruptedException - if the thread is interrupted while waitingpublic boolean await(long time,
TimeUnit unit)
throws org.apache.mahout.cf.taste.common.TasteException,
InterruptedException
TranslatingRecommenderTranslatingRecommender.isReady() returns true, or the given timeout is reached.await in interface TranslatingRecommendertrue if TranslatingRecommender.isReady() is true, or false if it timed outorg.apache.mahout.cf.taste.common.TasteException - if an error occurs while checking TranslatingRecommender.isReady()InterruptedException - if the thread is interrupted while waitingpublic Collection<String> getAllItemIDs() throws org.apache.mahout.cf.taste.common.TasteException
getAllItemIDs in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionpublic int getNumUserClusters()
throws org.apache.mahout.cf.taste.common.TasteException
getNumUserClusters in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.getNumUserClusters()public int getNumItemClusters()
throws org.apache.mahout.cf.taste.common.TasteException
getNumItemClusters in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.getNumItemClusters()public Collection<String> getUserCluster(int n) throws org.apache.mahout.cf.taste.common.TasteException
getUserCluster in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.getUserCluster(int)public Collection<String> getItemCluster(int n) throws org.apache.mahout.cf.taste.common.TasteException
getItemCluster in interface TranslatingRecommenderorg.apache.mahout.cf.taste.common.TasteExceptionMyrrixRecommender.getItemCluster(int)Copyright © 2012-2013 Myrrix Ltd. All Rights Reserved.