Package es.upm.etsisi.cf4j.recommender
Class Recommender
- java.lang.Object
-
- es.upm.etsisi.cf4j.recommender.Recommender
-
- Direct Known Subclasses:
BeMF
,BiasedMF
,BNMF
,CLiMF
,DeepMF
,DirMF
,GMF
,HPF
,ItemKNN
,MLP
,NCCF
,NeuMF
,NMF
,PMF
,SVDPlusPlus
,URP
,UserKNN
public abstract class Recommender extends Object
Abstract class that represents any recommender. To build a new recommender following methods must be implemented:- fit(): fits the recommender according to an instance of a DataModel.
- predict(userIndex, itemIndex): computes a rating prediction for a given user and item.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Recommender(DataModel datamodel)
Recommender constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
fit()
Estimates model parameters given the hyper-parametersDataModel
getDataModel()
Returns the DataModel instanceabstract double
predict(int userIndex, int itemIndex)
Computes a rating predictiondouble[]
predict(TestUser testUser)
Computes the rating predictions of the TestItems rated by a TestUser
-
-
-
Field Detail
-
datamodel
protected DataModel datamodel
DataModel instance used for the Recommender
-
-
Constructor Detail
-
Recommender
protected Recommender(DataModel datamodel)
Recommender constructor- Parameters:
datamodel
- instance of a DataModel
-
-
Method Detail
-
getDataModel
public DataModel getDataModel()
Returns the DataModel instance- Returns:
- DataModel instance used by the Recommender
-
fit
public abstract void fit()
Estimates model parameters given the hyper-parameters
-
predict
public abstract double predict(int userIndex, int itemIndex)
Computes a rating prediction- Parameters:
userIndex
- Index of the user in the array of Users of the DataModel instanceitemIndex
- Index of the item in the array of Items of the DataModel instance- Returns:
- Prediction
-
predict
public double[] predict(TestUser testUser)
Computes the rating predictions of the TestItems rated by a TestUser- Parameters:
testUser
- TestUser for which to calculate resting predictions- Returns:
- Rating prediction for TestItems rated by testUser. Positions of this array overlaps with testItemIndexes returned by testUser.getTestItemAt(pos)
-
-