public abstract class AbstractRecommender extends java.lang.Object implements Recommender
Modifier and Type | Field and Description |
---|---|
protected Configuration |
conf
conf
|
protected RecommenderContext |
context
RecommenderContext
|
protected float |
decay
decay of learning rate
|
protected boolean |
earlyStop
early-stop criteria
|
protected double |
globalMean
global mean of ratings
|
protected boolean |
isBoldDriver
whether to adjust learning rate automatically
|
protected boolean |
isRanking
is ranking or rating
|
com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> |
itemMappingData
item Mapping Data
|
protected double |
lastLoss
objective loss
|
protected org.apache.commons.logging.Log |
LOG
LOG
|
protected double |
loss
objective loss
|
protected double |
maxRate
Maximum rate of rating scale
|
protected double |
minRate
Minimum rate of rating scale
|
protected int |
numItems
the number of items
|
protected int |
numRates
the number of rates
|
protected int |
numUsers
the number of users
|
protected static java.util.List<java.lang.Double> |
ratingScale
a list of rating scales
|
protected RecommendedList |
recommendedList
Recommended Item List
|
protected SparseMatrix |
testMatrix
testMatrix
|
protected int |
topN
topN
|
protected SparseMatrix |
trainMatrix
trainMatrix
|
com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> |
userMappingData
user Mapping Data
|
protected SparseMatrix |
validMatrix
validMatrix
|
protected static boolean |
verbose
verbose
|
Constructor and Description |
---|
AbstractRecommender() |
Modifier and Type | Method and Description |
---|---|
protected void |
cleanup()
cleanup
|
double |
evaluate(RecommenderEvaluator evaluator)
evaluate
|
java.util.Map<Measure.MeasureValue,java.lang.Double> |
evaluateMap()
evaluate Map
|
protected RecommenderContext |
getContext()
get Context
|
DataModel |
getDataModel()
get Data Model
|
java.util.List<RecommendedItem> |
getRecommendedList()
get Recommended List
|
protected boolean |
isConverged(int iter)
Post each iteration, we do things:
print debug information
check if converged
if not, adjust learning rate
|
void |
loadModel(java.lang.String filePath)
(non-Javadoc)
|
protected abstract double |
predict(int userIdx,
int itemIdx)
predict a specific rating for user userIdx on item itemIdx, note that the
prediction is not bounded.
|
protected double |
predict(int userIdx,
int itemIdx,
boolean bound)
predict a specific rating for user userIdx on item itemIdx.
|
protected RecommendedList |
recommend()
recommend
* predict the ranking scores or ratings in the test data
|
void |
recommend(RecommenderContext context)
recommend
|
protected RecommendedList |
recommendRank()
recommend
* predict the ranking scores in the test data
|
protected RecommendedList |
recommendRating()
recommend
* predict the ratings in the test data
|
void |
saveModel(java.lang.String filePath)
(non-Javadoc)
|
void |
setContext(RecommenderContext context)
set Context
|
protected void |
setup()
setup
|
protected abstract void |
trainModel()
train Model
|
protected final org.apache.commons.logging.Log LOG
protected boolean isRanking
protected int topN
protected Configuration conf
protected RecommenderContext context
protected SparseMatrix trainMatrix
protected SparseMatrix testMatrix
protected SparseMatrix validMatrix
protected RecommendedList recommendedList
protected int numUsers
protected int numItems
protected int numRates
protected double maxRate
protected double minRate
protected static java.util.List<java.lang.Double> ratingScale
public com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> userMappingData
public com.google.common.collect.BiMap<java.lang.String,java.lang.Integer> itemMappingData
protected double globalMean
protected boolean earlyStop
protected static boolean verbose
protected double loss
protected double lastLoss
protected boolean isBoldDriver
protected float decay
protected void setup() throws LibrecException
LibrecException
- if error occurs during setupprotected abstract void trainModel() throws LibrecException
LibrecException
- if error occurs during training modelpublic void recommend(RecommenderContext context) throws LibrecException
recommend
in interface Recommender
context
- recommender contextLibrecException
- if error occurs during recommendingprotected RecommendedList recommend() throws LibrecException
LibrecException
- if error occurs during recommendingprotected RecommendedList recommendRank() throws LibrecException
LibrecException
- if error occurs during recommendingprotected RecommendedList recommendRating() throws LibrecException
LibrecException
- if error occurs during recommendingprotected abstract double predict(int userIdx, int itemIdx) throws LibrecException
userIdx
- user indexitemIdx
- item indexLibrecException
- if error occurs during predictingprotected double predict(int userIdx, int itemIdx, boolean bound) throws LibrecException
userIdx
- user indexitemIdx
- item indexbound
- whether there is a boundLibrecException
- if error occurs during predictingpublic double evaluate(RecommenderEvaluator evaluator) throws LibrecException
evaluate
in interface Recommender
evaluator
- recommender evaluatorLibrecException
- if error occurs during evaluatingpublic java.util.Map<Measure.MeasureValue,java.lang.Double> evaluateMap() throws LibrecException
evaluateMap
in interface Recommender
LibrecException
- if error occurs during constructing evaluate mapprotected void cleanup() throws LibrecException
LibrecException
- if error occurs during cleanuppublic void loadModel(java.lang.String filePath)
loadModel
in interface Recommender
filePath
- file pathRecommender.loadModel(String)
public void saveModel(java.lang.String filePath)
saveModel
in interface Recommender
filePath
- file pathRecommender.saveModel(String)
protected RecommenderContext getContext()
public void setContext(RecommenderContext context)
setContext
in interface Recommender
context
- recommender contextpublic DataModel getDataModel()
getDataModel
in interface Recommender
public java.util.List<RecommendedItem> getRecommendedList()
getRecommendedList
in interface Recommender
protected boolean isConverged(int iter) throws LibrecException
iter
- current iterationLibrecException
- if error occursCopyright © 2017. All Rights Reserved.