|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprea.recommender.etc.RankBased
public class RankBased
This is a class implementing rank-based collaborative filtering. Technical detail of the algorithm can be found in M. Sun and G. Lebanon and P. Kidwell, Estimating Probabilities in Recommendation Systems, Proceedings of the fourteenth international conference on Artificial Intelligence and Statistics, 2011.
Field Summary | |
---|---|
static int |
ASYMM_LOSS
Asymmetric loss function |
int |
itemCount
The number of items. |
double |
kernelWidth
Kernel bandwidth. |
private int |
lossType
The type of loss function. |
int |
maxValue
Maximum value of rating, existing in the dataset. |
static int |
MEAN_LOSS
Mean loss function |
int |
minValue
Minimum value of rating, existing in the dataset. |
int[][] |
numTieCount
The number of tie structure for each user with size m testing users by l raing levels. |
int[][] |
prbMatricesIndTrain
Parsed index for each user, 2d array with m testing users by the number of rated items. |
double[][][] |
prbMatricesVal
Parsed prb for each user, 3d array with l rating levels by m testing users by the number of rated items. |
SparseMatrix[] |
predictedArray
The probability array of each rating for testing items and users. |
SparseMatrix |
rateMatrix
Rating matrix for each user (row) and item (column) |
int |
userCount
The number of users. |
Constructor Summary | |
---|---|
RankBased(int uc,
int ic,
double max,
double min,
double kw,
int lt)
Construct a rank-based model with the given data. |
Method Summary | |
---|---|
void |
buildModel(SparseMatrix rm)
Predict the probabilities using the rank-based algorithm with the given test data. |
private void |
constructProbability()
Construct the probability (average rank) structure for each user's ranking. |
private void |
constructTie()
Construct the tie structure for each user's ranking. |
private void |
distanceOneToAllTest(int userId,
int testId,
SparseVector[] dist,
int k,
int[] indexK)
Compute the distance between the testing user with the testing item of every possible ratings and all the other training users with training items. |
private void |
distanceOneToAllTrain(int userId,
double[] dist,
int k,
int[] indexK)
Compute the distance between the testing user and all the other training users with training items. |
EvaluationMetrics |
evaluate(SparseMatrix testMatrix)
Evaluate the rank-based CF algorithm with the given probabilites and loss function. |
private void |
getEstimation(SparseMatrix testMatrix)
Estimate ratings for (user, item) pairs in test data matrix. |
private double |
predict(int userId,
int itemId)
Compute the rating for a given user and a test item, which minimizes the given loss. |
private void |
rankBasedPerUser(int userId,
int testItemId,
double ker,
int k,
int[] index,
double[] distL0,
SparseVector[] distL,
SparseMatrix[] predictedArray)
Predict ratings for a given user and a given test item, by rank-based CF algorithm. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MEAN_LOSS
public static final int ASYMM_LOSS
public SparseMatrix rateMatrix
public int userCount
public int itemCount
public int maxValue
public int minValue
public double kernelWidth
public double[][][] prbMatricesVal
public int[][] prbMatricesIndTrain
public int[][] numTieCount
public SparseMatrix[] predictedArray
private int lossType
Constructor Detail |
---|
public RankBased(int uc, int ic, double max, double min, double kw, int lt)
uc
- The number of users in the dataset.ic
- The number of items in the dataset.max
- The maximum rating value in the dataset.min
- The minimum rating value in the dataset.kw
- The kernel width for density estimationlt
- Loss function used for prediction. It should be either MEAN_LOSS or ASYMM_LOSS.Method Detail |
---|
public void buildModel(SparseMatrix rm)
buildModel
in interface Recommender
rm
- The rating matrix with train data.private void constructProbability()
private void constructTie()
private void distanceOneToAllTrain(int userId, double[] dist, int k, int[] indexK)
userId
- The user ID.dist
- The distance which will be computed.k
- The neighborhood size.indexK
- The index of nearest neighbor which will be computed.private void distanceOneToAllTest(int userId, int testId, SparseVector[] dist, int k, int[] indexK)
userId
- The user ID.testId
- The testing item ID.dist
- The distance which will be computed.k
- The neighborhood size.indexK
- The index of nearest neighbor.private void rankBasedPerUser(int userId, int testItemId, double ker, int k, int[] index, double[] distL0, SparseVector[] distL, SparseMatrix[] predictedArray)
userId
- The user ID.testItemId
- The id of item whose ratings will be predicted.ker
- The kernelwidth.k
- The number of nearest training users.index
- The index of near k users.distL0
- The distance between the test user and all the other k training users.distL
- The distance between the test user with testing item of each possible ratings and all the other k training users.predictedArray
- The array will be filled in with the probabilities of each rating for the user u and the item.public EvaluationMetrics evaluate(SparseMatrix testMatrix)
evaluate
in interface Recommender
testMatrix
- The rating matrix with test data.
private void getEstimation(SparseMatrix testMatrix)
testMatrix
- The rating matrix with test data.private double predict(int userId, int itemId)
userId
- The target user.itemId
- The target test item.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |